Revoke the token in use
/v1/token Revokes the token making the request. It stops working at once: every later call with it answers 401 token_revoked. This can't be undone; make a new token in the panel if you need one again.
The webhook endpoints it added are turned off with it (they can be turned on again in the panel).
Use it when a token may have leaked, or when the script that used it is retired. Any valid token can revoke itself: it needs no scope.
Scopes
Any valid token can make this request.
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 |
Example request
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() Response
204 No Content The answer has no body.
Example response
No content: the answer has no body.
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 |
|---|---|
400 invalid_ | A query parameter is unknown or has a wrong value ( Correct or remove the parameter named in |
400 invalid_ | The body isn't valid JSON, or isn't a JSON object where one is expected. Send a JSON object. |
400 invalid_ | The Idempotency-Key is empty, too long, or has characters other than A-Z a-z 0-9 _ - : . Use a UUID. |
401 missing_ | No API token was sent. Send the header Authorization: Bearer <token>. |
401 invalid_ | The token is malformed or unknown. Check you copied the whole token. Make a new one in the panel if it's lost. |
401 token_ | The token passed its expiry date ( Make a new token in the panel: an expired token can't be regenerated. |
401 token_ | 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. |
403 api_ | The API isn't open to this account. Contact support. |
403 api_ | Support paused this account's API access. Contact support. |
403 two_ | Two-factor authentication became required for this account and is off. Sign in to the panel and turn on two-factor authentication. |
403 ip_ | 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. |
409 idempotency_ | A request with this Idempotency-Key is still running. Wait a moment (Retry-After), then send the same request again. |
415 unsupported_ | The body isn't sent as application/json (or application/octet-stream for uploads). Send Content-Type: application/json with a JSON body. |
422 validation_ | One or more fields are missing or wrong. Correct the fields named in |
422 idempotency_ | The Idempotency-Key was already used in the last 24 hours with another operation or another body, or by another token of the account. Use a new key for a new request. |
429 rate_ | Too many requests. Wait for Retry-After seconds, then go on more slowly. |
429 concurrency_ | Too many requests of this token are in progress at once. Wait for a request to finish before sending the next. |
503 api_ | The API is switched off for everyone for a while. Try again later; Retry-After says when. |
503 api_ | Only reads are served for a while (for example during maintenance). Try the change again later; Retry-After says when. |