Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto

Create and use API tokens

Create a read-only or read and write API token in the CloudSat console, call the REST API with it, keep it safe, and revoke it when it leaks.

CloudSat teamUpdated Nov 18, 20263 min read

API tokens let scripts, CI pipelines and other tools use the CloudSat REST API at https://cloudsat.io/api/v1 on your behalf. Each token has a name, an access level and an optional expiry date, and you can revoke it at any time. A read and write token can deploy servers that spend your balance, so treat every token like a password.

Create a token

  1. Click API tokens in the sidebar, under Access. It is also in the account menu at the top right.
  2. Click Create token (on an empty page, Create your first token).
  3. Type a Name that says where the token will live, for example ci-deploys or monitoring.
  4. Choose the Access:
    • Read only: list and inspect. Only GET requests are allowed.
    • Read and write: also deploy, power actions, rebuild, resize, snapshots, delete and SSH keys.
  5. Choose when it Expires: In 30 days, In 90 days (the default), In a year or Never.
  6. Click Create token.
  7. The card that appears says "Copy it now: it is never shown again." Click Copy next to the token and store it in your secret manager or CI secrets. A ready-made curl command is shown below it.

Tokens start with cs_live_. We store only a hash of the token, so if you lose it, create a new one.

Call the API

Send the token in an Authorization header. Keep it in an environment variable rather than in your code:

export CLOUDSAT_TOKEN="cs_live_..."
curl -s https://cloudsat.io/api/v1/account -H "Authorization: Bearer $CLOUDSAT_TOKEN"
curl -s https://cloudsat.io/api/v1/servers -H "Authorization: Bearer $CLOUDSAT_TOKEN"

A write call, such as restarting a server, needs a read and write token:

curl -s -X POST https://cloudsat.io/api/v1/servers/srv_7kq2m9xw/actions \
  -H "Authorization: Bearer $CLOUDSAT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"type":"reboot"}'

Actions run in the background and answer with a task id that you can follow. The API reference lists every endpoint, field and error. The Quick start card at the bottom of the API tokens page has more examples.

Manage your tokens

The API tokens page lists every active token with its Name, the start of the Token, its Access, when it was Last used and when it Expires.

  • Last used shows Never until the first call, and is refreshed about once a minute while the token is in use.
  • To revoke a token, click Revoke and confirm. The console answers "Token revoked. Requests with it are refused from now on." Anything that still uses it gets an error.
  • A token cannot be extended or edited. To rotate one, create its replacement, update your tools, then revoke the old token.

Creating and revoking tokens shows up on your account Activity page. Changes made through the API, such as deploys and power actions, appear there too, with API in the By column.

Errors you may see

HTTP status Message What to do
401 Send your token in an "Authorization: Bearer <token>" header. The header is missing or malformed.
401 This token is unknown, revoked or expired. Create a new token.
403 This token is read-only. Create a read and write token for this call. Use a read and write token for this request.
429 Too many requests: 120 per minute per token. Wait for the seconds given in Retry-After.

Keep tokens safe

  • Give each tool its own token, so you can revoke one without breaking the others.
  • Use Read only for dashboards, monitoring and inventory scripts.
  • Pick an expiry date for tokens used by people or short projects. Keep Never for long-lived automation that you rotate yourself.
  • Never commit a token to a repository or paste it in a ticket. If one leaks, revoke it right away.
  • A token works without your password or two-factor code. Protect the machines that hold write tokens as carefully as your account. See Turn on two-factor authentication.
  • Closing your account revokes all its tokens.

Related: Deploy a one-click app shows a deploy request, and Take a snapshot a snapshot request.