Reset API token
Expires the requested token and creates a new token with the same permissions. The old token stops working after a short grace period. The response includes the new token value (store it securely; it is only returned once). Unless expires_at is provided, the new token expires 1 year after the reset. Pass "expires_at": null to create a token that never expires. expires_at must be in the future and no more than 5 years ahead; past or unparseable values are rejected with a 422 error. Tokens that have already expired cannot be reset (returns a 422 error).
Pass the API token in the Api-Token
API token ID
12345When the new token expires (ISO 8601 date-time, must be in the future). Must be no more than 5 years in the future. If omitted, the new token expires 1 year after the reset. Pass null to create a token that never expires. Past or unparseable values are rejected with a 422 error.
New API token (includes full token value once)
API token ID
Token display name
Last 4 characters of the token (full token is only shown on create or reset)
Name of the user or token that created this token
When the token expires (ISO 8601); null if the token does not expire
Full token value (only returned on create or reset; store securely)
Returns unauthorized error message. Check your credentials.
Returns forbidden error message. Check your permissions.
Returns not found error message
Validation error or other business rule violation
curl -X POST https://mailtrap.io/api/api_tokens/{id}/reset \
-H 'Authorization: Bearer YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"expires_at": "2027-06-01T00:00:00Z"}'
{
"id": 12345,
"name": "My API Token",
"last_4_digits": "x7k9",
"created_by": "user@example.com",
"expires_at": null,
"resources": [
{
"resource_type": "account",
"resource_id": 3229,
"access_level": 100
}
],
"token": "a1b2c3d4e5f6..."
}Last updated
Was this helpful?

