Skip to content

Set a site's resources

PUT /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

FieldType and description
Idempotency-Key

string 1 to 255 characters

A key of your own for this request, like a UUID: letters, digits and _ - : . Send the request again with the same key (after a timeout, say) and it's done only once. Keys are kept for 24 hours (see Idempotency).

Path parameters

FieldType and description
siteId Required

string

The site's id.

Request body

JSON, with these fields. Fields that aren't listed are refused.

FieldType 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: low, normal (the default) or high.

One of: lownormalhigh

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
}'

Response

202 Accepted Returns the SiteResources object in data.

The SiteResources object's fields 28 fields
FieldType and description
status

string

Whether the settings are in place on the site's server: applied, applying (on their way, usually within a minute) or failed (see lastError: the site keeps its previous settings).

Known values: appliedapplyingfailed More can appear.

lastError

string or null

Why the settings couldn't be put in place (with status: "failed"). Null otherwise.

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 normal, gives the site a PHP of its own; the PHP settings apply either way.

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: low, normal (the default) or high.

Known values: lownormalhigh More can appear.

workers

integer or null

How many PHP workers the site may run (requests served at once). Null: set by the server's memory (server.autoWorkers).

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 workers is null.

applied

object or null

How the site runs on its server, as the server last reported. Null before it first did.

mode

string

isolated: the site runs a PHP of its own, within its limits. shared: it runs on the server's shared PHP.

Known values: sharedisolated More can appear.

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: low, normal or high.

Known values: lownormalhigh More can appear.

Example response

202 Accepted
{
  "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 codeWhen, and what to do
403 feature_unavailable

This product isn't open to the account.

Contact support if you'd like it opened.

404 not_found

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_unavailable

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_busy

A staging operation is running on this site, or on a site of this server.

Wait until it finishes (activeRun in GET /sites/{siteId}/staging is null again), or cancel it, then try again.

409 server_restoring

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 pendingAction is null again), then try again. A restore that stopped partway keeps pendingAction: "restore", with the server's lastError set, until our team has checked the server.

422 validation_failed

One or more fields are missing or wrong. fields names each one with what's wrong.

Correct the fields named in fields. Unknown fields are refused too.

429 rate_limited

Too many requests. scope says which limit: token, account, create, operation or network.

Wait for Retry-After seconds, then go on more slowly.

Rate limit

Write requests: 30 a minute per token, 60 per account. More in Rate limits.

Added on .

Popular

API docs