Try setting up Media Offload again
/v1/sites/{siteId}/media-offload/actions/retry-setup Tries setting Media Offload up again after it failed (status: "failed"). The answer is 202 with status: "setting_up"; poll GET /sites/{siteId}/media-offload until it's active. 409 not_failed when there's nothing to try again; 409 site_unavailable when the site can't have it now (blockedReason). Up to 20 changes a minute on the account (429 rate_limited). Setting Media Offload up for a site and taking it away (turning it on or off, a setup tried again or cancelled, a restore that turns it off after, cloning a site that has it) is limited to 200 a day per account (429 rate_limited; a day ends at 00:00 UTC).
Scopes and card charges. Set up, it's billed by use after each month, as turning it on is: it needs billing:write as well as sites:write (403 insufficient_scope without it; billing:write is for tokens for all servers only, so a token limited to some servers is refused with 403 all_servers_required), and the account's agreement to card charges, given once in the panel's Billing (403 charges_not_authorized, and nothing changes).
Scopes
The token needs these scopes. Without them, the request is refused with insufficient_scope (see Scopes).
-
sites:write - Manage sites. Domains, SSL, CDN, cache, firewall, malware protection, resources, backups, staging, Media Offload, SMTP and RabbitPress Cache. Choosing Rabbitflare Backup for a site's backups, and turning on Media Offload or a site's malware protection, also need Turn on paid features: they start monthly charges.
-
billing:write - Turn on paid features. Turn on site features that are billed to this account each month: Rabbitflare Backup for a site's backups, Media Offload, and a site's malware protection. Needs a token for all servers.
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. |
Example request
curl -X POST "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/media-offload/actions/retry-setup" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/media-offload/actions/retry-setup", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
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.mediaOffload.retrySetup({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/media-offload/actions/retry-setup');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$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/media-offload/actions/retry-setup",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
202 Accepted Returns the SiteMediaOffload object in data.
The SiteMediaOffload object's fields 102 fields
| Field | Type and description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
status | string
Known values: | ||||||||
blockedReason | string or null Why the site can't have Media Offload right now: a server of your own or a trial server, a staging copy, a site still installing, a stopped server, and the like. Null when it can. | ||||||||
settings | object The site's Media Offload settings. | ||||||||
mode | string
Known values: | ||||||||
freeAfterDays | integer In free up disk mode, how many days new files stay on the server before their copy there is removed (image plugins finish their work first): 1, 3, 7, 14, 30, 90. | ||||||||
kinds | array of strings The kinds of files kept in storage. Known values: | ||||||||
keep | array of strings Folders of the uploads folder kept on the server, besides the ones always kept there (private downloads and form uploads, backups and logs, files plugins rebuild, code). | ||||||||
settingsStatus | string Whether the settings are in place on the site's server: Known values: | ||||||||
lastError | string or null Why setting it up, applying the settings or turning it off didn't finish. Null when nothing failed. | ||||||||
pausedReason | string or null Why new files aren't copied to storage right now (an unpaid Media Offload bill). Everything already in storage keeps being served. Null otherwise. | ||||||||
enabledAt | string or null An ISO 8601 time, in UTC When it was turned on. Null while it's off. | ||||||||
stored | object or null What storage holds for the site, as its server last reported. Null while it's off, or before the server first reported. | ||||||||
files | integer Files in storage. | ||||||||
bytes | integer Their size, in bytes (decimal: 1 GB is 1,000,000,000 bytes). | ||||||||
freedFiles | integer Of those, files removed from the server to free up disk: storage holds the only copy. | ||||||||
freedBytes | integer Their size, in bytes. | ||||||||
kinds | array of objects What storage holds, by kind of file. Empty while it's off. | ||||||||
kind | string A kind of file: Known values: | ||||||||
files | integer Files of this kind in storage. | ||||||||
bytes | integer Their size, in bytes. | ||||||||
freedFiles | integer Of those, files removed from the server to free up disk. | ||||||||
freedBytes | integer Their size, in bytes. | ||||||||
pending | object or null Files waiting to be copied to storage. Null while it's off, or before the server first reported. | ||||||||
files | integer Files. | ||||||||
bytes | integer Their size, in bytes. | ||||||||
keptOnServer | array of objects Files of the uploads folder that stay on the server, by reason. | ||||||||
reason | string Why they stay: Known values: | ||||||||
files | integer Files. | ||||||||
bytes | integer Their size, in bytes. | ||||||||
delivery | object or null Whether the site serves files from storage: checked every 10 minutes, and files stay on the server until it passes. Null while it's off, or before the first check. | ||||||||
ok | boolean Whether the last check passed: a test file was fetched from storage through the site. | ||||||||
checkedAt | string or null An ISO 8601 time, in UTC When it was last checked. Null before the first check. | ||||||||
error | string or null Why the last check didn't pass. Null when it passed. | ||||||||
lastSyncAt | string or null An ISO 8601 time, in UTC When files were last copied to storage. Null before the first copy. | ||||||||
lastVerify | object or null The last check of every file in storage (a | ||||||||
verifiedAt | string An ISO 8601 time, in UTC When every file was last checked. | ||||||||
repaired | integer Files repaired in storage. | ||||||||
lost | integer Files missing from storage that the server no longer has either. | ||||||||
fetchedFromStorage | object or null What visitors fetched from storage this month: files that weren't on the server. Null while it's off. | ||||||||
month | string The month, like | ||||||||
bytes | integer Bytes fetched. | ||||||||
requests | integer Files fetched. | ||||||||
popularFiles | integer Files visitors fetch often, brought back to the server for 30 days so they're delivered faster. | ||||||||
freeingPaused | boolean This month visitors fetched more than twice what the site stores, so no more files are removed from the server for now (free up disk). Nothing else changes. | ||||||||
failedFiles | array of objects Up to 10 files that couldn't be copied to storage or checked there. They're tried again by themselves and stay on the server meanwhile. | ||||||||
path | string The file, in the uploads folder. | ||||||||
failedAt | string An ISO 8601 time, in UTC When it last failed. | ||||||||
conflictingPlugins | array of strings Other media offload plugins active on the site. Media Offload pauses while one is: deactivate it in WordPress. | ||||||||
run | object or null The operation running now, or one that finished in the last minute. Null otherwise. | ||||||||
id | string The run's id. | ||||||||
operation | string What it does: Known values: | ||||||||
status | string
Known values: | ||||||||
stage | string or null What it's doing now, in a few words, like | ||||||||
filesDone | integer Files done so far. | ||||||||
filesTotal | integer Files it has to do (0 until it has counted them). | ||||||||
filesFailed | integer Files that couldn't be done: they're tried again later, and stay on the server meanwhile. | ||||||||
bytesDone | integer Bytes done so far. | ||||||||
bytesTotal | integer Bytes it has to do (0 until it has counted them). | ||||||||
bytesPerSecond | number or null How fast it's going, in bytes a second. Null when it isn't running. | ||||||||
filesPerSecond | number or null How fast it's going, in files a second. Null when it isn't running. | ||||||||
etaSeconds | integer or null About how many seconds are left. Null when it isn't known. | ||||||||
error | string or null Why it didn't finish (with | ||||||||
turnOffAfter | boolean A | ||||||||
startedAt | string or null An ISO 8601 time, in UTC When it started. Null while it's queued. | ||||||||
finishedAt | string or null An ISO 8601 time, in UTC When it finished. Null until then. | ||||||||
createdAt | string An ISO 8601 time, in UTC When it was asked for. | ||||||||
recentRuns | array of objects Up to 5 earlier operations, newest first. | ||||||||
id | string The run's id. | ||||||||
operation | string What it does: Known values: | ||||||||
status | string
Known values: | ||||||||
stage | string or null What it's doing now, in a few words, like | ||||||||
filesDone | integer Files done so far. | ||||||||
filesTotal | integer Files it has to do (0 until it has counted them). | ||||||||
filesFailed | integer Files that couldn't be done: they're tried again later, and stay on the server meanwhile. | ||||||||
bytesDone | integer Bytes done so far. | ||||||||
bytesTotal | integer Bytes it has to do (0 until it has counted them). | ||||||||
bytesPerSecond | number or null How fast it's going, in bytes a second. Null when it isn't running. | ||||||||
filesPerSecond | number or null How fast it's going, in files a second. Null when it isn't running. | ||||||||
etaSeconds | integer or null About how many seconds are left. Null when it isn't known. | ||||||||
error | string or null Why it didn't finish (with | ||||||||
turnOffAfter | boolean A | ||||||||
startedAt | string or null An ISO 8601 time, in UTC When it started. Null while it's queued. | ||||||||
finishedAt | string or null An ISO 8601 time, in UTC When it finished. Null until then. | ||||||||
createdAt | string An ISO 8601 time, in UTC When it was asked for. | ||||||||
export | object or null The download of the whole media library (an | ||||||||
runId | string The | ||||||||
status | string
Known values: | ||||||||
files | integer or null Files in it. Null until it's ready. | ||||||||
bytes | integer or null Its size, in bytes. Null until it's ready. | ||||||||
expiresAt | string or null An ISO 8601 time, in UTC When the download is removed. Null until it's ready. | ||||||||
createdAt | string An ISO 8601 time, in UTC When it was asked for. | ||||||||
allowance | object or null The storage included with the site's server, shared by its sites, and what uses it. Storage beyond it is billed by use after each month ends. Null on servers of your own. | ||||||||
includedBytes | integer Storage included with the server, shared by its sites (decimal: 1 GB is 1,000,000,000 bytes). | ||||||||
usedBytes | integer Storage the server's sites use now. | ||||||||
sites | array of objects The sites using it, largest first. Show its 3 fields
| ||||||||
extraCentsPerGbMonth | number The price of each GB stored beyond what's included, per month, in US cents (it can have decimals). Billed after the month ends. | ||||||||
monthToDateCents | integer or null Extra storage this month so far, before it's billed, in US cents. Null for a token without | ||||||||
currency | string Always Always | ||||||||
reportedAt | string or null An ISO 8601 time, in UTC When the site's server last reported its figures. Null before it first did. |
Example response
{
"data": {
"status": "setting_up",
"blockedReason": null,
"settings": {
"mode": "copy",
"freeAfterDays": 7,
"kinds": [
"image",
"video",
"audio",
"document",
"archive",
"font"
],
"keep": []
},
"settingsStatus": "applied",
"lastError": null,
"pausedReason": null,
"enabledAt": null,
"stored": null,
"kinds": [],
"pending": null,
"keptOnServer": [],
"delivery": null,
"lastSyncAt": null,
"lastVerify": null,
"fetchedFromStorage": null,
"popularFiles": 0,
"freeingPaused": false,
"failedFiles": [],
"conflictingPlugins": [],
"run": null,
"recentRuns": [],
"export": null,
"allowance": {
"includedBytes": 100000000000,
"usedBytes": 0,
"sites": [],
"extraCentsPerGbMonth": 2.085,
"monthToDateCents": 0,
"currency": "usd"
},
"reportedAt": null
}
} 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 feature_ | This product isn't open to the account. Contact support if you'd like it opened. |
403 charges_ | The account hasn't agreed to card charges yet. In the panel, open Billing and accept the terms once. Then try again. |
403 all_ | The token is limited to some servers, and this operation needs a token for all servers: it changes domains or Cloudflare, or reaches Mail or billing, none of which is tied to one server. Use a token for all servers: make one in the panel with All servers. |
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 not_ | Setting up Media Offload didn't fail, so there's nothing to try again or cancel. Read the site's Media Offload ( |
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 is being restored, and nothing else can change it or its sites until that's done. Wait until the restore finishes (the server's |
429 rate_ | Too many requests. Wait for Retry-After seconds, then go on more slowly. |