access_tokens

Rotate a personal access token

Rotates a specified personal access token. This revokes the previous token and creates a token that expires after one week. Administrators can revoke tokens for any user. Non-administrators can only revoke their own tokens.

post/api/v4/personal_access_tokens/{id}/rotate

Request

  • Base URL
    https://gitlab.com
  • Auth
    none declared

Path parameters

idinteger required

The ID of a personal access token

Request body

expires_atstring date

The expiration date of the token

Example request

{
  "expires_at": "2021-01-31"
}

Response

Rotate a personal access token

idinteger required
namestring required
revokedboolean required
created_atstring date-time required
descriptionstring required
user_idinteger required
last_used_atstring date-time required
last_used_ipsstring[] required

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.

activeboolean required
granularboolean required
expires_atstring date-time required
tokenstring required

Example response

{
  "id": 2,
  "name": "John Doe",
  "description": "Token to manage api",
  "scopes": [
    "api"
  ],
  "user_id": 3,
  "last_used_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
    }
  ],
  "expires_at": "2020-08-31T15:53:00.073Z"
}

Changes

No recorded changes to this operation across all 5 revisions of this API.