A script starts a backup the same way Run now does in the panel. The run then goes to the server's agent, and the script follows it until it ends.
Prerequisites
- A token with the Write ability, whose owner is an Admin or Operator in the client. Only an Admin can create one. See Create and manage API tokens.
- A plan whose server has the agent installed. See Plans.
Run the backup
Find the plan's id
Call GET /plans. Plans come in name order, 15 to a page.
curl 'https://app.clokeep.com/api/v1/plans' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/json'
Response, shortened: most of each plan's keys, and links and meta, are left out.
{
"data": [
{
"id": 41,
"server_id": 12,
"name": "Nightly files",
"type": "files",
"type_label": "Files",
"enabled": true
}
]
}
Note the plan's id. It does not change, so a script can keep it.
Start the run
Call POST /plans/{plan}/run with the plan's id. The request has no body.
curl -X POST 'https://app.clokeep.com/api/v1/plans/41/run' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/json'
<?php
$ch = curl_init('https://app.clokeep.com/api/v1/plans/41/run');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN',
'Accept: application/json',
],
]);
$response = curl_exec($ch);
echo $response;
const response = await fetch("https://app.clokeep.com/api/v1/plans/41/run", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
},
});
console.log(await response.text());
import requests
response = requests.post(
"https://app.clokeep.com/api/v1/plans/41/run",
headers={
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
},
)
print(response.text)
The answer is 202 with the new run. Response, shortened: queue, laravel_job_uuid, plan and server are left out.
{
"data": {
"id": 1874,
"plan_id": 41,
"server_id": 12,
"kind": "backup",
"kind_label": "Backup",
"trigger": "api",
"trigger_label": "API",
"status": "queued",
"status_label": "Queued",
"progress_percent": 0,
"current_step": null,
"message": null,
"started_at": null,
"finished_at": null,
"cancel_requested_at": null,
"error_message": null,
"initiated_by_user_id": 8,
"restore": null,
"created_at": "2026-11-20T10:15:00+00:00",
"updated_at": "2026-11-20T10:15:00+00:00"
}
}
data.id is the run's id. The run waits as queued until the server's agent picks it up.
Follow the run until it ends
Call GET /backup-runs/{backupRun} with the run's id until status is final. This endpoint does not count toward the rate limit, so a call every 10 to 30 seconds is fine.
import time
import requests
API = "https://app.clokeep.com/api/v1"
HEADERS = {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
}
FINAL = {"completed", "partial", "failed", "cancelled"}
run_id = 1874
while True:
response = requests.get(f"{API}/backup-runs/{run_id}", headers=HEADERS, timeout=30)
response.raise_for_status()
run = response.json()["data"]
print(run["status"], run["progress_percent"], run["current_step"], run["message"])
if run["status"] in FINAL:
break
time.sleep(15)
if run["error_message"]:
print(run["error_message"])
What the fields hold:
statusisqueued, thenrunning, then one of the four final values:completed,partial(labelPartially completed),failedorcancelled. A final status never changes again.progress_percentgoes from 0 to 100.current_stepis the step the agent is on:prepare,dump,archive,compress,uploadorindex. A queued run can already showprepare, so teststatus, not the step. A completed run showsnull. A failed or cancelled run keeps the step it stopped at.messageis the run's latest status line, such asArchiving backup, and at the end a closing line, such asBackup completed successfully.error_messagesays why afailedrun failed, or which items apartialrun could not back up. It isnullotherwise.finished_atis set when the run ends.
A partial run stored real backups for the items that worked. Treat it as a warning, not as a failed run.
The run's backups are listed under artifacts in the same answer. You need their ids to restore one.
Read the log
Call GET /backup-runs/{backupRun}/logs. Lines come oldest first, 15 to a page, each with a level (debug, info, warning or error), a message and created_at. Follow links.next for the rest. This endpoint does not count toward the rate limit either.
curl 'https://app.clokeep.com/api/v1/backup-runs/1874/logs' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/json'
The run is listed under Backup Runs in the panel. Its timeline reads "Triggered through the API by" and your name. The API has no option to start a full backup on an incremental plan. Use Run full backup now in the panel for that. See Incremental backups.
When the run is refused
409 means the plan already has a run that is queued or running:
{
"message": "Plan \"Nightly files\" already has an active backup run."
}
A plan has one active backup run at a time. Do not send the request again in a loop. Find the active run with GET /backup-runs?plan_id=41&status=running, or status=queued, and pick the run whose kind is backup. Follow it instead. Or wait until it ends and run the plan then.
422 means the plan cannot run until something changes in its setup. The message says what:
Server "web-01" is disabled; its backups are paused until it is re-enabled.web-01 has no agent yet. Install it from the server page first.Nightly files has no active storage to upload to. Attach one to the plan, or switch its storage back on.- for a Plesk server or cPanel server plan, a message that every account the plan backs up is gone from the server.
Sending the request again does not help. Log the message and fix the plan or the server first.
Other errors are on Errors and rate limits.
Stop a run
Call POST /backup-runs/{backupRun}/cancel. A queued run is cancelled at once. A running run gets a cancel_requested_at time and stops at the agent's next check. Keep polling until status is cancelled. A run that ends before then keeps its own final status.
A run that has already ended answers 422 with Backup run is not active and cannot be cancelled.
What a stopped run leaves on the storage is on Run and stop a backup.