Get started

Sub-workspaces

Every order, domain and mailbox lives in a workspace. A main workspace pays for itself and for its sub-workspaces, which is how agencies run many clients from one account.

Main and sub-workspaces

Main workspaceSub-workspace
parent_idNot sentThe main's id, e.g. org_DemoWorkspace1
Card and billing detailsIts ownNone: uses the main's
Purchases charged toIts own cardThe main's card
InvoicesIts own; can also list all of its subs'Its own only
TeamIts ownIts own; the main's owner is always its owner too
API v1 tokensWorkNever: use a v2 token
Can have subsYesNo: one level only

Create a sub-workspace with POST /workspaces and parent_id set to the main. The token needs workspaces:write, Can create workspaces and to cover the main, and the person who made it must be an owner or admin of the main.

Pick a workspace for each call

Header
Workspace: org_DemoSub1

Send the workspace id. Find it in GET /workspaces or in the app under Settings › API tokens.

Your token coversHeader
Any number of workspacesRequired on every call (also with one workspace, so your code keeps working when the token gets more). Without it: 400 workspace_required.
Not the workspace you named403 workspace_not_allowed. Nothing in that workspace is read or changed.

/workspaces calls ignore the header: they list, create and read workspaces themselves.

Who pays

  • A purchase in a main workspace charges the main's saved card.
  • A purchase in a sub-workspace charges the main's saved card. The invoice is stored in the sub-workspace that bought.
  • No saved card on the paying workspace answers 402 no_payment_method; nothing is bought.
  • Prices are the same in a main and its subs. They always come from GET /products or a quote.

In the main workspace, GET /invoices?workspace=all lists the invoices of the main and every sub-workspace, each with its workspace_id.

Example: one token for an agency

The owner of org_DemoWorkspace1 makes a token that covers the main and all its subs (with Can create workspaces and Can buy), then creates a sub-workspace for a new client and orders in it:

Create the sub-workspace
curl https://api.scaledmail.com/v2/workspaces \
  -H "Authorization: Bearer sm_live_EXAMPLE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Client Acme", "parent_id": "org_DemoWorkspace1" }'
Order in it (charged to the main's card)
curl https://api.scaledmail.com/v2/orders \
  -H "Authorization: Bearer sm_live_EXAMPLE_KEY" \
  -H "Workspace: org_DemoSub1" \
  -H "Content-Type: application/json" \
  -d @order.json