Skip to content

Server tokens ​

A server token is a long-lived token for your backend.

  • It never expires.
  • It survives password changes and resets. Those delete session tokens only.
  • Each one can be revoked on its own.
  • You can hold several, for example one per environment or per service.

All three endpoints accept any valid token of the account: a session token from sign-in or an existing server token. That means a running integration can rotate its own token: create a new one, switch to it, revoke the old one.

Create a server token ​

POST /api/v1/auth/server-tokens

Body ​

FieldTypeRequiredDescription
namestringNoA label to recognise the token later. Up to 100 characters.

Example ​

bash
curl -X POST https://app.xash.co.zw/api/v1/auth/server-tokens \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"production-backend"}'

Response 201 ​

json
{
  "success": true,
  "message": "Server token created.",
  "data": {
    "id": 42,
    "name": "production-backend",
    "token": "42|EXAMPLEserverTOKENdoNOTuse0000000000000000000"
  }
}

token is returned once. It cannot be read again later. Store it as a secret. If you lose it, create another and revoke this one.

Without a name, the token is called server-token.

List server tokens ​

GET /api/v1/auth/server-tokens

Returns your server tokens, newest first. Session tokens are not listed. The secret is never returned.

json
{
  "success": true,
  "data": [
    {
      "id": 42,
      "name": "production-backend",
      "last_used_at": "2026-11-19T08:15:00.000000Z",
      "created_at": "2026-11-18T14:02:11.000000Z"
    }
  ]
}

last_used_at is null for a token that has never been used.

Revoke a server token ​

DELETE /api/v1/auth/server-tokens/{tokenId}

tokenId is the id from the list. The token stops working at once.

bash
curl -X DELETE https://app.xash.co.zw/api/v1/auth/server-tokens/42 \
  -H "Authorization: Bearer YOUR_TOKEN"
json
{
  "success": true,
  "message": "Server token revoked."
}
StatusWhenBody
404No server token of yours has this id.{"success": false, "message": "Server token not found."}

If a token leaks ​

  1. Create a new server token.
  2. Deploy it.
  3. Revoke the leaked one by id.

If you can no longer authenticate at all, sign in again with your password and start from step 1. If you have no password (your account was set up for you by Xash), write to [email protected].

Spending limits ​

Xash can cap what your server tokens may spend: a maximum per purchase and a maximum per day. The limits are set per account by Xash staff, and many accounts have none. They apply to every server token of the account together, not to each token separately, and never to session tokens.

A purchase over a limit answers 422 with LIMIT_PER_TRANSACTION or LIMIT_DAILY, and nothing is charged. GET /api/v1/limits shows your limits and what is left today. See Spending limits.

Accounts on post-paid ZESA ​

Some partners are set up by Xash to buy USD ZESA on account instead of from a prepaid balance. That arrangement applies only to requests made with a server token. See ZESA electricity.