https://prod.voice.miraiminds.co. Sub-workspaces sit under a workspace
that has gone live, so the examples on this page use
the production address.
Sub-workspaces are off until your Mirai contact turns them on for your workspace
and sets how many you can have. Until then, creating one answers
403 sub_workspaces_disabled. You manage sub-workspaces through the API. The
console shows your own workspace only, so a brand’s agents and calls don’t
appear there.How it fits together
Your company’s live workspace is the parent. Each brand is a sub-workspace directly under it, with an id like any other workspace:ws_ followed by 24 hex
characters. Sub-workspaces go one level deep, so a sub-workspace can’t have
sub-workspaces of its own.
People sign in to the parent, and API keys belong to the parent. One key reaches
the parent and every sub-workspace under it. It can never reach a workspace
under another parent.
What a brand shares with the parent
Everything else belongs to one brand, and you see it only with that brand’s
header: its agents, campaigns and calls, its phone numbers, its do-not-call
list, its knowledge bases, and its tools and tool secrets. An agent in one brand
can’t be used for a call in another.
Address a sub-workspace
Send your API key as usual, and name the brand inMirai-Workspace:
- The value is the sub-workspace’s
idor theexternal_idyou gave it. X-WorkspaceandWorkspaceare accepted as the same header. An integration that already sendsworkspacecan keep its header name.- The header works on every
/v2route. The request then acts inside that brand: an agent you create belongs to the brand, andGET /v2/callsandGET /v2/phone-numberslist the brand’s calls and numbers. - Without the header, or with the parent’s own id in it, the request acts on the parent as before.
external_id is acme-skincare, send that
value in the header. The agent must be one of that brand’s agents; an agent from
the parent or another brand answers 404 not_found.
- cURL
- Python
- Node.js
404 workspace_not_found. One that names an archived sub-workspace answers
403 workspace_archived. See errors.
The workspace object
Manage sub-workspaces
The routes below create and change sub-workspaces. Call them with your API key alone. They act on the parent and refuse a request that names a sub-workspace inMirai-Workspace.
Create a sub-workspace
- cURL
- Python
- Node.js
201 Created with the workspace object.
If the external_id is already used, or an active sub-workspace already has the
name, you get 409 workspace_exists, and the response carries the existing
workspace next to the error. A script that timed out and retries with the same external_id can
read the brand it already made instead of creating a second one, as the code
above does. Check that external_id matches: a name clash with a different
brand returns that other brand.
409 Conflict
409 sub_workspace_limit. Archive a brand you no longer serve, or ask your
Mirai contact for a higher limit.
List sub-workspaces
200 OK
Get and update a sub-workspace
{id} is the sub-workspace’s ws_ id. To find a brand by your own id, list
with external_id.
PATCH takes name, external_id, kind, timezone, currency and
profile. Send only the fields you change. A profile you send replaces the
stored one. The uniqueness rules from create still apply, so a clash answers
409 workspace_exists.
404 workspace_not_found.
Archive and restore
Mirai-Workspace answers 403 workspace_archived. Its agents, calls and
settings are kept, and its external_id stays reserved. Archived sub-workspaces
don’t count toward your limit.
You can’t archive a brand while one of its campaigns is playing. The request
answers 409 workspace_busy. Pause or stop the campaign first,
with the brand’s header, then archive.
active. Its name must still be free among your
active sub-workspaces, or you get 409 workspace_exists, and you need room
under your limit, or you get 409 sub_workspace_limit.
Both answer with the workspace object, showing its new status.
Onboard a brand with your v1 code
kind comes from the
path. New code can call POST /v2/workspaces
directly.
200 OK
Both paths answer
200, including the Shopify path, which answered 201 on v1.
The errors are the same as for create. The v1 body has
no external_id, so a retried request with the same name answers
409 workspace_exists while the first brand is active. Set an external_id with
PATCH if you want to address the brand by
your own id.
See one brand’s usage
Send the brand’s header to the routes you already use:GET /v2/calls/summarycounts the brand’s calls and their live time.GET /v2/callslists the brand’s calls, each with itscost_inr. Add these up over a window for the brand’s spend.GET /v2/walletshows the parent’s wallet. The balance is shared, so it is the same for every brand.
- cURL
- Python
- Node.js
Coming from v1
On v1, your brands were workspaces under your organization. On v2 they are sub-workspaces under your parent workspace.
When Mirai moves your brands from v1, each brand becomes a sub-workspace whose
external_id is its v1 workspace id. The workspace header your code sends
today keeps its value; only the host and the key change. A brand you create on
v2 through the onboarding paths has no external_id, so use the workspace id
they return.
Agents, calls and webhooks have a different shape on v2.
Migrating from v1 maps each endpoint and field. Send the
brand’s header on each of those requests.
Errors
Related
Calls
Place a brand’s calls, list them and count them.
Wallet
The balance every brand spends from.
Migrating from v1
Each v1 endpoint, field and webhook on v2.
Errors
Every error code in one place.