v1 is deprecated. Please move to API v2 (recommended). v1 keeps working until March 31, 2027, then it stops. See Moving from v1.

Get started

Authentication

Every call sends an API token in the Authorization header. A token acts as the person who made it, only in the workspaces chosen for it.

Send the token

Put the token in the Authorization header with the word Bearer in front of it:

Header
Authorization: Bearer sm_live_EXAMPLE_TOKEN

Tokens start with sm_live_. Keep them secret: anyone with a token can use it. Only call the API from your server, never from a web page.

Create a token

Workspace owners and admins create tokens in the portal at https://portal.scaledmail.com/settings/api-tokens. The full token is shown once, right after you create it. Copy it then; it can't be shown again.

  • Name: so you know later what uses it.
  • API version: pick v1. New tokens default to v2, which is a different API (https://api.scaledmail.com/v2).
  • Access: Read only, or Read and write (see below).
  • Workspaces: only this workspace, all your workspaces, or this workspace plus the ones you pick. You can also allow it to create new workspaces.
  • Expires: after 30 days, 90 days (the default), 1 year, or never.

A workspace can have up to 10 active tokens.

Read only or read and write

AccessWhat it can call
Read onlyAll GET routes, plus POST /calculate-package, POST /search-domains and POST /suggest-domains (they only look, they change nothing).
Read and writeEverything, including the routes that change data or charge your card.

A read-only token that calls a write route gets 403 missing_scope.

Which workspaces a token reaches

A token only works in the workspaces chosen for it. It also never does more than the person who made it: it works in a workspace only while that person is an owner or admin there. If they become a member of (or leave) another workspace, calls for that workspace get 401 organization_not_allowed. If that happens in the workspace the token was made in, the token stops working everywhere and every call gets 403 no_access.

GET /organizations lists the workspaces your token can use right now. A call with any other organization_id gets 401 organization_not_allowed.

A refused token keeps the same answer for up to a minute, so a change of role can take up to a minute to show.

v1 tokens and sub-workspaces

  • v1 tokens never reach sub-workspaces. A sub-workspace is not listed by GET /organizations, and a call with a sub-workspace's organization_id gets 401 organization_not_allowed. Inside a sub-workspace you can't create a v1 token.
  • To work with sub-workspaces, use API v2 with a v2 key.
  • v1 tokens and v2 keys are separate: a v2 key sent to /api/v1 gets 401 wrong_api_version, and a v1 token sent to v2 gets the same code there.
  • v1 is deprecated and keeps working until March 31, 2027.

Expiry and revoking

An expired token gets 401 token_expired. An owner or admin can revoke a token at any time in Settings › API tokens. It stops working right away and gets 401 token_revoked. This can't be undone: create a new token instead.

Errors

These answers have isAuthError: true, except missing_scope.

StatuserrorMeaning
401missing_tokenNo Authorization: Bearer <token> header, or the token is empty.
401invalid_tokenNot a token we know. Check that you copied the whole token.
401token_expiredThe token has expired.
401token_revokedThe token was revoked.
401wrong_api_versionThis is an API v2 key. Use it with API v2, or create a v1 token.
401organization_not_allowedThe token can't use the workspace in organization_id (also every sub-workspace: v1 never reaches them).
403missing_scopeThe token is read only and the route needs Read and write.
403no_accessThe person who made the token is no longer an owner or admin of the workspace the token was made in (or that workspace was deleted). The token then works nowhere.
403account_blockedThe account of the person who made the token is blocked. Contact support.
403test_mode_unavailableTest tokens (sm_test_) can't be used yet. Use a live token.
429too_many_failed_attemptsMore than 60 calls in a minute with a missing or unknown token from your address. Then every call from that address is refused, also one with a good token, until the minute is over (Retry-After: 60).