Download a file or folder from a backup
Streams the entry at path (as the file index lists it): a file as it is, a folder as a zip. A file comes as application/octet-stream, a folder as application/zip. When the entry cannot be served the answer is JSON with a message: 404 when the backup holds no such path, 422 for an empty folder or one with too many files, 501 for an encrypted or zstd-compressed backup, 503 while the backup's file list or its storage cannot be reached.
/api/v1/artifacts/{artifact}/entry
curl 'https://app.clokeep.com/api/v1/artifacts/2291/entry?path=httpdocs%2Fwp-config.php' \
-H 'Authorization: Bearer YOUR_API_TOKEN' \
-H 'Accept: application/octet-stream, application/zip' \
--fail \
-o 'wp-config.php'<?php
$ch = curl_init('https://app.clokeep.com/api/v1/artifacts/2291/entry?path=httpdocs%2Fwp-config.php');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_TOKEN',
'Accept: application/octet-stream, application/zip',
],
]);
$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status >= 400) {
throw new RuntimeException('Request failed with status '.$status);
}
file_put_contents('wp-config.php', $response);
import { writeFile } from "node:fs/promises";
const response = await fetch("https://app.clokeep.com/api/v1/artifacts/2291/entry?path=httpdocs%2Fwp-config.php", {
headers: {
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/octet-stream, application/zip",
},
});
if (!response.ok) {
throw new Error("Request failed with status " + response.status);
}
await writeFile("wp-config.php", Buffer.from(await response.arrayBuffer()));
import requests
response = requests.get(
"https://app.clokeep.com/api/v1/artifacts/2291/entry?path=httpdocs%2Fwp-config.php",
headers={
"Authorization": "Bearer YOUR_API_TOKEN",
"Accept": "application/octet-stream, application/zip",
},
)
response.raise_for_status()
with open("wp-config.php", "wb") as file:
file.write(response.content)
Binary body (application/octet-stream, application/zip).
{
"message": "Unauthenticated."
}{
"message": "Backup downloads are disabled."
}{
"message": "This backup holds no file or folder at that path."
}{
"message": "The storage that held this backup was deleted."
}{
"message": "This folder holds no files."
}{
"message": "This backup is encrypted. Per-file download is unavailable; restore it instead."
}{
"message": "The file list of this backup is unavailable: storage unreachable."
}Path Parameters
-
artifactintegerrequired
The ID of the backup.
Example:
2291
Query Parameters
-
pathstringrequired
The path of the file or folder inside the backup, as the entries list gives it.
Example:
httpdocs/wp-config.php
Response
200
The file, or the folder as a zip.
Binary body (application/octet-stream, application/zip)
401
The request carries no valid token: the Authorization: Bearer header is missing, or its token is unknown, revoked or past its expiry date. Send a current personal access token.
-
messagestring
Always
Unauthenticated.
403
The token may not read this. The message says why: Your role does not permit this action. (its owner is not an Admin, Operator or Viewer in the client), This account is disabled., This token is not bound to a client you belong to., or Client suspended. While backup downloads are switched off for the client the message is Backup downloads are disabled.
-
messagestring
What went wrong.
404
The backup, or the file or folder inside it, was not found. A backup that was missing from storage at the last check answers This backup is missing from storage and cannot be downloaded.
-
messagestring
What went wrong.
410
The storage that held this backup was deleted.
-
messagestring
What went wrong.
422
The folder holds no files, or too many to zip.
-
messagestring
What went wrong.
501
The backup is encrypted or zstd-compressed, so one file cannot be taken out of it; restore it instead.
-
messagestring
What went wrong.
503
The backup's file index cannot be read from storage right now. Try again later. The same status, with the message The storage that holds this backup can't be reached right now. Try again later., when the storage that holds the backup does not answer before the download starts.
-
messagestring
What went wrong.