Authenticate API requests with tokens
Learn how you can authenticate your requests to the Axiom API with tokens.
This reference article explains how you can authenticate your requests to the Axiom API with tokens.
Why authenticate with tokens
You can use the Axiom API and CLI to programmatically ingest and query data, and manage settings and resources. For example, you can create new API tokens and change existing datasets with API requests. To prove that these requests come from you, you must include forms of authentication called tokens in your API requests. Axiom offers two types of tokens:
- API tokens let you control the actions that can be performed with the token. For example, you can specify that requests authenticated with a certain API token can only query data from a particular dataset.
- Personal access tokens (PATs) provide full control over your Axiom account. Requests authenticated with a PAT can perform every action you can perform in Axiom. When possible, use API tokens instead of PATs.
When working with tokens, use the principle of least privilege:
- Assign only those privileges to API tokens that are necessary to perform the actions that you want.
- When possible, use API tokens instead of PATs because PATs have full control over your Axiom account.
For more information on how to use tokens in API requests, see Get started with Axiom API.
API tokens
You can use two types of API tokens in Axiom:
- Basic API tokens let you ingest data to Axiom. When you create a basic API token, you select the datasets that you allow the basic API token to access.
- Advanced API tokens let you perform a wide range of actions in Axiom beyond ingesting data. When you create an advanced API token, you select which actions you allow the advanced API token to perform. For example, you can create an advanced API token that can only query data from a particular dataset and another that has wider privileges such as creating datasets and changing existing monitors.
After creating an API token, you can’t change the privileges assigned to that API token.
Create basic API token
- Click Settings > API tokens, and then click New API token.
- Name your API token.
- Optional: Give a description to the API token and set an expiration date.
- In Permissions, click Basic.
- In Dataset access, select the datasets where this token can ingest data.
- Click Create token.
- Copy the API token that appears and store it securely. It won’t be displayed again.
Create advanced API token
-
Click Settings > API tokens, and then click New API token.
-
Name your API token.
-
Optional: Give a description to the API token and set an expiration date.
-
In Permissions, click Advanced.
-
In Advanced permissions, choose one of the following options:
- Select Custom and define your own permission set. In Datasets, select the actions the token can perform on all datasets, or click Add dataset to grant access to specific datasets. In Views, you can click Add view to grant the token access to specific views. In Organization, you can select the actions the token can perform that affect your whole Axiom organization. For example, creating users and changing existing notifiers.
- Select one of the presets to auto-populate a predefined set of capabilities. For example, Preset - Evaluations allows an SDK to write evaluation traces and query comparison data, and Preset - Terraform grants capabilities to manage Axiom resources using Terraform.
-
Click Create token.
-
Copy the API token that appears and store it securely. It won’t be displayed again.
Create an API token with an AI agent
Axiom MCP Server lets your AI agent help you create an API token quickly and securely.
The prepareApiToken tool constructs a prefilled template in Axiom Console for you to review before creating the token yourself. By handing off token creation to you, it keeps the token value out of the conversation with the agent. Axiom recommends that you do not expose API tokens directly to AI agents.
To create an API token, follow these steps:
- Ask your AI agent to prepare an API token with the required permissions.
- Open the link, review the token details, and click Create token.
- Copy the API token and store it securely.
Limit query costs of an API token
You can cap the hourly and daily query costs of an API token, in dollars. When the token exceeds a limit, its query requests fail with HTTP status code 429 until the window resets. Ingest and other operations are unaffected. This is particularly useful for tokens you give to AI agents.
To set limits when you create a token, enter an hourly limit, a daily limit, or both in Query cost limits. To add or change limits on an existing token, click Settings > API tokens, select the token, and then edit Query cost limits. The token page shows the token’s current usage against each limit.
For more information, see Set query cost limits for AI agents.
View API token details and usage
In Settings > API tokens, search by token name or ID. You can also filter the token list by Created by, Created, Expiry (Expiring within 7 days, Expired, or Not expired), and Last used. Expired tokens remain in the list. Check Last used before replacing a token. For tokens used for both ingestion and other API requests, select the token to see each type of activity separately.
Axiom highlights tokens that expire within 7 days. For fine-grained tokens created with a lifetime of at least 7 days, Axiom also emails the creator before expiry. If the creator is no longer in the organization, Axiom emails the organization owners.
Regenerate API token
Recommended: Rotate API tokens regularly and set an expiration date after which the token becomes invalid.
Tokens with an expiration date can’t be regenerated. To replace an expiring or expired token, create a new API token and update your clients.
To regenerate a non-expiring, non-classic API token:
- Click Settings > API tokens.
- Click the API token to regenerate, and then click Regenerate token. Alternatively, open the actions menu next to the token in the list, and then select Regenerate token.
- Optional: In Expire previous token, choose a delay before the previous token stops working. In Expiration, choose an expiration date for the regenerated token.
- Click Regenerate.
- Copy the regenerated API token that appears and store it securely. It won’t be displayed again.
- Update all API requests that use the token with the regenerated value.
Delete API token
- Click Settings > API tokens.
- Click the API token to delete, and then click Delete token. Alternatively, open the actions menu next to the token in the list, and then select Delete token.
- Click Delete token to confirm.
Personal access tokens (PAT)
Personal access tokens (PATs) provide full control over your Axiom account. Requests authenticated with a PAT can perform every action you can perform in Axiom. When possible, use API tokens instead of PATs.
Create PAT
- Click Settings > Profile.
- In the Personal tokens section, click New token.
- Name the PAT.
- Optional: Give a description to the PAT.
- Click Save.
- Copy the PAT that appears and store it securely. It won’t be displayed again.
Delete PAT
- Click Settings > Profile.
- In the Personal tokens section, open the actions menu next to the PAT that you want to delete, and then select Delete.
- Click Delete token to confirm.
Determine organization ID
If you authenticate requests with a PAT, you must include the organization ID in the requests. API tokens don’t need the organization ID; if a request with an API token includes one, it must match the token’s organization. For more information on including the organization ID in the request, see Axiom API and Axiom CLI.
Determine the organization ID in one of the following ways:
- Click Settings, and then copy the organization ID in the top right corner.
- Click Settings > General, and then find the ID section.
- Go to the Axiom app and check the URL. For example, in the URL
https://app.axiom.co/axiom-abcd/datasets, the organization ID isaxiom-abcd.