Access tokens API - POST a token
Creates a new API token.
The token will be owned by the user who owns the token used to authenticate the call.
The request consumes and produces an application/json
payload.
POST | ManagedDynatrace for Government | https://{your-domain}/e/{your-environment-id}/api/v2/apiTokens |
SaaS | https://{your-environment-id}.live.dynatrace.com/api/v2/apiTokens | |
Environment and Cluster ActiveGate (default port 9999) | https://{your-activegate-domain}:9999/e/{your-environment-id}/api/v2/apiTokens |
Authentication
To execute this request, you need an access token with apiTokens.write
scope.
To learn how to obtain and use it, see Tokens and authentication.
Parameters
Parameter | Type | Description | In | Required |
---|---|---|---|---|
body | ApiTokenCreate | The JSON body of the request. Contains parameters of the new API token. | body | required |
Request body objects
The ApiTokenCreate
object
Parameters of a new API token.
Element | Type | Description | Required |
---|---|---|---|
expirationDate | string | The expiration date of the token. You can use one of the following formats:
If not set, the token never expires. | optional |
name | string | The name of the token. | required |
personalAccessToken | boolean | The token is a personal access token ( Personal access tokens are tied to the permissions of their owner. | optional |
scopes | string[] | A list of the scopes to be assigned to the token.
| required |
Request body JSON model
This is a model of the request body, showing the possible elements. It has to be adjusted for usage in an actual request.
1{2 "expirationDate": "now+14d",3 "name": "tokenName",4 "personalAccessToken": false,5 "scopes": [6 "metrics.read"7 ]8}
Response
Response codes
Code | Type | Description |
---|---|---|
201 | ApiTokenCreated | Success. The token has been created. The body of the response contains the token secret. |
400 | ErrorEnvelope | Failed. The input is invalid. |
Response body objects
The ApiTokenCreated
object
The newly created token.
Element | Type | Description |
---|---|---|
expirationDate | string | The token expiration date in ISO 8601 format ( |
id | string | The ID of the token, consisting of prefix and public part of the token. |
token | string | The secret of the token. |
Response body JSON model
1{2 "expirationDate": "2020-11-12T08:15:30.144Z",3 "id": "dt0c01.ST2EY72KQINMH574WMNVI7YN",4 "token": "dt0c01.ST2EY72KQINMH574WMNVI7YN.G3DFPBEJYMODIDAEX454M7YWBUVEFOWKPRVMWFASS64NFH52PX6BNDVFFM572RZM"5}