Allow or block an IP address on a site
/v1/sites/{siteId}/firewall/addresses Adds an IP address or range to the site's blocked addresses (kind: "block": refused on every page of the site, whatever the mode) or allowed addresses (kind: "allow": its requests skip the firewall's checks; only for addresses you trust, like your office). A range is stored from its first address (203.0.113.7/24 is 203.0.113.0/24).
The answer is 201 with the firewall. Location is the new rule's path, /v1/sites/{siteId}/firewall/rules/{ruleId}: its id is the rule's id in rules, and DELETE there removes it. The answer is the firewall with status: "applying" (or installing while the firewall is first set up on the server, a few minutes): the change reaches the server within seconds, then status is active. If it fails, status is failed: apply it again with POST /sites/{siteId}/firewall/actions/apply. Up to 60 changes a minute per account.
Limits. Up to 500 blocked and 100 allowed addresses per site. An address can be on the lists once (409 conflict), and the server's own addresses can't be blocked (409 own_address): WordPress needs to reach itself for its health checks and the theme editor.
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 |
|---|---|
kind Required | string
One of: |
address Required | string Up to 64 characters An IPv4 or IPv6 address, or a range like 203.0.113.0/24 (at most /8 for IPv4, /16 for IPv6). The server's own addresses can't be blocked. |
note | string Up to 80 characters A note for yourself, up to 80 characters. |
Example request
curl -X POST "https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/firewall/addresses" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"kind": "block",
"address": "198.51.100.0/24",
"note": "Login attempts from a scanner"
}' const res = await fetch("https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/firewall/addresses", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"kind": "block",
"address": "198.51.100.0/24",
"note": "Login attempts from a scanner"
}),
});
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.firewall.addresses.add({
siteId: "8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d",
kind: "block",
address: "198.51.100.0/24",
note: "Login attempts from a scanner",
});
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/sites/8a1b2c3d-4e5f-4a6b-8c7d-9e0f1a2b3c4d/firewall/addresses');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'kind' => 'block',
'address' => '198.51.100.0/24',
'note' => 'Login attempts from a scanner',
]),
]);
$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/firewall/addresses",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
json={
"kind": "block",
"address": "198.51.100.0/24",
"note": "Login attempts from a scanner",
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) Response
201 Created Returns the SiteFirewall object in data.
The SiteFirewall object's fields 14 fields
| Field | Type and description |
|---|---|
mode | string
Known values: |
sensitivity | string
Known values: |
loginProtection | boolean Whether repeated sign-ins from one address are slowed down (after a few quick tries, one every 6 seconds), so password-guessing bots can't hammer wp-login.php. It works while the firewall is on. |
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 |
updatedAt | string or null An ISO 8601 time, in UTC When the settings or rules last changed. Null when they never did. |
rules | array of objects The site's allowed addresses (up to 100), blocked addresses (up to 500) and exceptions (up to 30), oldest first. |
id | string The rule's id. |
kind | string
Known values: |
address | string or null The IP address or range, like 203.0.113.7 or 203.0.113.0/24, written as the firewall uses it (a range from its first address). Null for an exception. |
ruleIds | array of integers The firewall rules an exception turns off, by number (as an event's |
path | string or null Where an exception applies: this page and the pages under it ( |
note | string or null The note given when it was added. Null when none was. |
createdAt | string An ISO 8601 time, in UTC When the rule was added. |
Example response
{
"data": {
"mode": "protect",
"sensitivity": "standard",
"loginProtection": true,
"status": "applying",
"lastError": null,
"updatedAt": "2026-11-18T10:15:02.000Z",
"rules": [
{
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "block",
"address": "198.51.100.0/24",
"ruleIds": [],
"path": null,
"note": "Login attempts from a scanner",
"createdAt": "2026-11-18T09:20:03.000Z"
},
{
"id": "f2a3b4c5-d6e7-4f8a-9b0c-1d2e3f4a5b6c",
"kind": "exception",
"address": null,
"ruleIds": [
942270,
942360
],
"path": "/wp-admin/admin-ajax.php",
"note": "Page builder saves",
"createdAt": "2026-11-18T09:31:17.000Z"
}
]
}
} 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 · 409 limit_ | A limit is reached: Delete something first, or contact support to raise the limit. |
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 conflict | This clashes with something that exists, or is already done (for example, a domain already connected to a site). Read |
409 own_ | That address is one of your own, which can't be used here: a site's firewall can't block its server's own IP address (WordPress needs to reach itself), and the account's own email addresses can't be changed. Leave that address as it is. For the firewall, use an address or range that leaves out the server's own; the account's own email addresses need nothing done. |
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 |
422 invalid_ | The IP address or range isn't valid. Use an address like 203.0.113.7, or a range like 203.0.113.0/24. |