Skip to content

Create a project deploy token

POST
/api/v4/projects/{id}/deploy_tokens

Creates a project deploy token.

id
required
One of:
string

The ID or URL-encoded path of the project owned by the authenticated user

Media type application/json
object
name
required

New deploy token’s name

string
nullable
scopes
required

Indicates the deploy token scopes. Must be at least one of read_repository, read_registry, write_registry, read_package_registry, write_package_registry, read_virtual_registry, or write_virtual_registry.

Array<string>
expires_at

Expiration date for the deploy token. Does not expire if no value is provided. Expected in ISO 8601 format (2019-03-15T08:00:00Z).

string format: date-time
nullable
username

Username for deploy token. Default is gitlab+deploy-token-{n}

string
nullable
Example generated
{
"name": "example",
"scopes": [
"example"
],
"expires_at": "2026-04-15T12:00:00Z",
"username": "example"
}

Created

Media type application/json
object
id
integer format: int64
name
string
username
string
expires_at
string format: date-time
scopes
array
revoked
boolean
expired
boolean
token
string
Example
{
"id": 1,
"name": "MyToken",
"username": "gitlab+deploy-token-1",
"expires_at": "2020-02-14T00:00:00.000Z",
"scopes": [
"read_repository"
],
"token": "jMRvtPNxrn3crTAGukpZ"
}

Bad request

Unauthorized

Not found