Keeping tokens safe
How to store, scope and limit API tokens and webhook secrets, and what to do the moment one leaks.
On this page
An API token acts as you on your account, within its scopes. Treat it like a password to your servers, and give each one as little reach as the job needs.
Store it outside your code
- Keep tokens in a secret manager or an environment variable. Every example in
these docs reads
CLOUDUXE_API_KEYfor that reason. - Never commit a token, paste it into a ticket or a chat, or send it to an AI. An assistant never needs your token to write code for you.
- The token is shown once, when it is made. If you lose it, make a new one and revoke the old one.
- Keep webhook signing secrets (
cxwhsec_) the same way: anyone with one can sign fake deliveries to your endpoint.
Give it as little as it needs
- Scopes. Choose only the scopes the integration uses. A reporting job needs
services:read, notservices:destructive. See Authentication and scopes. - Elevated scopes move money, destroy data, send account data to a URL or revoke access. Give them only to the tokens that must have them. A token with one always expires, at most a year after it was made.
- Expiry. Pick the shortest expiry that fits; 90 days is the suggestion.
- Addresses. If your integration calls from fixed addresses, add them to the token's allowlist. A request from anywhere else is refused, and you are emailed once a day for each new address.
- One token per integration. Then revoking one never breaks the others, and the panel's last-used time and address tell you which system used it.
Watch for surprises
- Every new token emails the account owner, naming the token, who made it, its scopes and its expiry.
- Creating a webhook endpoint, or changing its URL, emails the owner too.
- The panel shows when and from which address each token was last used.
If any of these surprise you, revoke the token first and ask questions after.
If a token leaks
Revoke it
Revoke it in the panel at API tokens, or with
revokeApiToken. It stops working at once: the next request answers401token_revoked.Make a new one
Make a replacement with the same or fewer scopes, and update the integration.
Check what it touched
Check your services, orders and SSH keys for changes you did not expect, and check the webhook endpoints listed beside your tokens. If a webhook secret may have leaked too, rotate it with no overlap: send
oldSecretExpiresInSeconds: 0.
A token sent over plain HTTP counts as leaked. The API refuses plain HTTP, but the token still crossed the network unencrypted.