Create a new tenant token

  • Published Mar 09, 2021

This API call creates a new tenant management token for an environment.

Authentication

To execute this request, you need the Token Management (EnvironmentTokenManagement) permission assigned to your API token. Generate your API token via Cluster Management Console (CMC). To learn how to obtain and use it, see Cluster API - Authentication.

Endpoint

/api/cluster/v2/environments

Parameter

ParameterTypeDescriptionInRequired
idstring

The ID of the environment where the token is valid.

pathRequired
bodyCreateEnvironmentTokenManagementToken

The JSON body of the request. Contains parameters of the token.

bodyOptional

Request body objects

The CreateEnvironmentTokenManagementToken object

ElementTypeDescriptionRequired
expiresInDuration

Defines a period of time.

Optional
namestring

The name of the token.

Required

The Duration object

Defines a period of time.

ElementTypeDescriptionRequired
unitstring

The unit of time.

If not set, millisecond is used.

The element can hold these values
  • DAYS
  • HOURS
  • MILLIS
  • MINUTES
  • SECONDS
Optional
valueinteger

The amount of time.

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.

{
"expiresIn": {
"unit": "SECONDS",
"value": 3600
},
"name": "Token Management"
}

Response

Response codes

CodeTypeDescription
201Token

Success. The token has been created. The response body contains the token itself

400ErrorEnvelope

Failed. The input is invalid.

Response body objects

The Token object

ElementTypeDescription
tokenstring

Dynatrace API authentication token.

The ErrorEnvelope object

ElementTypeDescription
errorError-

The Error object

ElementTypeDescription
codeinteger

The HTTP status code

constraintViolationsConstraintViolation[]

A list of constraint violations

messagestring

The error message

The ConstraintViolation object

A list of constraint violations

ElementTypeDescription
locationstring-
messagestring-
parameterLocationstring-
The element can hold these values
  • HEADER
  • PATH
  • PAYLOAD_BODY
  • QUERY
pathstring-

Response body JSON models

{
"token": "abcdefjhij1234567890"
}
{
"error": {
"code": 1,
"constraintViolations": [
{
"location": "string",
"message": "string",
"parameterLocation": "HEADER",
"path": "string"
}
],
"message": "string"
}
}

Example

Creates a new tenant management token for the environment 19a963a7-b19f-4382-964a-4df674c8eb8e.

Curl

curl -X POST "https://myManaged.cluster.com/api/cluster/v2/environments/19a963a7-b19f-4382-964a-4df674c8eb8e/tokenManagementToken" -H "accept: application/json; charset=utf-8" -H "Authorization: Api-Token dt0c01.abc123.abcdefjhij1234567890" -H "Content-Type: application/json; charset=utf-8" -d "{\"name\":\"Token Management\",\"expiresIn\":{\"value\":3600,\"unit\":\"SECONDS\"}}"

Request URL

https://myManaged.cluster.com/api/cluster/v2/environments/19a963a7-b19f-4382-964a-4df674c8eb8e/tokenManagementToken

Request body

{
"name": "Token Management",
"expiresIn": {
"value": 3600,
"unit": "SECONDS"
}
}

Response body

{
"token": "dt0c01.RVSDGWUQEVQFS4CWIZTKX5DV.<token-value>"
}

Response code

201