API Tokens
API tokens are the access tokens for authentication. Instead of using username and password, it can be used for programmatic access to API. It allows users to generate API tokens with the desired access. Only super admin users can generate API tokens and see the generated tokens.
Generate API Token
To generate API tokens, go to Global Configurations -> Authorization -> API tokens
and click Generate New Token
.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-1.png&width=768&dpr=4&quality=100&sign=f4d3cb74&sv=1)
Enter a name for the token.
Add Description.
Select an expiration date for the token (7 days, 30 days, 60 days, 90 days, custom and no expiration).
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-2.png&width=768&dpr=4&quality=100&sign=a3ee7cfb&sv=1)
To select a custom expiration date, select
Custom
from the drop-down list. In the adjacent field, you can select your custom expiration date for the API token.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-custom.png&width=768&dpr=4&quality=100&sign=b4c4934c&sv=1)
You can assign permission to the token either with:
Super admin permission: To generate a token with super admin permission, select
Super admin permission
.Specific permissions: Selecting
Specific permissions
option allows you to generate a token with a specific role for:Devtron Apps
Helm Apps
Kubernetes Resources
Chart Groups
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-specific-permissions-latest1.jpg&width=768&dpr=4&quality=100&sign=7e1e140f&sv=1)
Click
Generate Token
.
A pop-up window will appear on the screen from where you can copy the API token.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-5.png&width=768&dpr=4&quality=100&sign=f9dfc330&sv=1)
Use API Token
Once Devtron API token has been generated, you can use this token to request Devtron APIs using any API testing tool like Jmeter, Postman, Citrus. Using Postman here as an example.
Open Postman. Enter the request URL with POST
method and under HEADERS, enter the API token as shown in the image below.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-6.png&width=768&dpr=4&quality=100&sign=472e4dc7&sv=1)
In the Body
section, provide the API payload as shown below and click Send
.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-7.png&width=768&dpr=4&quality=100&sign=9890254e&sv=1)
As soon as you click Send
, the created application API will be triggered and a new Devtron app will be created as provided in the payload.
Update API Token
To set a new expiration date or to make changes in permissions assigned to the token, we need to update the API token in Devtron. To update the API token, click the token name or click on the edit icon.
To set a new expiration date, you can regenerate the API token. Any scripts or applications using this token must be updated. To regenerate a token, click Regenerate token
.
A pop-up window will appear on the screen from where you can select a new expiration date.
Select a new expiration date and click Regenerate token
.
This will generate a new token with a new expiration date.
To update API token permissions, give the permissions as you want to and click Update Token
.
![](https://docs.devtron.ai/~gitbook/image?url=https%3A%2F%2Fdevtron-public-asset.s3.us-east-2.amazonaws.com%2Fimages%2Fglobal-configurations%2Fapi-token%2Fapi-token-3.png&width=768&dpr=4&quality=100&sign=68fe53c2&sv=1)
Delete API Token
To delete an API token, click delete
icon. Any applications or scripts using this token will no longer be able to access the Devtron API.
Last updated