A restore through the API does what Restore selected backup does in the panel, with the same choices. The agent downloads the backup from your storage and writes it onto the server the backup came from.
A restore writes onto the live server and cannot be undone. Before you script one, read what each choice overwrites on Restore files, email and databases and Restore a Plesk or cPanel account.
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.
- The agent installed on the backup's server.
- For a files restore, a target folder the agent may write to. See Allowed folders.
Queue the restore
Find the backup
Call GET /artifacts. Backups come newest first, 15 to a page. To list only the backups of one run, add ?backup_run_id=1873. A run's backups are also listed under artifacts in GET /backup-runs/{backupRun}.
curl 'https://app.clokeep.com/api/v1/artifacts' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/json'
Response, shortened: most of each backup's keys, and links and meta, are left out.
{
"data": [
{
"id": 2291,
"backup_run_id": 1873,
"filename": "nightly-files-2026-11-20-020007.tar.gz",
"label": null,
"hosting_account_id": null,
"created_at": "2026-11-20T02:14:20+00:00"
}
]
}
Note the backup's id.
Check what kind of backup it is
The body depends on the plan type of the backup. Call GET /backup-runs/{backupRun} with the backup's backup_run_id and read data.plan.type.
plan.type |
Body fields |
|---|---|
files, email |
target_path, overwrite_policy |
database |
database_connection_id |
plesk_subscription, cpanel_account |
components and the account fields, or mailbox |
A few Plesk and cPanel backups take the files fields instead: those for which the panel shows the files form, such as one whose account no longer exists. See Files.
A field that does not fit the backup is refused with 422, for example The database connection id field does not apply to this backup. Nothing is queued.
Send the restore
Call POST /artifacts/{artifact}/restore with the backup's id and the body for its kind.
A files or email backup. target_path is an absolute folder on the server, inside the agent's allowed folders. overwrite_policy is overwrite (the default), skip_existing or rename.
For a backup of an incremental plan, every choice restores the newest version of each file. Only overwrite also deletes from the target the files deleted during the chain. See Files.
curl -X POST 'https://app.clokeep.com/api/v1/artifacts/2291/restore' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"target_path": "/var/www/restore",
"overwrite_policy": "skip_existing"
}'
<?php
$ch = curl_init('https://app.clokeep.com/api/v1/artifacts/2291/restore');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN',
'Accept: application/json',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'target_path' => '/var/www/restore',
'overwrite_policy' => 'skip_existing',
]),
]);
$response = curl_exec($ch);
echo $response;
const response = await fetch("https://app.clokeep.com/api/v1/artifacts/2291/restore", {
method: "POST",
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
"Content-Type": "application/json",
},
body: JSON.stringify({
"target_path": "/var/www/restore",
"overwrite_policy": "skip_existing",
}),
});
console.log(await response.text());
import requests
response = requests.post(
"https://app.clokeep.com/api/v1/artifacts/2291/restore",
headers={
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/json",
"Content-Type": "application/json",
},
json={
"target_path": "/var/www/restore",
"overwrite_policy": "skip_existing",
},
)
print(response.text)
A database backup. database_connection_id is a database connection on the backup's server. The dump is imported into the database that connection names. List the server's connections with GET /database-connections?server_id=12 and pick an id.
{
"database_connection_id": 9
}
A Plesk or cPanel backup. components lists the parts to restore. databases names the databases, and database_mode is new (into name_restored) or overwrite. To restore one mailbox, send mailbox alone instead. Every field is on Restore a backup.
{
"components": ["files", "databases"],
"databases": ["wp"],
"database_mode": "new"
}
Left out, database_mode follows the same rule as the panel. It is overwrite when you send apply_settings with settings in components and the account was missing from the server at the last account sync: the re-created account's databases come back empty, and the data goes into them. Otherwise it is new. Send database_mode yourself when you know better, for example for an account deleted since the last sync. With overwrite, each named database is dropped and created again before the import, also for an account that still exists. See Restore a Plesk or cPanel account.
Read the answer
The answer is 202 with the new run. Its kind is restore, and restore holds your choices. Response, shortened: queue, laravel_job_uuid, plan and server are left out.
{
"data": {
"id": 1875,
"plan_id": 41,
"server_id": 12,
"kind": "restore",
"kind_label": "Restore",
"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": {
"source_artifact_id": 2291,
"mode": "alternate_path",
"target_path": "/var/www/restore",
"overwrite_policy": "skip_existing",
"database_connection_id": null,
"account": null
},
"created_at": "2026-11-20T10:40:00+00:00",
"updated_at": "2026-11-20T10:40:00+00:00"
}
}
Follow the restore
Poll GET /backup-runs/{backupRun} with the run's id, as for a backup. See Follow the run until it ends. The final statuses are the same. A restore's steps are download, extract, restore and verify.
A files restore into a folder the agent may not write to fails with an error_message that reads "restore target … is not within an allowed root". See Allowed folders.
When the restore is refused
409: another restore on the same server is queued or running, for exampleServer "web-01" already has an active restore run.A server runs one restore at a time. Wait for that run to end, then send the request again.422witherrors: a field is missing, invalid or does not fit the backup. Fix the body.422withouterrors: the backup cannot be restored. Themessagesays why, for example that its server or plan was deleted, or that it was missing from storage at the last check.503: the backup's file list cannot be read from storage.messagesays why. For a Plesk or cPanel backup, it starts withThe file list of this backup is unavailable:. Nothing is queued. Try again later if the storage was unreachable or the file list was still being fetched by another request. If the file list is missing from storage, a retry does not help.
To stop a restore, call POST /backup-runs/{backupRun}/cancel, as for a backup. What a stopped restore already wrote stays on the server. See One restore at a time, and stopping one.