What is an API token?

With our API you can manage your servers from your own program or script, e.g. reboot servers, create snapshots, add IP addresses, and order and renew servers. You can even resell them to your own customers. Orders and renewals made with the API are paid from your balance.

A token is needed so that the API knows the request was sent by you. It is up to you what can be done with the token, and you can revoke it at any time. The program does not need the password to your account.

You can find your tokens in Settings → Authentication, in the API tokens section.

List of API tokens, the Create token buttonList of API tokens, the Create token button

How to create a token

  1. Click Create token.
  2. Enter a name so that you can recognize this token later, e.g. the name of the program that will use it.
  3. Select the scopes. If you only need to get data, click Read-only. The Full access button selects everything, including operations that use your balance.
  4. Select how long the token will work. 90 days is selected at first, but you can also choose 180 days or one year. If you select Never, the token will not expire and will work until you revoke it.
  5. If your program always works from the same address, enter this address in the Allowed IP addresses field. Enter each address on a new line, 20 addresses at most. Requests from all other addresses will be refused.
  6. Click Create token.

Creating a token with access to servers and the balanceCreating a token with access to servers and the balance

Please select only the access that you really need. A token with the billing:write scope can spend the money on your balance, so be sure to enter the allowed addresses for it. Some scopes are needed for other scopes to work and they will be selected automatically, e.g. server:read will be added together with server:power.

Save the token

The full token is shown only once, right after you create it. Click Copy and save the token in a safe place such as a password manager, as it will not be possible to see it again later. If you lose the token, create a new one and revoke the old one.

A new token that can only be copied nowA new token that can only be copied now

How to send a request

The token is sent in the Authorization header. To check that it works, you can get the list of your servers. Just replace the token in this command with your own:

curl -H "Authorization: Bearer xsc_live_YOUR_TOKEN" https://app.xserver.cloud/api/v1/servers

This token needs the server:read scope. All of the requests and their parameters are described in the documentation, which you can open with the API documentation button in the API tokens section.

If you want to know the amount before you pay, use a request with preview. There is one for orders, renewals and other paid operations. It only calculates the price and nothing is charged.

Limits

  • You can send up to 3600 requests per hour with one token.
  • With one token, you can make up to 20 operations per hour that spend your balance, i.e. orders, renewals and invoice payments. If you need more, please contact support.
  • You can’t top up the balance with the API, this can only be done in your account.

If there are too many requests, the API will respond with the code 429. The Retry-After header shows how many seconds you need to wait before sending the request again.

How to revoke a token

Click Revoke next to the token and confirm. The token will stop working right away, and the programs that use this token will lose access. A revoked token can’t be restored. Revoke the token immediately if someone else could have seen it.