Skip to content

Tokens API ​

9 endpoints. Request and response schemas are described on the schemas page; the other tags are listed in the API index.

Endpoints ​

GET /api/v1/admin/tokens ​

List all API tokens

List all API tokens across users (admin only)

Parameters

NameInTypeRequiredDescription
pagequeryintegernoMinimum: 1.
per_pagequeryintegernoMinimum: 1. Maximum: 100.

Responses

StatusDescriptionBody
200Paginated list of tokensapplication/json: object
400Invalid requestapplication/json: Error
403Admin access required-

Fields of the 200 response (application/json):

FieldTypeRequiredDescription
dataarray of AdminTokenno-
pageintegerno-
per_pageintegerno-
totalintegerno-

DELETE /api/v1/admin/tokens/{tokenId} ​

Revoke any API token

Revoke any user's API token (admin only)

Parameters

NameInTypeRequiredDescription
tokenIdpathstring (uuid)yes-

Responses

StatusDescriptionBody
204Token revoked-
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error
404Token not found-

GET /api/v1/auth/tokens ​

List own API tokens

List API tokens for the current user

Responses

StatusDescriptionBody
200List of tokensapplication/json: object
403Forbiddenapplication/json: Error

Fields of the 200 response (application/json):

FieldTypeRequiredDescription
dataarray of Tokenno-

POST /api/v1/auth/tokens ​

Create own API token

Create a new API token for the current user

Request body (required)

application/json: object

FieldTypeRequiredDescription
expires_atstring (date-time)no-
kindstringyesOne of: access, deploy.
namestringyes-
scopesarray of stringno-

Responses

StatusDescriptionBody
201Token createdapplication/json: TokenCreateResponse
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error

DELETE /api/v1/auth/tokens/{id} ​

Revoke own API token

Revoke an API token for the current user

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes-

Responses

StatusDescriptionBody
204Token revoked-
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error
404Token not found-

GET /api/v1/tokens ​

List tokens

Personal, project and federation tokens in one list, newest first. A global admin sees every token; anyone else sees their own personal tokens plus the project and federation tokens of the projects they maintain or own. Secrets are never returned and revoked tokens are not listed. A non-admin needs an interactive session (an API token gets 403). Revoke with the per-type endpoints: DELETE /api/v1/auth/tokens/{id} (own personal), DELETE /api/v1/admin/tokens/{tokenId} (admin, any personal or project token), DELETE /api/v1/projects/{project}/tokens/{tokenId} and DELETE /api/v1/repositories/{name}/federation/tokens/{tokenId}.

Parameters

NameInTypeRequiredDescription
typequerystringnoOne of: personal, project, federation.
projectquerystringnoProject name: only that project's tokens and the federation tokens of its repositories (personal tokens never match).
expires_beforequerystringnoRFC 3339 timestamp or YYYY-MM-DD date: only tokens that expire before it (already expired ones included; tokens without an expiry never match).
qquerystringnoCase-insensitive substring of the token name or owner.
pagequeryintegernoDefault: 1. Minimum: 1.
limitqueryintegernoDefault: 25. Minimum: 1. Maximum: 100.

Responses

StatusDescriptionBody
200One page of tokensapplication/json: UnifiedTokenList
400Invalid type or expires_before-
401Not authenticated-
403A non-admin API token cannot list tokens-

GET /api/v1/users/{id}/tokens ​

List user's tokens

List the active (not revoked) API tokens of a user (owner or admin)

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes-

Responses

StatusDescriptionBody
200List of tokensapplication/json: object
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error
404User not found-

Fields of the 200 response (application/json):

FieldTypeRequiredDescription
dataarray of Tokenno-

POST /api/v1/users/{id}/tokens ​

Create token for user

Create an API token for a user (admin only)

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes-

Request body (required)

application/json: object

FieldTypeRequiredDescription
expires_atstring (date-time)no-
kindstringyesOne of: access, deploy.
namestringyes-
scopesarray of stringno-

Responses

StatusDescriptionBody
201Token createdapplication/json: TokenCreateResponse
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error
404The addressed resource was not foundapplication/json: Error

DELETE /api/v1/users/{id}/tokens/{tokenId} ​

Revoke user's token

Revoke an API token for a user (admin only)

Parameters

NameInTypeRequiredDescription
idpathstring (uuid)yes-
tokenIdpathstring (uuid)yes-

Responses

StatusDescriptionBody
204Token revoked-
400Invalid request, including a NUL byte in the URL or the bodyapplication/json: Error
403Forbiddenapplication/json: Error
404Token not found-

Free software under the AGPL-3.0-or-later.