Skip to content

Pro API Tokens

Create long-lived API tokens for server-to-server integrations. Unlike JWT tokens, API tokens don't expire until revoked.

List Tokens

GET /pro/api/tokens

Request

bash
curl https://api.mail.cx/pro/api/tokens \
  -H "Authorization: Bearer tm_pro_xxxxxxxxxxxx"

Response 200

json
{
  "tokens": [
    {
      "id": "t1o2k3e4-n5i6-d7e8-9012-abcdef123456",
      "name": "Production Server",
      "last_used_at": "2025-01-15T10:30:00Z",
      "created_at": "2025-01-10T08:00:00Z",
      "revoked_at": null
    },
    {
      "id": "t2o3k4e5-n6i7-d8e9-0123-bcdef2345678",
      "name": "Staging",
      "last_used_at": null,
      "created_at": "2025-01-12T14:00:00Z",
      "revoked_at": "2025-01-14T09:00:00Z"
    }
  ]
}
FieldTypeDescription
iduuidToken ID
namestringDisplay name
last_used_atstring?Last time the token was used (null if never)
created_atstringCreation timestamp
revoked_atstring?Revocation timestamp (null if active)

Create a Token

POST /pro/api/tokens

Request

bash
curl -X POST https://api.mail.cx/pro/api/tokens \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Production Server"}'
FieldTypeRequiredDescription
namestringYesDisplay name for the token

Response 201

json
{
  "id": "t1o2k3e4-n5i6-d7e8-9012-abcdef123456",
  "name": "Production Server",
  "token": "tm_pro_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456"
}

WARNING

The token value is only shown once at creation. Copy and store it securely — it cannot be retrieved later.

Usage

Use the token in the Authorization header for any Pro endpoint:

bash
curl https://api.mail.cx/pro/api/accounts \
  -H "Authorization: Bearer tm_pro_aBcDeFgHiJkLmNoPqRsTuVwXyZ123456"

Revoke a Token

DELETE /pro/api/tokens/{id}

Immediately invalidates the token. Any requests using this token will receive 401.

Request

bash
curl -X DELETE https://api.mail.cx/pro/api/tokens/t1o2k3e4-... \
  -H "Authorization: Bearer tm_pro_xxxxxxxxxxxx"

Response 204

No content. The token is permanently revoked.

Mail.cx API Documentation