Skip to content

personal_tokens_create

POST
/api/personal-tokens/
curl --request POST \
--url https://example.com/api/personal-tokens/ \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "name": "example", "scopes": [ "example" ], "expires_in_days": 1 }'

Generate a new Personal Access Token.

Parameters

request : HttpRequest The request object containing user information and the token’s details.

Returns

Response A response containing the generated token’s information.

Serializer to generate a new Personal Access Token.

Parameters

name : str The name of the token to generate. scopes : list[str] The scopes granted to the token. expires_in_days : int The number of days until the token expires.

Returns

dict A dictionary containing the generated token.

Notes

The token is generated with a random secure token and contains the user’s ID, the token’s name and the scopes granted to the token. The token is valid until the expires_at date, or until revoked.

object
name
required
string
<= 255 characters
scopes
Array<string>
expires_in_days
integer
nullable >= 1 <= 365

Example generated

{
"name": "example",
"scopes": [
"example"
],
"expires_in_days": 1
}
Media typeapplication/json

Serializer to return a created Personal Access Token.

Parameters

id : int The ID of the created token. name : str The name of the created token. token : str The created token. token_preview : str A string containing the token preview. scopes : list[str] The scopes granted to the created token. created_at : datetime The date and time the token was created. expires_at : datetime | None The date and time the token expires, or None if it never expires. warning : str A warning message about the token’s expiration date.

Returns

dict A dictionary containing the created token’s information.

object
id
required
integer
name
required
string
token
required
string
token_preview
required
string
scopes
required
Array<string>
created_at
required
string format: date-time
expires_at
required
string format: date-time
nullable
warning
required
string

Example generated

{
"id": 1,
"name": "example",
"token": "example",
"token_preview": "example",
"scopes": [
"example"
],
"created_at": "2026-04-15T12:00:00Z",
"expires_at": "2026-04-15T12:00:00Z",
"warning": "example"
}