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 workspace | Sub-workspace | |
|---|---|---|
parent_ | Not sent | The main's id, e.g. org_ |
| Card and billing details | Its own | None: uses the main's |
| Purchases charged to | Its own card | The main's card |
| Invoices | Its own; can also list all of its subs' | Its own only |
| Team | Its own | Its own; the main's owner is always its owner too |
| API v1 tokens | Work | Never: use a v2 token |
| Can have subs | Yes | No: one level only |
Create a sub-workspace with POST /workspaces and parent_ 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
Workspace: org_DemoSub1
Send the workspace id. Find it in GET /workspaces or in the app under Settings › API tokens.
| Your token covers | Header |
|---|---|
| Any number of workspaces | Required on every call (also with one workspace, so your code keeps working when the token gets more). Without it: 400 workspace_. |
| Not the workspace you named | 403 workspace_. 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
402no_; nothing is bought.payment_ method - Prices are the same in a main and its subs. They always come from
GET /productsor a quote.
In the main workspace, GET /invoices?workspace=all lists the invoices of the main and every sub-workspace, each with its workspace_.
Example: one token for an agency
The owner of org_ 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:
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" }'
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
