Configure an Analytics API token
Cloudflare recommends API tokens as the preferred authentication method with Cloudflare APIs. This article walks through creating API tokens for authentication to the GraphQL Analytics API.
To create an API token for authentication to the GraphQL Analytics API, use this workflow:
Access the Create API Token page
To access the Create Custom Token page, follow these steps:
Log in to your Cloudflare account and select My Profile from the user account drop-down list.
In your user profile page, select the API Tokens tab.
In the API Tokens page, click Create Token.
The Create API Token page displays.
Configure a custom API token
To configure a custom token, follow these steps:
Click Get started in the Custom token section of the Create API Token page:
The Create Custom Token page displays:
Enter a descriptive name for your token in the Token name text input field.
To configure access to the GraphQL Analytics API, use the Permissions drop-down lists. To set permissions for the GraphQL Analytics API, select Analytics from the second drop-down list.
This example scopes zone-level permissions for read access to the Analytics API:
To configure the specific zones to which the token grants access, use the Resources drop-down lists. In this example, the token is set to grant access to all zones:
[Optional] To restrict the API token to specific IP addresses, use the IP Address Filtering controls.
To define how long the token is valid, click the TTL (time-to-live) start/end date picker.
Click Continue to summary.
Review and create your API token
Once you click Continue to summary, the API Token Summary page displays.
Use the API Token Summary to confirm that you have scoped the API Token to the desired permissions and resources before creating it.
Once you have validated your API token configuration, click Create Token.
Copy and test your API token
When you create a new token, a confirmation page displays that includes your token and a custom
To copy the token to your device's clipboard, click the Copy button.
To test your token, copy the
curl command and paste it into a terminal.
When you have finished, click View all API tokens.