access_tokens

List all personal access tokens

Lists all personal access tokens accessible by the authenticated user. For administrators, returns all personal access tokens in the instance. For non-administrators, returns all of their personal access tokens.

get/api/v4/personal_access_tokens

Request

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

Query parameters

user_idinteger

Filter PATs by User ID

revokedboolean

Filter tokens where revoked state matches parameter

state'active' | 'inactive'

Filter tokens which are either active or not

created_beforestring date-time

Filter tokens which were created before given datetime

created_afterstring date-time

Filter tokens which were created after given datetime

last_used_beforestring date-time

Filter tokens which were used before given datetime

last_used_afterstring date-time

Filter tokens which were used after given datetime

expires_beforestring date

Filter tokens which expire before given datetime

expires_afterstring date

Filter tokens which expire after given datetime

searchstring

Filters tokens by name

sortstring

Sort tokens

pageinteger

Current page number

per_pageinteger

Number of items per page

Response

List all personal access tokens

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

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.