Skip to content

Create Api Token

POST
/api/v1/tokens
curl --request POST \
--url https://example.com/api/v1/tokens \
--header 'Content-Type: application/json' \
--data '{ "name": "example", "expires_in_days": 1 }'

Create a new API token. The plaintext token is only returned here.

Media typeapplication/json
ApiTokenCreate
object
name
required
Name

Human-readable label for the token, e.g. ‘CI pipeline’.

string
<= 100 characters
expires_in_days
Any of:
integer
>= 1 <= 3650

Example generated

{
"name": "example",
"expires_in_days": 1
}

Successful Response

Media typeapplication/json
ApiTokenCreated

Includes the plaintext token — only returned on creation.

object
id
required
Id

Token id.

integer
name
required
Name

Human-readable label for the token.

string
created_at
required
Created At

When the token was created.

string format: date-time
last_used_at
Any of:
string format: date-time
expires_at
Any of:
string format: date-time
token
required
Token

Plaintext bearer token, prefixed ‘ptr_’; shown only in this creation response.

string

Example generated

{
"id": 1,
"name": "example",
"created_at": "2026-04-15T12:00:00Z",
"last_used_at": "2026-04-15T12:00:00Z",
"expires_at": "2026-04-15T12:00:00Z",
"token": "example"
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object

Example generated

{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}