Add a cron job to a site
/v1/sites/{siteId}/cron-jobs Adds a scheduled task to the site: a WP-CLI command, a PHP script of the site, a call to an address, or a shell command, run on a cron schedule in UTC. It runs on the site's server as the site's own user, in the site's folder, and is stopped when it takes longer than timeoutSeconds. A run is skipped while the job's previous run is still going.
Limits. Up to 25 jobs per site (409 limit_reached). The site must have finished installing and its server be running (409 site_unavailable, 409 server_unavailable). The schedule on the server changes in the same step: when the server can't be reached (502 server_unreachable), nothing is changed.
Scopes
The token needs this scope. Without it, the request is refused with insufficient_scope (see Scopes).
-
sites:files - Files and logins. File Manager, WordPress logins, cron jobs, backup downloads and backup storage. Full access to the sites' code and data.
Headers
| Field | Type and description |
|---|---|
Idempotency-Key | string 1 to 255 characters A key of your own for this request, like a UUID: letters, digits and |
Path parameters
| Field | Type and description |
|---|---|
siteId Required | string The site's id. |
Request body
JSON, with these fields. Fields that aren't listed are refused.
| Field | Type and description |
|---|---|
name Required | string 1 to 80 characters The job's name, up to 80 characters. |
type Required | string What the job runs: One of: |
target Required | string 1 to 2,000 characters What it runs, on one line (up to 2,000 characters), by |
schedule Required | string When it runs: a cron schedule of five fields (minute, hour, day of month, month, day of week) in UTC, with numbers, |
timeoutSeconds | integer 60 to 7,200 How long a run may take, in seconds, before it's stopped: 60 (1 minute) to 7,200 (2 hours). Left out: 300 (5 minutes). |
enabled | boolean Whether it runs on its schedule. Left out: |
Example request
curl -X POST "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/cron-jobs" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Nightly clean-up",
"type": "wp_cli",
"target": "transient delete --expired",
"schedule": "0 3 * * *",
"timeoutSeconds": 900
}' const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/cron-jobs", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"name": "Nightly clean-up",
"type": "wp_cli",
"target": "transient delete --expired",
"schedule": "0 3 * * *",
"timeoutSeconds": 900
}),
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data } = await res.json();
console.log(data); import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
const data = await rf.sites.cronJobs.create({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
name: "Nightly clean-up",
type: "wp_cli",
target: "transient delete --expired",
schedule: "0 3 * * *",
timeoutSeconds: 900,
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/cron-jobs');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Nightly clean-up',
'type' => 'wp_cli',
'target' => 'transient delete --expired',
'schedule' => '0 3 * * *',
'timeoutSeconds' => 900,
]),
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
print_r(json_decode($body, true)['data']); import os
import requests
response = requests.post(
"https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/cron-jobs",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"name": "Nightly clean-up",
"type": "wp_cli",
"target": "transient delete --expired",
"schedule": "0 3 * * *",
"timeoutSeconds": 900,
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
201 Created Returns the CronJob object in data.
The CronJob object's fields 10 fields
| Field | Type and description |
|---|---|
id | string The cron job's id. |
siteId | string The site it runs on. |
name | string The job's name. |
type | string What the job runs: Known values: |
target | string What it runs, by |
schedule | string When it runs: a cron schedule of five fields (minute, hour, day of month, month, day of week) in UTC, like |
timeoutSeconds | integer How long a run may take, in seconds, before it's stopped (60 to 7,200). |
enabled | boolean Whether it runs on its schedule. |
createdAt | string An ISO 8601 time, in UTC When the job was added. |
updatedAt | string An ISO 8601 time, in UTC When it was last changed. |
Example response
{
"data": {
"id": "4c1d2e3f-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
"siteId": "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
"name": "Nightly clean-up",
"type": "wp_cli",
"target": "transient delete --expired",
"schedule": "0 3 * * *",
"timeoutSeconds": 900,
"enabled": true,
"createdAt": "2026-11-02T09:14:05.000Z",
"updatedAt": "2026-11-02T09:14:05.000Z"
}
} Errors
The errors this request can answer besides those every request can (a missing token, a missing scope, the rate limits). Each answer is an Error object (see Errors).
| Status and code | When, and what to do |
|---|---|
403 trial_ | The site's server is on the free trial: WordPress sign-in, the File Manager and Cron Jobs switch on once it's kept. Keep the server in the control panel: they switch on by themselves. |
403 · 409 limit_ | A limit is reached: Delete something first, or contact support to raise the limit. |
404 not_ | The resource doesn't exist, or isn't this account's. Check the id. Ids of other accounts' resources answer the same way. |
409 site_ | The site isn't in a state that allows this (for example, it's still installing). Wait until the site is active, then try again. |
409 server_ | The server isn't in a state that allows this (for example, it's off or still being set up). Start the server, or wait until it's active, then try again. |
409 server_ | The server is being restored, and nothing else can change it or its sites until that's done. Wait until the restore finishes (the server's |
422 validation_ | One or more fields are missing or wrong. Correct the fields named in |
502 server_ | The server didn't answer, or didn't finish the request. Check that the server is running, then try again in a minute. |