Cloudflare Docs
Analytics
Analytics
Visit Analytics on GitHub
Set theme to dark (⇧+D)

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.

For more details on API tokens and the full range of supported options, refer to Creating API tokens .

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:

  1. Log in to your Cloudflare account and select My Profile from the user account drop-down list.

User account drop-down list

  1. In your user profile page, select the API Tokens tab.

  2. In the API Tokens page, click Create Token.

API Tokens tab

The Create API Token page displays.

Create API Token page

The next section of this walkthrough shows you how to configure a custom token for access to the GraphQL Analytics API.

Configure a custom API token

To configure a custom token, follow these steps:

  1. Click Get started in the Custom token section of the Create API Token page:

Create API Token page

The Create Custom Token page displays:

Create Custom Token page

  1. Enter a descriptive name for your token in the Token name text input field.

  2. 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:

Configure permissions

  1. To configure the specific zones to which the token grants access, use the Zone Resources drop-down lists. In this example, the token is set to grant access to all zones:

Configure resources

  1. [Optional] To restrict the API token to specific IP addresses, use the IP Address Filtering controls.

Configure IP

  1. To define how long the token is valid, click the TTL (time-to-live) start/end date picker.

Configure TTL

  1. Click Continue to summary.

The next section of this walkthrough covers how to review and test your API token.

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 curl command.

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.