Set a site's resources
/v1/sites/{siteId}/resources Sets every one of the site's resource settings at once: a setting left out (or null) goes back to its default, so send {} to remove them all. A CPU, memory or process limit, or a priority other than normal, gives the site a PHP of its own, which holds it to them; the PHP settings apply either way.
What happens next. The answer is 202 with the settings and status: "applying": the site's server applies them shortly, then status is applied. If the server can't apply them, status is failed and the site keeps its previous settings.
Limits. The memory limit is at most the server's maxMemoryMb, and at least room for one request (phpMemoryMb + 128 MB); the process limit leaves room for the PHP workers and scheduled tasks. The site must be live, its server running, and not a staging copy (409 site_unavailable says why). Up to 30 changes a minute. If per-site resources are no longer open to your account, a site's settings can still be removed ({}); anything else answers 403 feature_unavailable.
Scopes
The token needs this scope. Without it, 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.
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 |
|---|---|
cpuPercent | integer or null 5 to 100 The share of the server's processor the site may use, in percent of all its cores. 5 to 100%; null or left out: no limit of its own. |
memoryMb | integer or null 256 to 1,048,576 The memory the site may use (its PHP and scheduled tasks), in MB. At most the server's memory less 256 MB. 256 to 1,048,576 MB; null or left out: no limit of its own. |
processes | integer or null 32 to 4,096 How many processes the site may run at once. 32 to 4,096; null or left out: no limit of its own. |
priority | string The site's share of the processor when the server is busy: One of: |
workers | integer or null 1 to 64 How many PHP workers the site may run (requests served at once). Left out: set by the server's memory. 1 to 64; null or left out: no limit of its own. |
phpMemoryMb | integer or null 64 to 1,024 PHP's memory limit per request, in MB. Left out: 256 MB. 64 to 1,024 MB; null or left out: no limit of its own. |
timeLimit | integer or null 30 to 300 How long one request may run, in seconds. Left out: 120 seconds. 30 to 300 seconds; null or left out: no limit of its own. |
uploadMb | integer or null 8 to 512 The largest upload, in MB. Left out: 64 MB. 8 to 512 MB; null or left out: no limit of its own. |
inputVars | integer or null 1000 to 20,000 The most form fields one request may send. Left out: 5,000. 1,000 to 20,000; null or left out: no limit of its own. |
Example request
curl -X PUT "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/resources" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"cpuPercent": 50,
"memoryMb": 1024,
"workers": 8,
"phpMemoryMb": 512,
"uploadMb": 128
}' const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/resources", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"cpuPercent": 50,
"memoryMb": 1024,
"workers": 8,
"phpMemoryMb": 512,
"uploadMb": 128
}),
});
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.resources.update({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
cpuPercent: 50,
memoryMb: 1024,
workers: 8,
phpMemoryMb: 512,
uploadMb: 128,
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/resources');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'cpuPercent' => 50,
'memoryMb' => 1024,
'workers' => 8,
'phpMemoryMb' => 512,
'uploadMb' => 128,
]),
]);
$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.put(
"https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/resources",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"cpuPercent": 50,
"memoryMb": 1024,
"workers": 8,
"phpMemoryMb": 512,
"uploadMb": 128,
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
202 Accepted Returns the SiteResources object in data.
The SiteResources object's fields 28 fields
| Field | Type and description |
|---|---|
status | string Whether the settings are in place on the site's server: Known values: |
lastError | string or null Why the settings couldn't be put in place (with |
blockedReason | string or null Why the site can't have settings of its own right now: a staging copy (set them on the live site), a site on its server's original one-site setup, a site still installing, or a stopped server. Null when it can. |
settings | object The site's settings. A CPU, memory or process limit, or a priority other than |
cpuPercent | integer or null The share of the server's processor the site may use, in percent of all its cores. Null: no limit of its own. |
memoryMb | integer or null The memory the site may use (its PHP and scheduled tasks), in MB. Null: no limit of its own. |
processes | integer or null How many processes the site may run at once. Null: no limit of its own. |
priority | string The site's share of the processor when the server is busy: Known values: |
workers | integer or null How many PHP workers the site may run (requests served at once). Null: set by the server's memory ( |
phpMemoryMb | integer or null PHP's memory limit per request, in MB. Null: the server's (256 MB). |
timeLimit | integer or null How long one request may run, in seconds. Null: the server's (120 seconds). |
uploadMb | integer or null The largest upload, in MB. Null: the server's (64 MB). |
inputVars | integer or null The most form fields one request may send. Null: the server's (5,000). |
server | object What the site's server has, and what follows from it. |
vcpus | integer The server's vCPUs. |
memoryMb | integer The server's memory, in MB. |
maxMemoryMb | integer The largest memory limit a site on this server can have, in MB: the server's memory less what the system, database and web server need. |
autoWorkers | integer The PHP workers a site gets on this server when |
applied | object or null How the site runs on its server, as the server last reported. Null before it first did. |
mode | string
Known values: |
workers | integer How many PHP workers the site may run. |
otherSites | array of objects The server's other sites with limits or a priority of their own, by name. |
siteId | string The site's id. |
name | string The site's name. |
cpuPercent | integer or null Its CPU limit, in percent. Null: none. |
memoryMb | integer or null Its memory limit, in MB. Null: none. |
processes | integer or null Its process limit. Null: none. |
priority | string Its CPU priority: Known values: |
Example response
{
"data": {
"status": "applying",
"lastError": null,
"blockedReason": null,
"settings": {
"cpuPercent": 50,
"memoryMb": 1024,
"processes": null,
"priority": "normal",
"workers": 8,
"phpMemoryMb": 512,
"timeLimit": null,
"uploadMb": 128,
"inputVars": null
},
"server": {
"vcpus": 2,
"memoryMb": 4096,
"maxMemoryMb": 3840,
"autoWorkers": 24
},
"applied": {
"mode": "isolated",
"workers": 8
},
"otherSites": [
{
"siteId": "9b2c3d4e-5f6a-4b7c-8d9e-0f1a2b3c4d5e",
"name": "Blog",
"cpuPercent": 25,
"memoryMb": null,
"processes": null,
"priority": "low"
}
]
}
} 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. |
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 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 |
422 validation_ | One or more fields are missing or wrong. Correct the fields named in |
429 rate_ | Too many requests. Wait for Retry-After seconds, then go on more slowly. |