Authentication
API tokens: how to make one, send it, limit it and replace it.
5 min read Updated
Every request is made with an API token: a secret that stands for your account, with only the access you give it. You make tokens in the control panel and send one with each request. A token works until it expires or you revoke it.
Send the token
Put it in the Authorization header of every request, as a bearer token:
Authorization: Bearer $RABBITFLARE_TOKEN
Only this header works: not a query parameter, not a cookie, not Basic authentication. A request without it answers 401 missing_token. Only two calls need no token: the API's index and the OpenAPI document.
Make a token
-
Open the API page
-
Fill in the form
-
Confirm with your code
Enter the 6-digit code from your authenticator app, and choose Generate token.
-
Copy it
We email you whenever a token is made. An account can make 10 tokens an hour. To use it, keep it in an environment variable such
as RABBITFLARE_TOKEN, as the samples do.
Who can make tokens
The account's owner, once the account's email address is confirmed, two-factor authentication is on and the first payment is made. The API page in the panel says which of these is missing. Team members can't make tokens, even with every permission: tokens belong to the account.
Why it asks for a code
A token can do what you can do, so making one, giving one more access and regenerating one ask for a code from your authenticator app. Someone who learns your password can't make a token without your phone. Taking access away needs no code.
What a token carries
- Access
- Its scopes: what it may do. Full access, Read only, or Custom to choose them one by one (see Scopes). A request needs every scope its operation lists.
- Servers
- All servers, including new ones; or only the servers you choose (up to 500). Then the token sees and changes only those servers and the sites on them, everywhere, lists included.
- Network
-
Where it may be used from: any address, or up to 20 IPv4 or IPv6 addresses or ranges (like
203.0.113.0/24). A request from anywhere else answers403ip_not_allowed. - Expiry
- 30 days, 60 days, 90 days or a year (90 days unless you choose), a date of your choice up to
2 years ahead, or never. A token used after it expired answers
401token_expired.
Changes to a token's access apply within a minute, and its value stays the same.
Expiry and reminders
We email you before a token expires, so there's time to regenerate it. Its expiry can't be changed on its own: regenerating it sets a new one. An expired token can't be regenerated; make a new one.
Regenerate a token
Regenerating gives a token a new value, with the same name and access and a new expiry. In the panel, open the token's menu and choose Regenerate. Choose when the old value stops working: at once, or in 1 hour or 24 hours, so you can roll the new value out to your apps before the old one stops.
Revoke a token
In the panel, open the token's menu and choose Revoke: apps using it stop working at once, and it can't be undone. From code,
DELETE /v1/token revokes the token the request is made with, for a token whose job is done (a one-off script's
last step). The webhook endpoints it added are turned off with it:
curl -X DELETE "https://api.rabbitflare.com/v1/token" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/token", {
method: "DELETE",
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
if (!res.ok) throw new Error(`Rabbitflare API error ${res.status}: ${await res.text()}`); import { Rabbitflare } from "@rabbitflare/api";
const rf = new Rabbitflare({ token: process.env.RABBITFLARE_TOKEN });
await rf.token.revoke(); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/token');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$body = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
if ($body === false || $status >= 400) {
throw new RuntimeException("Rabbitflare API error $status: $body");
} import os
import requests
response = requests.delete(
"https://api.rabbitflare.com/v1/token",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status() A revoked token answers 401 token_revoked, and so does an old value whose grace time has passed.
In the panel, Revoke lists the webhook endpoints the token added that are still on, and turns them off with it (Also turn off these
endpoints, ticked unless you untick it). Those you leave on keep being sent only what the token could read; DELETE /v1/token
always turns them off.
See what a token can do
GET /v1/token answers with the token in use: its name, scopes, servers, allowed addresses, expiry, when it was last
used and its rate limits. It needs no scope, so any working token can check itself:
curl "https://api.rabbitflare.com/v1/token" \
-H "Authorization: Bearer $RABBITFLARE_TOKEN" const res = await fetch("https://api.rabbitflare.com/v1/token", {
headers: {
Authorization: `Bearer ${process.env.RABBITFLARE_TOKEN}`,
},
});
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.token.get();
console.log(data); <?php
$ch = curl_init('https://api.rabbitflare.com/v1/token');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('RABBITFLARE_TOKEN'),
],
]);
$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.get(
"https://api.rabbitflare.com/v1/token",
headers={
"Authorization": "Bearer " + os.environ["RABBITFLARE_TOKEN"],
},
timeout=120,
)
response.raise_for_status()
print(response.json()["data"]) {
"data": {
"id": "0b9f2c1e-5d0b-4b53-9a7e-2f1a3a6d7b11",
"name": "deploy-bot",
"tokenStart": "rfp_3kTq",
"tokenLast4": "a1B2",
"scopes": [
"servers:read",
"sites:read",
"sites:write"
],
"allServers": true,
"serverIds": [],
"ipAllowlist": [
"203.0.113.0/24"
],
"expiresAt": "2027-02-16T08:46:49.000Z",
"createdAt": "2026-11-18T08:46:49.000Z",
"lastUsedAt": "2026-11-18T09:12:03.000Z",
"rateLimits": {
"readPerMinute": 120,
"writePerMinute": 30,
"heavyPerMinute": 20,
"perHour": 3000,
"concurrent": 4
}
}
} 401 and 403 answers
A 401 means the request couldn't be tied to a working token: it also carries a WWW-Authenticate header. A 403 means
the token works but may not do this (every error).
| Code | Status | What it means | What to do |
|---|---|---|---|
missing_token | 401 | No API token was sent. | Send the header Authorization: Bearer <token>. |
invalid_token | 401 | The token is malformed or unknown. | Check you copied the whole token. Make a new one in the panel if it's lost. |
token_expired | 401 | The token passed its expiry date (expiredAt). | Make a new token in the panel: an expired token can't be regenerated. |
token_revoked | 401 | The token was revoked, or replaced by a regenerated one whose grace time has passed. | Use the token's new value, or make a new token. |
insufficient_scope | 403 | The token lacks a scope this operation needs (missingScopes). | Edit the token in the panel and add the scopes in missingScopes. |
ip_not_allowed | 403 | The request came from an address that isn't on the token's list of allowed IP addresses. | Call from an allowed address, or change the token's list in the panel. |
api_not_enabled | 403 | The API isn't open to this account. | Contact support. |
api_access_suspended | 403 | Support paused this account's API access. | Contact support. |
two_factor_required | 403 | Two-factor authentication became required for this account and is off. | Sign in to the panel and turn on two-factor authentication. |
feature_unavailable | 403 | This product isn't open to the account. | Contact support if you'd like it opened. |
all_servers_required | 403 | The token is limited to some servers, and this operation needs a token for all servers: it changes domains or Cloudflare, or reaches Mail or billing, none of which is tied to one server. | Use a token for all servers: make one in the panel with All servers. |
The token's format
A token is rfp_ followed by 46 letters and digits, the last six of them a checksum (a CRC32 of the rest): a mistyped token
is refused before any lookup. To find tokens in your code, logs or repositories (a secret scanner's rule), match this pattern:
rfp_[A-Za-z0-9]{46}
The panel shows the start and end of each token (tokenStart and tokenLast4 in GET /v1/token), so you
can tell which one an app uses.
Still have a question?
Our team answers support tickets about the API, and other developers answer in the community.