For the complete documentation index, see llms.txt. This page is also available as Markdown.

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).

post
Authorizations
Api-TokenstringRequired

Pass the API token in the Api-Token

Path parameters
idinteger · int64Required

API token ID

Example: 12345
Body
expires_atstring · date-time · nullableOptional

When 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.

Responses
200

New API token (includes full token value once)

application/json
idinteger · int64Optional

API token ID

namestringOptional

Token display name

last_4_digitsstringOptional

Last 4 characters of the token (full token is only shown on create or reset)

created_bystringOptional

Name of the user or token that created this token

expires_atstring · date-time · nullableOptional

When the token expires (ISO 8601); null if the token does not expire

tokenstringOptional

Full token value (only returned on create or reset; store securely)

post/api/api_tokens/{id}/reset
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?