Create an API token.
Changed onCreate a new personal access token or service account token in the workspace.
Unlike the other API token endpoints, this one requires no particular scope: any valid token can call it. What a token is allowed to create is bounded by its own type and its own scopes instead.
A token can only create another token of its own type: type must match the type of the token used to authenticate the call. A personal access token therefore creates personal access tokens owned by its own member, and a service account token creates service account tokens belonging to the workspace. There is no way to create a token on behalf of another member.
The requested scopes must be a subset of the scopes of the calling token.
A service account token whose creating user no longer exists cannot create tokens, and the call is rejected.
The response is the only place the new token's clear text key is exposed: it cannot be read again from the list or retrieve endpoints.
Creation is also rejected when the name is already used by an active token of the same type, when the workspace has reached its maximum number of active tokens, or when the requested lifetime exceeds the maximum lifetime allowed by the workspace policy.
Request
- Base URLhttps://api.gitguardian.com
- URLhttps://api.gitguardian.com/v1/api_tokens
- AuthHTTP bearer
Request body
Example request
{
"name": "myTokenName",
"type": "personal_access_token",
"scopes": [
"incidents:read",
"scan"
],
"lifetime": 30
}Response
API token created
Example response
{
"id": "5ddaad0c-5a0c-4674-beb5-1cd198d13360",
"name": "myTokenName",
"workspace_id": 42,
"type": "personal_access_token",
"status": "revoked",
"created_at": "2023-05-20T12:40:55.662949Z",
"last_used_at": "2023-05-24T12:40:55.662949Z",
"revoked_at": "2023-05-27T12:40:55.662949Z",
"member_id": 22015,
"creator_id": 22015,
"scopes": [
"incidents:read",
"scan"
],
"key": "gg_pat_AbCdEf123456..."
}Changes
- warning
added the new
nhi:readenum value to the//response property for the response status - warning
added the new
nhi:writeenum value to the//response property for the response status - info
added the new
nhi:readenum value to the request property/ - info
added the new
nhi:writeenum value to the request property/
- warning
- warning
added the new
custom_tags:readenum value to the//response property for the response status - warning
added the new
custom_tags:writeenum value to the//response property for the response status - warning
added the new
health_checks:readenum value to the//response property for the response status - warning
added the new
health_checks:writeenum value to the//response property for the response status - warning
added the new
public-perimeter:readenum value to the//response property for the response status - warning
added the new
scan:create-incidentsenum value to the//response property for the response status - warning
added the new
secrets:readenum value to the//response property for the response status - warning
added the new
secrets:writeenum value to the//response property for the response status - warning
added the new
sources:scanenum value to the//response property for the response status - info
added the new
custom_tags:readenum value to the request property/ - info
added the new
custom_tags:writeenum value to the request property/ - info
added the new
health_checks:readenum value to the request property/ - info
added the new
health_checks:writeenum value to the request property/ - info
added the new
public-perimeter:readenum value to the request property/ - info
added the new
scan:create-incidentsenum value to the request property/ - info
added the new
secrets:readenum value to the request property/ - info
added the new
secrets:writeenum value to the request property/ - info
added the new
sources:scanenum value to the request property/
- warning