Documentation menu
Docs › API
API authentication
Every API request is authenticated with a bearer token. Tokens are scoped, can be limited to specific sites and IP ranges, and can expire automatically.
Creating a token
Create tokens in the dashboard under Account → API tokens, or with the CLI. A token is shown once; store it in your secret manager.
cachebz tokens create \
--name "ci-deploy" \
--scopes config:write,purge:write \
--sites site_7Hq2xK \
--expires 90dUsing a token
Send the token in the Authorization header. All requests must use HTTPS; plain HTTP requests are rejected.
curl https://api.cache.bz/v1/sites \
-H "Authorization: Bearer $CACHEBZ_TOKEN"Scopes
| Scope | Allows |
|---|---|
sites:read | List sites and read their settings. |
config:write | Validate, deploy and roll back configuration. |
purge:write | Create purge requests. |
analytics:read | Read analytics and logs. |
certs:write | Upload and delete custom certificates. |
debug | Use the x-cachebz-debug header on edge requests. |
account:admin | Manage members, billing and other tokens. |
Errors
Authentication errors use standard status codes and a JSON body with a stable code you can match on:
HTTP/2 403
content-type: application/json
{
"error": {
"code": "token_scope_missing",
"message": "This token does not have the purge:write scope.",
"request_id": "req_01JE3XA4P9"
}
}Rotating tokens
- Create a new token with the same scopes.
- Deploy it to the systems that use the old one.
- Check the old token's last used time in the dashboard until it stops changing.
- Revoke the old token.
Leaked a token?
Revoke it immediately in the dashboard; revocation takes effect at every API endpoint within five seconds. Then check the audit log for actions taken with it.
Was this page helpful? Tell us what was missing at support@cache.bz. Every message is read by the team that writes these docs.