Skip to content

Create a personal access token

POST
/api/v4/user/personal_access_tokens

Creates a personal access token for the currently authenticated user. For security purposes, the token is limited to the k8s_proxy and self_rotate scope. Token values are included with the response, but cannot be retrieved later. This feature was introduced in GitLab 16.5.

Media type application/json
object
name
required

The name of the access token

string
nullable
Example
My token
description

The description of the access token

string
nullable
Example
A token used for k8s
expires_at

Expiration date of the access token in ISO format (YYYY-MM-DD). If undefined, the date is set to the maximum allowable lifetime limit.

string format: date
nullable
Example
2021-01-31
granular_scopes

List of granular scopes to assign to the token

Array<object>
nullable
object
access
required

Access to configure for the granular scope.

string
>= 1 characters
Allowed values: personal_projects all_memberships selected_memberships user instance
permissions
required

List of permissions for the granular scope

Array<string>
nullable
project_ids

IDs of projects to associate with the granular scope, when access is selected_memberships

Array<integer>
nullable
group_ids

IDs of groups to associate with the granular scope, when access is selected_memberships

Array<integer>
nullable
scopes

The array of scopes of the personal access token

Array<string>
nullable

Created

Media type application/json
object
id
integer format: int64
name
string
revoked
boolean
created_at
string format: date-time
description
string
scopes
array
user_id
integer format: int64
last_used_at
string format: date-time
active
boolean
granular
boolean
expires_at
string format: date-time
token
string
granular_scopes
Array<object>
object
access
string
permissions
array
project_id
integer format: int64
group_id
integer format: int64
Example
{
"id": 2,
"name": "John Doe",
"description": "Token to manage api",
"scopes": [
"api"
],
"user_id": 3,
"last_used_at": "2020-08-31T15:53:00.073Z",
"expires_at": "2020-08-31T15:53:00.073Z",
"granular_scopes": [
{
"access": "personal_projects",
"permissions": [
"read_job"
],
"project_id": 3,
"group_id": 5
}
]
}

Bad Request