personal_tokens_create
const url = 'https://example.com/api/personal-tokens/';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"example","scopes":["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/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.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”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
Example generated
{ "name": "example", "scopes": [ "example" ], "expires_in_days": 1}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
Example generated
name=example&scopes=example&expires_in_days=1Serializer 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
Responses
Section titled “Responses”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
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"}
