Skip to main content

Regenerate Auth Token

Regenerate an existing auth token.

HTTP Request

POST/api/users/auth_tokens/:id/regenerate

Authorization

Authorization

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

Path Parameters

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the auth token to regenerate

Example Requests

1import requests
2
3api = requests.Session()
4api.headers.update({'Authorization': 'Token f4e75eab6e0f663a972d145478d6fc4b81762070'})
5response = api.post('http://www.example.com/api/users/auth_tokens/15/regenerate/')
6print(response.json())

Status Codes

CodeDescription
200Auth token regenerated successfully
400Bad request — invalid input
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404Not found — auth token does not exist
500Internal server error

Response Fields

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

Example Response

{
"id": 15,
"user_data": {
"id": 42,
"username": "johndoe",
"email": "johndoe@example.com"
},
"key": "newlygeneratedtokenkey1234567890abcdef",
"created_at": "2023-10-01T12:34:56Z",
"updated_at": "2024-06-15T09:21:00Z"
}

Notes

  • The old token key becomes invalid immediately.
  • The updated_at timestamp reflects when the token was regenerated.
  • The token ID remains the same, only the key changes.