Turn a site's Cloudflare protection on or off
/v1/sites/{siteId}/protection Turns Cloudflare protection on (on: true) or off (on: false). Turning it on needs a live site with its SSL certificate, its server running, and a domain of your own as its primary domain (409 needs_domain); not for staging copies.
What happens next. The answer is 202 with status: "applying". Turning on: the site's domains are added to Cloudflare, which checks each one and makes its certificate while the site keeps answering as before; each domain then goes through Cloudflare once its DNS points at edge (see domains). An hour after a domain starts coming through Cloudflare, the server refuses visitors who skip Cloudflare on it. Turning off takes up to 15 minutes; domains still pointed at edge keep working (stillPointed). If it fails, status is failed with the reason in error: send the same again to retry. Asking for what's already in place answers 200 as it is.
Up to 30 changes a minute per account.
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 |
|---|---|
on Required | boolean
|
Example request
curl -X PUT "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/protection" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"on": true
}' const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/protection", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"on": true
}),
});
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.protection.update({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
on: true,
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/protection');
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([
'on' => true,
]),
]);
$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/protection",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"on": True,
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
202 Accepted Returns the SiteProtection object in data. It can also answer 200 OK.
The SiteProtection object's fields 22 fields
| Field | Type and description | ||||||||
|---|---|---|---|---|---|---|---|---|---|
on | boolean Whether Cloudflare protection is switched on for the site. | ||||||||
status | string
Known values: | ||||||||
error | string or null Why turning it on or off failed (with | ||||||||
edge | string or null The site's own name at Cloudflare, like shop-x7k2p.rabbitflare.net: each domain goes through Cloudflare once its DNS points here. Null when the site can't be protected (contact support). | ||||||||
needs | string or null What the site needs before protection can go on (a domain of your own as its primary domain). Null when nothing, and while it's on. | ||||||||
domains | array of objects The site's own domains, while protection is on (its built-in address isn't listed). Empty while it's off. | ||||||||
domainId | string The domain's id, as the site's list of domains gives it. | ||||||||
hostname | string The domain, like www.example.com. | ||||||||
status | string
Known values: | ||||||||
detail | string or null What's happening with it, or why it waits or was refused, in a sentence. Null when it's protected. | ||||||||
record | object or null The DNS record that sends the domain through Cloudflare. At Cloudflare, set it to DNS only (grey cloud), and remove other A, AAAA or CNAME records of the same name (keep MX and TXT records: they're for email). Null for a root domain whose DNS company can't point it at a name. Show its 3 fields
| ||||||||
dnsBy | string Who changes its DNS: Known values: | ||||||||
dnsCompany | object or null The DNS company its nameservers belong to. Null when not known yet or not recognised, and for domains bought from Rabbitflare. Show its 3 fields
| ||||||||
locked | boolean Whether the site's server already refuses visitors who skip Cloudflare on its protected domains (an hour after a domain starts coming through Cloudflare). | ||||||||
stillPointed | array of strings While it's off: domains whose DNS still points at the site's name at Cloudflare. They keep working (that name now leads straight to the server); point them back at the server when you like. | ||||||||
connectFor | array of strings While it's on: domains whose DNS is in a Cloudflare account that isn't connected to Rabbitflare. Connect that account in the panel and Rabbitflare switches them for you; otherwise set their |
Example response
{
"data": {
"on": true,
"status": "applying",
"error": null,
"edge": "shop-x7k2p.rabbitflare.net",
"needs": null,
"domains": [
{
"domainId": "c4d5e6f7-a8b9-4c0d-9e1f-2a3b4c5d6e7f",
"hostname": "shop.example.com",
"status": "preparing",
"detail": "Cloudflare is checking it and making its certificate (a few minutes). Nothing to change yet.",
"record": {
"type": "CNAME",
"name": "shop.example.com",
"value": "shop-x7k2p.rabbitflare.net"
},
"dnsBy": "you",
"dnsCompany": {
"id": "godaddy",
"name": "GoDaddy",
"root": "none"
}
}
],
"locked": false,
"stillPointed": [],
"connectFor": []
}
} 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 not_ | Something this needs isn't ready yet (for example, the server has no IP address yet). Wait a few minutes, then try again. |
409 staging_ | This site is a staging copy, which can't do this. Do it on the live site. A staging copy is managed through its live site's staging operations. |
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 |
422 validation_ | One or more fields are missing or wrong. Correct the fields named in |
Rate limit
Write requests: 30 a minute per token, 60 per account. More in Rate limits.
Added on .
Deprecated since November 28, 2026; it stops working on November 30, 2027. Cloudflare protection was removed from Rabbitflare on 28 November 2026: this operation answers `403 feature_unavailable` for every site, and goes in v2.