Skip to main content

Create Auth Token

Create a new auth token.

HTTP Request

POST/api/users/auth_tokens

Authorization

Authorization

  • Required: Yes
  • Permission: Staff or Admin
  • Authentication: Token-based (Authorization: Token <your_api_key>)

Request Body

FieldTypeRequiredDescription
user_idIntegerYesUser ID to create the auth token for

Example Requests

1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.post(
6  'http://www.example.com/api/users/auth_tokens/',
7  json={
8      'user_id': 42
9  }
10)

Status Codes

CodeDescription
201Auth token created successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
500Internal server error

Response Fields

FieldTypeDescription
idIntegerUnique ID of the authentication token.
keyStringThe authentication token string.
user_dataObjectUser information associated with token.
created_atString (ISO 8601)Timestamp when token was created.
updated_atString (ISO 8601)Timestamp when token was last updated.

Example Response

{
"id": 1,
"key": "f4e75eab6e0f663a972d145478d6fc4b81762070",
"user_data": {
"id": 42,
"username": "johndoe",
"full_name": "John Doe",
"email": "johndoe@example.com"
},
"created_at": "2023-10-01T12:34:56Z",
"updated_at": "2023-10-01T12:34:56Z"
}

Notes

  • The key field contains the actual token to use in API requests.
  • Tokens are automatically generated and cannot be customized.