Create Api Token
POST
/api/v1/tokens
const url = 'https://example.com/api/v1/tokens';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"name":"example","expires_in_days":1}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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.
Request Bodyrequired
Section titled “Request Bodyrequired”Responses
Section titled “Responses”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
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>
ValidationErrorobject
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": {} } ]}