Skip to content

Create an impersonation token

POST
/api/v4/users/{user_id}/impersonation_tokens

Creates an impersonation token. These tokens are used to act on behalf of a user and can perform API calls as well as Git read and write actions. These tokens are not visible to the associated user on their profile settings page. Token values are included with the response, but cannot be retrieved later. Administrators only.

user_id
required
integer

The ID of the user

Media type application/json
object
name
required

The name of the impersonation token

string
nullable
description

The description of the personal access token

string
nullable
expires_at

The expiration date in the format YEAR-MONTH-DAY of the impersonation token

string format: date
nullable
scopes

The array of scopes of the impersonation token

Array<string>
nullable
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

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
last_used_ips

The five most recent unique IP addresses that have authenticated with this token. When the limit is reached, the oldest IP address is removed. The list updates once per minute per token.

Array<string>
granular_scopes
Array<object>
object
access
string
permissions
array
project_id
integer format: int64
group_id
integer format: int64
impersonation
string
token
string
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",
"last_used_ips": [
"127.0.0.1",
"127.0.0.2",
"127.0.0.3"
],
"granular_scopes": [
{
"access": "personal_projects",
"permissions": [
"read_job"
],
"project_id": 3,
"group_id": 5
}
]
}

Bad Request

Not Found