Skip to main content
Version: 1.0.0

Cron API

Cron jobs can be fully managed through the API and SDK. The section contains methods to execute CRUD-operations against the Cron endpoints.

List#

Returns all cronjobs for selected environment, which is controlled by which API token that is in use.

$response = $client->cron->list();if ($response->wasSuccessful()) {    $items = $response->getResultItems();    // Do something with items}

Create#

Create a cronjob. Note that you need to specify the environment.

Example:

$response = $client->cron->create([    'type' => 'cronjobs',    'attributes' => [        'enabled' => 1,        'command' => 'ls ./',        'comment' => 'This is a cron job created using the PHP SDK',        'schedule' => '* * * * *',        'notifications' => 'none',    ],    'relationships' => [        'environment' => [            'data' => [                'type' => 'environments',                'id' => 123,            ]        ]    ],]);if ($response->wasSuccessful()) {    // Do something} elseif ($response->hasErrors()) {    $errors = $response->getErrors();    // Do something with errors}

Get#

Returns a specific cronjob by ID.

$response = $client->cron->get(123);if (    $response->wasSuccessful()     && $item = $response->getFirstResultItem()) {    // Do something    echo $item->id; // 123}

Delete#

Deletes a cronjob by ID.

$response = $client->cron->delete(123);if ($response->wasSuccessful()) {    // Cronjob deleted}

Update#

Updated a cronjob by ID.

$response = $client->cron->update(123, [    'attributes' => [        'comment' => 'Updated comment'    ]]);if ($response->wasSuccessful()) {    // Cronjob updated}