Rate limits
How many requests a token and an account can make, and how to slow down.
3 min read Updated
Limits keep the API quick for everyone. They're generous for real work, and a script that reaches one only has to wait a little and go on. Every answer says how much is left.
The limits
Each request counts in its kind and in every request of the hour, for its token and for its account. An account's limits are twice a token's, shared by all its tokens, so two busy tokens can't use more than that between them.
| Limit | Counts | Per token | Per account |
|---|---|---|---|
| Reads | GET and HEAD, other than heavy ones | 120 a minute | 240 a minute |
| Changes | POST, PUT, PATCH and DELETE, other than heavy ones | 30 a minute | 60 a minute |
| Heavy requests | Those marked Heavy (below) | 20 a minute | 40 a minute |
| Every request | All of the above together | 3,000 an hour | 6,000 an hour |
| Requests at once | Sent and not yet answered | 4 | 8 |
| New servers | Created through the API | Per account only | 10 an hour |
| New sites | Created through the API | Per account only | 60 an hour |
These are the defaults. GET /v1/token shows your token's own in rateLimits. Only servers and sites that
were made count against the hourly limits on new ones: a request that failed costs nothing.
Heavy requests
Some requests reach one of your servers while you wait: graphs, logs, tools, checks. They count against the heavy limit instead of the reads or changes, and are marked Heavy in the reference:
| Operation | Request |
|---|---|
| Get what's in stock on a cloud | GET / |
| Restart PHP on a server | POST / |
| Check PHP security updates now | POST / |
| Get a server's graphs | GET / |
| List a server's snapshots and backups | GET / |
| Get a server's logs and clean-up settings | GET / |
| Clear a server's logs | POST / |
| Purge a site's cache | POST / |
| Reset the WordPress administrator's password | POST / |
| Check a domain's DNS now | POST / |
| Check a custom CDN hostname's DNS now | POST / |
| List the requests a site's firewall stopped | GET / |
| List requests Cloudflare stopped on a site | GET / |
| Get a server's security | GET / |
| Turn on a server's security | POST / |
| Turn off a server's security | POST / |
| Change a server's security settings | PATCH / |
| List a server's allowed and blocked addresses | GET / |
| Allow, block or challenge an address on a server | POST / |
| Take an address off a server's list | POST / |
| Move an address to another of a server's lists | POST / |
| Add a port to a server's port list | POST / |
| Take a port off a server's port list | DELETE / |
| Get the attacks stopped on a server | GET / |
| Scan a server's sites for malware | POST / |
| Turn off a security rule for false alarms | POST / |
| Turn a security rule back on | POST / |
| Install KernelCare on a server | POST / |
| Remove KernelCare from a server | POST / |
| Check a server's domains against blacklists | POST / |
| Turn on Imunify360's WordPress plugin | POST / |
| Turn off Imunify360's WordPress plugin | POST / |
| Let a search engine through a server's bot checks | POST / |
| Stop letting a search engine through | DELETE / |
| Get a site's malware protection | GET / |
| Turn on a site's malware protection | POST / |
| Turn off a site's malware protection | POST / |
| Change a site's malware protection emails | PATCH / |
| List a site's malware threats | GET / |
| Clean a site's malware threats | POST / |
| Undo a clean-up of a site's threats | POST / |
| Mark a site's threats as not malware | POST / |
| Have malware scans skip a path on a site | POST / |
| Stop malware scans skipping a path | DELETE / |
| Scan a site for malware | POST / |
| Change Imunify360's WordPress plugin in a site | PATCH / |
| Get what a site uses of its server now | GET / |
| Add a cron job to a site | POST / |
| Change a cron job | PUT / |
| Resume a paused cron job | POST / |
| Pause a cron job | POST / |
| Delete a cron job | DELETE / |
| Run a cron job now | POST / |
| List a cron job's runs | GET / |
| Get which of a site's cron jobs are running | GET / |
| List a folder of a site | GET / |
| Read a text file of a site | GET / |
| Write a text file of a site | PUT / |
| Make a folder in a site | POST / |
| Make an empty file in a site | POST / |
| Move or rename a file or folder | POST / |
| Copy a file or folder | POST / |
| Delete files and folders of a site | POST / |
| Change a file's or folder's permissions | POST / |
| Extract a .zip archive in a site | POST / |
| Make a .zip archive in a site | POST / |
| Upload a file to a site | PUT / |
| Download a file or folder of a site | GET / |
| Download a backup's files or database | GET / |
| Check backup storage | POST / |
| Check what a staging operation would do | GET / |
| Get what cloning a site needs | GET / |
| Check a server's room for a clone | GET / |
| Get RabbitPress Cache on a site | GET / |
| See what turning on Media Offload would move | POST / |
| Send a test event | POST / |
How much is left
Every answer to a request with a token carries three headers, about the limit closest to running out:
RateLimit-Limit: 120
RateLimit-Remaining: 87
RateLimit-Reset: 41 RateLimit-Limit- How many requests that limit allows.
RateLimit-Remaining- How many are left.
RateLimit-Reset- Seconds until it starts again.
Over a limit
A request over a limit isn't done, and answers 429 rate_limited
with a Retry-After header: the seconds to wait. The error says which limit it was in scope:
{
"error": {
"type": "rate_limit_error",
"code": "rate_limited",
"message": "Too many requests. Try again in 41 seconds.",
"scope": "token",
"limit": 120,
"retryAfterSeconds": 41,
"requestId": "req_8Zk2mPq4Xc7Lw9Tn0Bv3Ys",
"docUrl": "https://rabbitflare.com/docs/api/errors#rate_limited"
}
} scope | The limit reached |
|---|---|
token | This token's limit for the kind of request, or its hourly limit. |
account | The account's limit, shared by all its tokens. |
create | The account's limit on new servers or new sites in an hour. |
operation | A feature's own limit, the same as in the panel. |
network | Requests without a working token, from one network. |
Back off
Wait as long as Retry-After says, then send the request again; don't send it again at once in a loop. Better still, slow down before the
limit: when RateLimit-Remaining reaches 0, wait RateLimit-Reset seconds.
// Send a request; on 429, wait as long as Retry-After says, then send it again.
async function withBackOff(send, attempts = 5) {
for (let attempt = 1; ; attempt++) {
const res = await send();
if (res.status !== 429 || attempt === attempts) return res;
const seconds = Number(res.headers.get("Retry-After")) || 1;
await new Promise((resolve) => setTimeout(resolve, seconds * 1000));
}
}
const res = await withBackOff(() =>
fetch("https://api.rabbitflare.com/v1/servers", { headers: { Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}` } }),
);
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`);
const { data: servers } = await res.json();
console.log(`${servers.length} servers`);
// Slow down before the limit: when nothing is left, wait for the window to start again.
if (res.headers.get("RateLimit-Remaining") === "0") {
const reset = Number(res.headers.get("RateLimit-Reset"));
await new Promise((resolve) => setTimeout(resolve, reset * 1000));
} // The SDK backs off by itself: on 429 it waits as long as Retry-After says, then sends the request
// again (here up to 4 times).
import { setTimeout as sleep } from "node:timers/promises";
import { Rabbitflare } from "@rabbitflare/api";
// Slow down before the limit: when nothing is left, wait for the window to start again.
// The SDK sends its requests with this fetch, which waits before it gives such an answer back. The wait
// is part of the attempt: the attempt's signal (its time limit, or your signal) stops it.
async function slowDown(url, init) {
const res = await fetch(url, init);
if (res.ok && res.headers.get("RateLimit-Remaining") === "0") {
const reset = Number(res.headers.get("RateLimit-Reset"));
await sleep(reset * 1000, undefined, { signal: init.signal });
}
return res;
}
const rf = new Rabbitflare({
token: process.env.RABBITFLARE_TOKEN,
maxRetries: 4,
fetch: slowDown,
});
const { data: servers } = await rf.servers.list();
console.log(`${servers.length} servers`); <?php
// Send a request; on 429, wait as long as Retry-After says, then send it again.
function withBackOff(string $url, int $attempts = 5): array
{
for ($attempt = 1; ; $attempt++) {
$headers = [];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN')],
CURLOPT_HEADERFUNCTION => function ($ch, $line) use (&$headers) {
$parts = explode(':', $line, 2);
if (count($parts) === 2) {
$headers[strtolower(trim($parts[0]))] = trim($parts[1]);
}
return strlen($line);
},
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($status !== 429 || $attempt === $attempts) {
return [$status, $headers, $body];
}
sleep((int) ($headers['retry-after'] ?? 1));
}
}
[$status, $headers, $body] = withBackOff('https://api.rabbitflare.com/v1/servers');
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
}
echo count(json_decode($body, true)['data']), ' servers', PHP_EOL;
// Slow down before the limit: when nothing is left, wait for the window to start again.
if (($headers['ratelimit-remaining'] ?? null) === '0') {
sleep((int) $headers['ratelimit-reset']);
} import os
import time
import requests
def with_back_off(send, attempts=5):
"""Send a request; on 429, wait as long as Retry-After says, then send it again."""
for attempt in range(1, attempts + 1):
response = send()
if response.status_code != 429 or attempt == attempts:
return response
time.sleep(float(response.headers.get("Retry-After") or 1))
response = with_back_off(
lambda: requests.get(
"https://api.rabbitflare.com/v1/servers",
headers={"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"]},
timeout=120,
)
)
response.raise_for_status()
print(len(response.json()["data"]), "servers")
# Slow down before the limit: when nothing is left, wait for the window to start again.
if response.headers.get("RateLimit-Remaining") == "0":
time.sleep(float(response.headers["RateLimit-Reset"])) Spread work out rather than sending it in bursts, and keep what rarely changes, like the catalogue of clouds and plans, instead of asking for it every time (the errors guide's helper backs off too).
Requests at once
A token can have 4 requests waiting for an answer at once, and an account 8. One more answers 429 concurrency_limited, with
Retry-After. To send many requests, run at most 4 at a time, for example with a small queue.
Other limits
-
Features have their own limits, the same as in the panel. Reaching one answers
429rate_limitedwithscopeoperation. -
The account's own limits, like how many servers it can have, apply as in the panel:
limit_reachedsays so. -
Some features share limits with every account: setting Media Offload up or taking it away (cloning a site that has it counts too), setting
up the CDN and adding a CDN hostname. When one is busy, the request answers
429rate_limitedwithscopeoperationand the seconds to wait, and it doesn't count against your token's limits. Each also has a cap per account per day, and backup downloads are limited to 50 GB a day per account. A day ends at 00:00 UTC. -
Without a working token, requests are counted per network: 60 a minute. After 20
answers of
401within 5 minutes, every request from that network answers429for 5 minutes. -
A token refused by the account's checks (an address outside its allowed IP addresses, the API not open to the account or paused on it,
two-factor authentication owed, changes while only reads are served) is limited all the same, as many refusals as its own limits allow, counted
apart from its own requests and its account's: once they're used up, it answers
429instead, while its requests from an allowed address go on.
Higher limits
If your app needs more, open a support ticket saying what it does and which limit it reaches. Limits can be raised for an account.
Still have a question?
Our team answers support tickets about the API, and other developers answer in the community.