Skip to content

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:

Header
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

  1. Open the API page

    In the control panel, open API in the sidebar and choose Generate new token.

    The API page in the control panel: the Tokens tab lists seven tokens, each with its access, servers, creation and expiry dates and last use, beside a Generate new token button.
    The API page: your tokens, what each may do, and when each was last used.
  2. Fill in the form

    Give it a name you'll recognise (up to 64 characters), say what it may do and where, and when it expires (below).

    The Generate new token page: the token's name, its expiry, its access (full, read only or custom, with each permission), its servers, the addresses it may be used from, and the authenticator code.
    Generate new token: a name, when it expires, what it may do, on which servers and from where.
  3. Confirm with your code

    Enter the 6-digit code from your authenticator app, and choose Generate token.

  4. Copy it

    The token is shown once. We keep only a fingerprint of it, so it can't be shown again: if it's lost, regenerate it.

    The new token shown once, with a Copy button, a warning that it won't be shown again, and a cURL command to try it.
    The new token, shown this once: copy it now. The cURL command beside it tries 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 answers 403 ip_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 401 token_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.

Old value
New value
Both values work during the grace time you chose (1 hour or 24 hours); after it, only the new one. A second regenerate within that time stops the older value at once.

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"

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"
200 OK
{
  "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).

CodeStatusWhat it meansWhat 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:

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.

Contact support

Popular

API docs