ServerAvatarDocs
Account

API access

Turn on your personal API token to call the ServerAvatar API from your own scripts, and see what the token can and can't do.

A personal API token lets your own scripts and tools call the Central API as you. You turn it on under Account, on the API access tab. Each account has at most one token. It never expires, and you can see it again at any time.

Anyone who has the token can use the API as you. Keep it secret.

Turn on API access

  1. Open the account menu in the top-right corner and select Account, then open the API access tab. While API access is off, the API token box says "API access is off. Your account has no API token." and the buttons are greyed out.

    The API access tab with Enable API access off and the How to use it example request

  2. Turn on Enable API access. No password is asked. You see "API access is on."

  3. The API token box now holds your token with most of its characters covered by dots. Created shows when it was made and Last used shows when a request last used it, or Never.

    The API access tab with the switch on, the hidden API token, the Created and Last used dates and the Generate new token button

  4. Click Show to see the token, or Hide to cover it again. Click Copy to copy it. The token is shown and copied with Bearer in front, as the Authorization header takes it.

Central emails you "API token created" when you turn it on. Like the other security emails it is always sent.

Use the token

Send the token in the Authorization header of every request. The How to use it panel shows an example request on your install's API address:

curl -H "Authorization: Bearer <token>" https://<api-address>/api/v1/account/profile

Replace <token> with your token and <api-address> with the address shown in that panel. See the API reference for the routes you can call.

What the token can and can't do

The personal API token has the ability api only. It can read your profile. Routes that change account settings, such as your password, two-factor authentication or API access, need a normal sign-in and refuse the token with the status 403 and the code api_token_not_allowed:

The API token cannot change account settings. Log in to the panel to do this.

Other parts of the API refuse the token in the same way. The Authentication page of the API reference lists which.

Generate a new token

Do this when the token may have leaked, or to see a fresh one.

  1. On the API access tab, click Generate new token.

  2. In the dialog Generate a new API token?, click Confirm. The dialog warns "The current token stops working right away. Update every script and tool that uses it."

    The Generate a new API token dialog with the Cancel and Confirm buttons

  3. You see "A new API token was created. The old token no longer works." Click Show or Copy to get the new token.

Central emails you "API token regenerated".

Turn off API access

  1. On the API access tab, turn off Enable API access.
  2. In the dialog Turn off API access?, click Confirm. The token stops working right away, and scripts and tools that use it fail.

You see "API access is off." Central emails you "API access turned off". Turning it on again creates a new token. The old one does not come back.

Limits

  • One token per account. It never expires and has no password check.
  • Turning it on, generating a new token and turning it off together are limited to 10 per minute.
  • A password change does not remove the token, even with Log out on all devices. See Password. Deleting your account does.

Who can do this

  • Every signed-in user can manage their own token. No organization permission is involved.
  • The token itself can't turn API access on or off, or generate a new token.
  • A request with the token is made as you. Central's other API pages say which routes accept it.

Common errors

  • API access is already on. or Turn on API access first. Your screen was out of date. Central shows "API access was changed somewhere else. Showing the current state." and refreshes it.
  • Central can't show your API token (it was saved before the security key changed). Your token still works; regenerate it to see a new one. Click Generate new token.
  • The API token cannot change account settings. Log in to the panel to do this. A script called an account route with the personal token. Use the panel instead.

On this page