Skip to main content

Create Auth Token

Create an auth token for a user without a token

HTTP Request

POST/api/users/auth_tokens/
NOTE: NOT USING THE TRAILING SLASH AT THE END OF THE URL RESULTS TO A 500 SERVER ERROR

Authorization

Authorization

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

Request Body

FieldTypeRequiredDescription
userIntegerYesUser 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': 42
9  }
10)

Response Fields

FieldTypeDescription
idIntegerUnique ID of the auth token(unique)
keyStringThe regenerated authentication token key(unique)
user_dataObjectInformation about the user associated with the token
created_atDateTimeTimestamp when the token was created
updated_atDateTimeTimestamp when the token was last updated (regenerated)

UserData fields

FieldTypeDescription
idIntegerUser id(unique)
usernameStringUsername of the related user(unique)
mobile_numberStringUser mobile number (unique)
first_nameStringFirst name of the user (nullable)
last_nameStringLast name of the user (nullable)

Example Response

{
"id": 8,
"key": "96425ca2693ed75c82f520a5d19d49e2db424f7b",
"user_data": {
"id": 7,
"username": "user_96f356bd56e9fcd8148bd59d8d9b1960",
"mobile_number": "09123456789",
"first_name": null,
"last_name": null
},
"created_at": "2025-11-29T13:03:31.428690Z",
"updated_at": "2025-11-29T13:03:31.428698Z"
}

Notes

  • The key field contains the actual token to use in API requests.
  • Tokens are auto-generated and cannot be customized.
  • Token creation is only possible for users without a token. Regenrating a new token is done with the regenarate endpoint