Skip to main content
If your platform runs voice agents for many brands, give each brand a sub-workspace. A sub-workspace has its own agents, campaigns, calls, phone numbers, do-not-call list, knowledge bases and tools. It has no wallet, API keys or console users of its own. Its calls are paid from your workspace’s wallet at your plan’s rates, and you reach it with your own API key and one extra header. Base URL 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.
Each brand has its own do-not-call list. A number on the parent’s list or on another brand’s list is still dialled by this brand’s campaigns. When an opt-out should apply to every brand, add the number to each brand’s list. Consent and DND obligations sit with the business placing the calls; see India calling rules.

Address a sub-workspace

Send your API key as usual, and name the brand in Mirai-Workspace:
  • The value is the sub-workspace’s id or the external_id you gave it.
  • X-Workspace and Workspace are accepted as the same header. An integration that already sends workspace can keep its header name.
  • The header works on every /v2 route. The request then acts inside that brand: an agent you create belongs to the brand, and GET /v2/calls and GET /v2/phone-numbers list 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.
To place a call for the brand whose 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.
A header that names no sub-workspace of your parent answers 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 in Mirai-Workspace.

Create a sub-workspace

The answer is 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
When you already have as many active sub-workspaces as your limit allows, you get 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
This route uses standard pagination.

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.
Both answer with the workspace object. An id that is not one of your sub-workspaces answers 404 workspace_not_found.

Archive and restore

Archiving a sub-workspace stops API access to it: any request that names it in 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.
Restoring sets it back to 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

These two routes take the v1 onboarding body and answer in v1’s shape. If your code onboards brands on v1 today, point it at the v2 host and your v2 key, and keep the body. Each request creates a sub-workspace whose 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/summary counts the brand’s calls and their live time.
  • GET /v2/calls lists the brand’s calls, each with its cost_inr. Add these up over a window for the brand’s spend.
  • GET /v2/wallet shows the parent’s wallet. The balance is shared, so it is the same for every brand.
Count this month’s calls for one brand, or loop over every active brand:

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

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.