API Token Permissions, Account Tokens and REST Authentication
How account and user API tokens differ, how to create them with permissions and templates, and how to authenticate REST API calls.
This page summarises Cloudflare’s API authentication model: scoped API tokens (user-owned and account-owned), permission groups, dashboard templates and template URLs, and how tokens differ from legacy Global API keys. Product-specific permission names appear in each API’s “Get started” page; the patterns here apply across the REST API at https://api.cloudflare.com/client/v4/.
API tokens vs Global API key: which credential to use
Section titled “API tokens vs Global API key: which credential to use”Cloudflare recommends API tokens as the preferred way to call its APIs. Tokens can limit access to specific accounts and zones and to particular permission groups; legacy Global API keys authenticate only as the user and do not scope resources.
Cloudflare recommends API Tokens as the preferred way to interact with Cloudflare APIs. You can configure the scope of tokens to limit access to account and zone resources, and you can define the Cloudflare APIs to which the token authorizes access.
— Cloudflare, Authentication
Global API key has access to all of a user’s resources… Full permissions… Limited to one per user… Lack of advanced limits on usage… For these reasons, Global API key is not recommended for new customers.
— Cloudflare, Get Global API key (legacy)
For GraphQL Analytics and most new integrations, create a scoped token rather than using the Global API key. Keys are retrieved under My Profile > API Tokens in the API Keys section.
User API tokens vs Account API tokens: service principal vs person
Section titled “User API tokens vs Account API tokens: service principal vs person”User API tokens act on behalf of a specific user and inherit a subset of that user’s permissions. They suit ad hoc scripting when “acting as the user” is enough and long-term durability matters less.
Account API tokens are owned by the account: they behave like service principals with their own permission set. Cloudflare positions them for CI/CD, SIEM integrations, and automation that must keep working after the configuring user leaves.
While user tokens act on behalf of a particular user and inherit a subset of that user’s permissions, account API tokens allow you to set up durable integrations that can act as service principals with their own specific set of permissions. This approach is ideal for scenarios like CI/CD, or building integrations with external services like SIEMs where it is important that the integration continues working, even long after the user who configured the integration may have left your organization altogether. User tokens are better for ad hoc tasks like scripting, where acting as the user is ideal and durability is less of a concern.
— Cloudflare, Account API tokens
New account-owned secrets use the cfat_ prefix so credential scanners can detect leaks. See Token formats for verification endpoints.
| Aspect | User API token | Account API token |
|---|---|---|
| Owner | User profile (/profile/api-tokens) |
Account (Manage account > Account API tokens) |
| Typical use | Scripts, personal automation, some APIs (e.g. Workers Builds) | CI/CD, Terraform, long-lived integrations |
| Durability | Tied to user membership and roles | Persists as account credential |
| Prefix | (varies) | cfat_ for new tokens |
| Creation roles | User with sufficient permissions | API Token Provisioning or Super Administrator (see below) |
Some APIs accept only one type. For example, the Workers Builds API requires a user-scoped token; account-scoped tokens return “Invalid token” errors.
API token permissions: zone, account and user groups
Section titled “API token permissions: zone, account and user groups”Permissions are grouped by resource type. DNS and zone firewall rules sit under Zone; billing under Account; managing a user’s own tokens under User.
Permissions are segmented into three categories based on resource: Zone permissions, Account permissions, User permissions.
— Cloudflare, API token permissions
Each API documents required groups (for example Spectrum analytics needs Analytics Read; billing endpoints need Billing Read or Billing Edit). For programmatic token creation, Cloudflare recommends permission group IDs (stable identifiers) over display names—list them with the List permission groups endpoint for account or user scope.
Create API tokens in the dashboard: templates and custom policies
Section titled “Create API tokens in the dashboard: templates and custom policies”Using the Cloudflare API requires authentication so Cloudflare knows who is calling and what they may do—start from Get started.
User tokens: dashboard → My Profile > API Tokens → Create Token.
Account tokens: Manage account > Account API tokens → Create Token (name, permissions, optional expiration). Alternatively use the account API token creation API.
Predefined API token templates (e.g. Edit Zone DNS, Edit Cloudflare Workers, WordPress) pre-fill permission sets; you can still narrow account and zone resources. For WordPress APO, pick the WordPress template on the Account API tokens page.
- Open the correct token page (profile vs account).
- Create Token → choose a template or Custom token → Get started.
- Set a descriptive Token name (after creation the secret is hidden; the name is how you identify the token later).
- Add Permissions (Account / Zone / User) and Resources (specific zones or all).
- Optional: Client IP Address Filtering and TTL (Restrict tokens).
- Continue to summary → Create Token → copy the secret immediately (shown once).
The token displays only on the confirmation page, so copy the token and store it safely, since anyone who has the token can use it to access your data.
— Cloudflare, Configure an Analytics API token
Account API token roles: who can create and see tokens
Section titled “Account API token roles: who can create and see tokens”Creation is no longer limited to Super Administrators. Members with the API Token Provisioning role can create account tokens via Dashboard, API, Terraform, or CF CLI.
Account API token creation is no longer limited to Super Administrators. Members with the API Token Provisioning role can now create Account API tokens via the Dashboard, API, Terraform, or CF CLI…
— Cloudflare, Account members can self-serve create Account API tokens
Visibility: Super Administrators see all account tokens; other members typically see only tokens they created. New tokens include creator attribution metadata. OAuth clients with account_api_tokens:create (e.g. Cloudflare CLI) can also create account tokens, with permissions capped by authorized scopes.
For Workers, account tokens can scope to Specified Workers and a role such as metadata read-only—useful for agents and pipelines without full Workers admin access.
Scoped tokens for Zero Trust and least privilege
Section titled “Scoped tokens for Zero Trust and least privilege”Teams that manage Cloudflare Zero Trust separately from WAF or DNS can issue tokens that only touch Zero Trust settings:
You can configure scoped API tokens so that team members and automated systems can manage Cloudflare Zero Trust settings without having permission to modify other configurations in Cloudflare.
— Cloudflare, API and Terraform
SCIM provisioning文档 recommends account API tokens for durability when user-owned tokens might break if the owner loses access.
API token template URLs: share required permissions without picking each box
Section titled “API token template URLs: share required permissions without picking each box”Template URLs open the dashboard creation form with permissionGroupKeys pre-filled. They do not create the token automatically—the user must still confirm and click Create Token.
User token base pattern:
https://dash.cloudflare.com/profile/api-tokens?permissionGroupKeys=[ENCODED_PERMISSIONS]&accountId=*&zoneId=all&name=[TOKEN_NAME]
Account token pattern:
https://dash.cloudflare.com/?to=/:account/api-tokens&permissionGroupKeys=[ENCODED_PERMISSIONS]&name=[TOKEN_NAME]
Encode a JSON array such as:
[{ "key": "dns", "type": "edit" }, { "key": "analytics", "type": "read" }]For account URLs, prefer permission group IDs in key (most reliable); user URLs require short keys like dns and drop unknown entries silently—account URLs show a notice for unresolved keys. Ready-made examples for DNS, Workers, analytics, and Access appear in the same template URL guide.
Create and rotate tokens via the REST API
Section titled “Create and rotate tokens via the REST API”To mint tokens programmatically, you first need a “bootstrap” token from the dashboard—for example Account > Account API Tokens > Edit to create account-owned tokens, or the Create additional tokens template (User > API Tokens > Edit) for user-owned tokens. Full flow: Create tokens via API.
Policy shape uses permission_groups with id, scoped resources, and optional not_before, expires_on, and condition.request.ip CIDR filters.
Authenticate REST requests: Bearer header and common errors
Section titled “Authenticate REST requests: Bearer header and common errors”All v4 REST calls use the same header pattern:
Once you create your API token, all API requests are authorized in the same way. Cloudflare uses the RFC standard Authorization: Bearer <API_TOKEN> interface.
— Cloudflare, Make API calls
Example from SDKs:
curl "https://api.cloudflare.com/client/v4/zones" \ --header "Authorization: Bearer <API_TOKEN>"Store tokens in environment variables (e.g. CLOUDFLARE_API_TOKEN), never in public repos. Validate a user token with Verify Token.
GraphQL Analytics errors map cleanly to token problems: 401 Unauthorized means missing, expired, or invalid bearer token; 403 means the token lacks permission for the account or zone in the query—fix permissions in the dashboard and match the product doc (e.g. Configure an Analytics API token).
Account API token product compatibility: what still fails
Section titled “Account API token product compatibility: what still fails”Account tokens are GA for most products but not all. Unsupported examples from the compatibility matrix:
| Product | Account API token |
|---|---|
| Intel Data Platform | ❌ |
| Page Rules | ❌ |
| Registrar | ❌ |
| Super Bot Fight Mode | ❌ |
| Turnstile | ❌ |
| Zero Trust Client Platform | ❌ |
For those surfaces, use a user token or another auth path documented on the product page until compatibility changes.
Common mistakes when provisioning API tokens
Section titled “Common mistakes when provisioning API tokens”- Wrong token type for the API (e.g. account token on Workers Builds).
- Over-broad resources (“all zones”) when a single zone or Worker would suffice—GitHub/GitLab CI docs explicitly recommend scoping down (GitHub Actions).
- Skipping copy on create; regeneration is possible but requires reconfiguring policies.
- Token-creator exceeds own role—Troubleshooting notes you cannot create permissions above your membership.
- AI Gateway vs Workers AI:
/accounts/{account_id}/ai/*needs Workers AI permission, not AI Gateway alone (AI Gateway REST API). - Exposing tokens to frontends—RealtimeKit FAQ states API tokens belong on the backend only.
How to check this on your site
Section titled “How to check this on your site”- In the Cloudflare dashboard, open API token permissions alongside your token’s summary and confirm each required group for your target API (e.g. Make your first API request for Radar).
- Run the Verify Token
curlcommand from Troubleshooting and confirm"status": "active". - Call a minimal read endpoint for your use case with
Authorization: Bearer $CLOUDFLARE_API_TOKENper Make API calls; on failure, compare HTTP status with GraphQL authentication errors. - If using account tokens, check your product against the Account API tokens compatibility matrix.
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match your dashboard or API responses, email yimasynthetic@gmail.com with the page URL, the section heading, and the exact error or behavior you see.