Skip to content

Rotate a project access token

POST
/api/v4/projects/{id}/access_tokens/{token_id}/rotate

Rotates a project access token. This immediately revokes the previous token and creates a token. Generally, this endpoint rotates a specific project access token by authenticating with a personal access token. You can also use a project access token to rotate itself. If you attempt to use this endpoint to rotate a token that was previously revoked, any active tokens from the same token family are revoked. This feature was introduced in GitLab 16.0.

id
required
string

The project ID

token_id
required
string

The ID of the token

Media type application/json
object
expires_at

The expiration date of the token

string format: date
nullable
Example
2021-01-31

OK

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
access_level
integer
resource_type
string
resource_id
integer
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
}
],
"access_level": 40,
"resource_type": "project",
"resource_id": 1234
}

Bad Request

Not Found