Extract a .zip archive in a site
/v1/sites/{siteId}/files/actions/extract Extracts a .zip archive of the site into a folder of it (the folder must exist); files already there with the same names are replaced. Links in the archive are left out, and an archive with a path leading outside the folder is refused (422 unsafe_archive).
At most 60,000 files and 4 GB once extracted (413 too_large); a large archive can take minutes. Not while a staging operation copies, pushes or puts back the site (409 staging_busy).
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 |
|---|---|
path Required | string Up to 4,096 characters The .zip archive's path in the site. |
destination Required | string Up to 4,096 characters The folder to extract it into (it must exist). Files already there with the same names are replaced. |
Example request
curl -X POST "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/actions/extract" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"path": "/wp-content/uploads/theme.zip",
"destination": "/wp-content/themes"
}' const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/actions/extract", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"path": "/wp-content/uploads/theme.zip",
"destination": "/wp-content/themes"
}),
});
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.files.extract({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
path: "/wp-content/uploads/theme.zip",
destination: "/wp-content/themes",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/files/actions/extract');
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([
'path' => '/wp-content/uploads/theme.zip',
'destination' => '/wp-content/themes',
]),
]);
$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/files/actions/extract",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"path": "/wp-content/uploads/theme.zip",
"destination": "/wp-content/themes",
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
200 OK Returns the FilesExtracted object in data.
The FilesExtracted object's fields 2 fields
| Field | Type and description |
|---|---|
extractedFiles | integer How many files the archive put in place (folders aren't counted). |
extractedBytes | integer Their total size, in bytes. |
Example response
{
"data": {
"extractedFiles": 184,
"extractedBytes": 5242880
}
} 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 |
|---|---|
400 bad_ | The path isn't one the site's server can use. Use a path in the site that starts with /, without control characters. |
400 not_ | The path is a file, where a folder is needed. Name a folder. |
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 outside_ | The path leads outside the site's folder (through a link), which files can't reach. Use a path inside the site's folder. |
403 permission_ | The site's server refused access to a file or folder: its permissions don't let the site's own user do this. Check its permissions ( |
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 staging_ | A staging operation is running on this site, or on a site of this server. Wait until it finishes ( |
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 |
413 too_ | It's too large for this: a file over 2 MB to read as text, an upload over the limit, or an archive that holds more than 60,000 files or 4 GB. Download the file instead of reading it, upload a smaller file, or extract a smaller archive. |
422 validation_ | One or more fields are missing or wrong. Correct the fields named in |
422 io_ | The site's server couldn't complete the file operation (its disk or file system refused). Try again; if it keeps failing (for example, the disk is full), contact support. |
422 bad_ | The file isn't a valid .zip archive. Check the file, or make the archive again. |
422 unsafe_ | The archive holds a path that would land outside the folder it's extracted to ( Make the archive again without that path. |
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. |
502 file_ | The site's server didn't complete the file operation. Try again in a moment. |