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 data and manage your organisation settings. For example, you can add new users and change existing monitors 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.
Keep tokens confidential. Anyone with these forms of authentication can perform actions on your behalf such as sending data to your Axiom dataset.
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, avoid using PATs because they 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 cannot 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 Token permissions, click Basic.
- In Dataset access, select the datasets where this token can ingest data.
- Click Create.
- 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 Token permissions, click Advanced.
- Select the datasets that this token can access and the actions it can perform.
- In Org level permissions, select the actions the token can perform that affect your whole Axiom organisation. For example, creating users and changing existing notifiers.
- Click Create.
- Copy the API token that appears and store it securely. It won’t be displayed again.
Regenerate API token
Similarly to passwords, it’s recommended to change API tokens regularly and to set an expiration date after which the token becomes invalid. When a token expires, you can regenerate it.
To regenerate an advanced API token, follow these steps:
- Click Settings > API tokens.
- In the list, select the API token you want to regenerate.
- Click Regenerate token.
- Copy the regenerated API token that appears and store it securely. It won’t be displayed again.
- Update all the API requests where you use the API token with the regenerated token.
Delete API token
- Click Settings > API tokens.
- In the list, point your mouse over the API token you want to delete.
- To the right, click Delete.
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, avoid using PATs.
To authenticate an API request with a PAT, include the Org ID in the requests. For more information, see Get started with Axiom API.
Create PAT
- Click Settings > Profile.
- In the Personal tokens section, click New token.
- Name the PAT.
- Optional: Give a description to the PAT.
- Copy the PAT that appears and store it securely. It wont be displayed again.
Delete PAT
- Click Settings > Profile.
- In the list, find the PAT that you want to delete.
- To the right of the PAT, click Delete.
Was this page helpful?