Generate User Api Token Using POST
Programmatically Generate User Api Token. The following restrictions are in place: .
- 'All Roles' or high privilege organization roles are not allowed as a scope for the new API token (few exceptions apply)
- Organization ID in Access token (in headers) and ID token (in request body) should be the same.
- Maximum number of 50 API tokens is allowed.
- In non-production environments it is possible to choose for which of your organizations to generate token.
Access Policy
Role | User Accounts | Service Accounts (Client Credentials Applications) |
---|---|---|
All Roles | ✔️ | ❌ |
"GenerateApiTokenRequestV2 Object"
Number of days to notify before token expiration
ID Token is signed JWT token returned from the authorization server and contains the user's profile information, includingthe domain of the identity provider. This domain is used to obtain the identity provider URL. This token is used for optimization so the application can know the identity of the user, without having to make any additional network requests. This token can be generated via the Authorization Code flow only.
The name of the API token. The value must be alphanumerical and can contain the following symbols -_.`':@&, and space. International characters are allowed.
API Token Time To Live (TTL)
The allowed general, organization and service scopes of access.
Id of the organization for which to generate token (if different from the logged in user organization). This functionality is allowed only for non-production environments.
OK
{
"apiToken": "string"
}
The value of the API token.
Max number of 50 user API Tokens reached | Invalid or expired idToken | Provided idToken does not belong to loggedin user | Authenticated Organization id and idToken organization id mismatch | High privilege organization scopes and 'All roles' scope not allowed
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
The user is not authorized to use the API
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
IP auth policy violation
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
The requested resource could not be found
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
The request could not be processed due to a conflict
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
The user has sent too many requests
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
An unexpected error has occurred while processing the request
"CspErrorResponse Object"
cspErrorCode
message
errorCode
requestId
moduleCode
statusCode
curl -X POST -H 'Authorization: <value>' -H 'Content-Type: application/json' -d '[{}]' https://{api_host}/csp/gateway/am/api/loggedin/user/api-tokens