> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.rasen.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.rasen.ai/_mcp/server.

# Manage the workspaces of an organisation

> With an organisation key, read the organisation, create and archive workspaces, set call-line shares and call workspace operations in each workspace.

## Summary

This guide uses an organisation key to read the organisation, create a workspace, give it call
lines, and act inside it with the workspace operations. It also reads usage, people and keys, and
archives and restores a workspace. It does not cover how to get the key; see
[Enterprise API](/enterprise/overview).

## Facts

**Access.** The Enterprise API is for Enterprise customers. To turn it on for your organisation,
contact Rasen at [`team@rasen.ai`](mailto:team@rasen.ai).

| Item             | Value                                                                                                                                                                                                |
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Access           | Enterprise customers only. Contact Rasen at [`team@rasen.ai`](mailto:team@rasen.ai). Until Rasen turns it on, every operation answers `403 organisation_api_not_enabled`                             |
| Key              | An organisation key, secret `ra_org_…`, with organisation operations on. The 4 changes need a `full_access` key                                                                                      |
| Reads            | `getOrganisation`, `listOrganisationWorkspaces`, `getOrganisationConcurrency`, `getOrganisationUsageSummary`, `listOrganisationPeople`, `listOrganisationPersonKeys`: capability `organisation.read` |
| Changes          | `createOrganisationWorkspace`, `setOrganisationWorkspaceConcurrency`, `archiveOrganisationWorkspace`, `restoreOrganisationWorkspace`: capability `organisation.manage`                               |
| Either key       | `getLimits` (`GET /limits`): capability `usage.read`                                                                                                                                                 |
| Paths            | Below `/organisations/{organisation_id}`; `getLimits` is `GET /limits`                                                                                                                               |
| Required headers | `Authorization` on every request; `Idempotency-Key` (1 to 255 characters) on the 4 changes; `Rasen-Workspace` on every workspace operation                                                           |
| Workspace name   | 1 to 200 characters. `caller_region` is `india` or `us`                                                                                                                                              |
| Call-line share  | `share` 0 to 9999, with `expected_revision` from `getOrganisationConcurrency`                                                                                                                        |
| Archive          | Rasen deletes the workspace at `delete_at`, 28 days after the archive, unless you restore it first                                                                                                   |
| Usage range      | UTC, `start` inclusive and `end` exclusive, at most 93 days. The trailing 30 days by default                                                                                                         |
| Page size        | `limit` and `cursor` on the three list operations. See [Pagination](/concepts/pagination)                                                                                                            |
| Environment      | `RASEN_API_BASE` (the base URL, ending in `/v1`), `RASEN_API_KEY` (your organisation key), `ORGANISATION_ID`, `WORKSPACE_ID`, `PERSON_ID`, `SHARE_REVISION`                                          |
| Python           | 3.10 or later, with the `httpx` package                                                                                                                                                              |
| TypeScript       | Node.js 22 or later (built-in `fetch`)                                                                                                                                                               |

Set `RASEN_API_KEY` to the organisation key. Set `ORGANISATION_ID` to the ID on **Organization
settings**, **General settings**, **Organization ID** in the Rasen app.

## Steps

### 1. Read the organisation

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]

response = httpx.get(
    f"{BASE}/organisations/{ORGANISATION_ID}", headers={"Authorization": f"Bearer {KEY}"}
)
response.raise_for_status()
print(response.json())
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID } = process.env;

const response = await fetch(`${RASEN_API_BASE}/organisations/${ORGANISATION_ID}`, {
  headers: { Authorization: `Bearer ${RASEN_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

The answer has `id`, `name`, `state`, `workspace_count` and `member_count`. It has no role and no
billing field.

### 2. List the workspaces

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces?limit=50" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]

params = {"limit": 50}
while True:
    response = httpx.get(
        f"{BASE}/organisations/{ORGANISATION_ID}/workspaces",
        headers={"Authorization": f"Bearer {KEY}"},
        params=params,
    )
    response.raise_for_status()
    page = response.json()
    for workspace in page["items"]:
        print(workspace["id"], workspace["name"], workspace["state"], workspace["concurrency_share"])
    if page["next_cursor"] is None:
        break
    params["cursor"] = page["next_cursor"]
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID } = process.env;

let cursor: string | null = null;
do {
  const query = new URLSearchParams({ limit: "50" });
  if (cursor) query.set("cursor", cursor);
  const response = await fetch(
    `${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/workspaces?${query}`,
    { headers: { Authorization: `Bearer ${RASEN_API_KEY}` } },
  );
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  const page = await response.json();
  for (const workspace of page.items) {
    console.log(workspace.id, workspace.name, workspace.state, workspace.concurrency_share);
  }
  cursor = page.next_cursor;
} while (cursor);
```

The list has every workspace of the organisation except those that Rasen is deleting, also workspaces that
are not in the key's workspace list. It has metadata only, nothing inside a workspace.

### 3. Create a workspace

**`curl`**

```bash curl
curl -sS -X POST "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{"name": "Clinic north", "caller_region": "india"}'
```

**`Python`**

```python Python
import os
import uuid

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]

response = httpx.post(
    f"{BASE}/organisations/{ORGANISATION_ID}/workspaces",
    headers={"Authorization": f"Bearer {KEY}", "Idempotency-Key": str(uuid.uuid4())},
    json={"name": "Clinic north", "caller_region": "india"},
)
response.raise_for_status()
print(response.json())
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID } = process.env;

const response = await fetch(`${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/workspaces`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${RASEN_API_KEY}`,
    "Idempotency-Key": crypto.randomUUID(),
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ name: "Clinic north", caller_region: "india" }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

The answer is `201` with the new workspace. Set `WORKSPACE_ID` to its `id`. The organisation owner
becomes the owner of the workspace. A key with a list of named workspaces does not get the new
workspace in its list; a key with all workspaces does.

### 4. Read the call-line shares

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/concurrency" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]

response = httpx.get(
    f"{BASE}/organisations/{ORGANISATION_ID}/concurrency",
    headers={"Authorization": f"Bearer {KEY}"},
)
response.raise_for_status()
shares = response.json()
print(shares["open"], shares["total"], shares["allotted"])
for workspace in shares["workspaces"]:
    print(workspace["workspace_id"], workspace["share"], workspace["revision"])
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID } = process.env;

const response = await fetch(`${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/concurrency`, {
  headers: { Authorization: `Bearer ${RASEN_API_KEY}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const shares = await response.json();
console.log(shares.open, shares.total, shares.allotted);
for (const workspace of shares.workspaces) {
  console.log(workspace.workspace_id, workspace.share, workspace.revision);
}
```

`total` is the call lines of the organisation, and `allotted` is the sum of the shares. While
`open` is `false`, you cannot set shares, and each workspace keeps the standard limit. When the
organisation has set shares, a new workspace has 0 call lines until you set its share.

### 5. Set the share of the new workspace

Set `SHARE_REVISION` to the `revision` of the new workspace in the answer of step 4.

**`curl`**

```bash curl
curl -sS -X PUT "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/concurrency" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d "{\"share\": 5, \"expected_revision\": $SHARE_REVISION}"
```

**`Python`**

```python Python
import os
import uuid

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]
WORKSPACE_ID = os.environ["WORKSPACE_ID"]
SHARE_REVISION = int(os.environ["SHARE_REVISION"])

response = httpx.put(
    f"{BASE}/organisations/{ORGANISATION_ID}/workspaces/{WORKSPACE_ID}/concurrency",
    headers={"Authorization": f"Bearer {KEY}", "Idempotency-Key": str(uuid.uuid4())},
    json={"share": 5, "expected_revision": SHARE_REVISION},
)
response.raise_for_status()
print(response.json())
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID, WORKSPACE_ID, SHARE_REVISION } = process.env;

const response = await fetch(
  `${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/workspaces/${WORKSPACE_ID}/concurrency`,
  {
    method: "PUT",
    headers: {
      Authorization: `Bearer ${RASEN_API_KEY}`,
      "Idempotency-Key": crypto.randomUUID(),
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ share: 5, expected_revision: Number(SHARE_REVISION) }),
  },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());
```

The answer has the new `share` and `revision`. The total of the organisation does not change. A
raise above the free call lines is refused with `share_above_free`; a lower share always passes,
and running calls finish.

### 6. Act inside the workspace

Every workspace operation of the [API reference](/api-reference) works with the organisation key
when `Rasen-Workspace` names the workspace. This step reads the workspace context and the rate
limits of the key in it.

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/context" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Rasen-Workspace: $WORKSPACE_ID"
curl -sS "$RASEN_API_BASE/limits" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Rasen-Workspace: $WORKSPACE_ID"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
WORKSPACE_ID = os.environ["WORKSPACE_ID"]

headers = {"Authorization": f"Bearer {KEY}", "Rasen-Workspace": WORKSPACE_ID}
for path in ("/context", "/limits"):
    response = httpx.get(f"{BASE}{path}", headers=headers)
    response.raise_for_status()
    print(path, response.json())
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, WORKSPACE_ID } = process.env;

const headers = { Authorization: `Bearer ${RASEN_API_KEY}`, "Rasen-Workspace": WORKSPACE_ID! };
for (const path of ["/context", "/limits"]) {
  const response = await fetch(`${RASEN_API_BASE}${path}`, { headers });
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  console.log(path, await response.json());
}
```

`getContext` answers with the workspace that `Rasen-Workspace` names. `getLimits` answers with
`scope` `workspace`: the numbers of the workspace and of the key in it, for each minute. Without
`Rasen-Workspace`, `getLimits` answers with `scope` `organisation`: the numbers of the organisation.

### 7. Read the usage of the organisation

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/usage/summary?start=2026-10-01T00:00:00Z&end=2026-11-01T00:00:00Z" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]

response = httpx.get(
    f"{BASE}/organisations/{ORGANISATION_ID}/usage/summary",
    headers={"Authorization": f"Bearer {KEY}"},
    params={"start": "2026-10-01T00:00:00Z", "end": "2026-11-01T00:00:00Z"},
)
response.raise_for_status()
usage = response.json()
print(usage["state"], usage["range"], usage["totals"])
for workspace in usage["workspaces"]:
    print(workspace)
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID } = process.env;

const query = new URLSearchParams({ start: "2026-10-01T00:00:00Z", end: "2026-11-01T00:00:00Z" });
const response = await fetch(
  `${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/usage/summary?${query}`,
  { headers: { Authorization: `Bearer ${RASEN_API_KEY}` } },
);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const usage = await response.json();
console.log(usage.state, usage.range, usage.totals);
for (const workspace of usage.workspaces) console.log(workspace);
```

The answer has `totals` (`minutes` and `calls`) and rows by agent, by workspace and by component.
An archived workspace counts; a workspace that Rasen is deleting does not. The answer has no cost,
currency or invoice.

### 8. List the people and the keys of a person

**`curl`**

```bash curl
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/people" \
  -H "Authorization: Bearer $RASEN_API_KEY"
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/people/$PERSON_ID/keys" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

**`Python`**

```python Python
import os

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]
PERSON_ID = os.environ["PERSON_ID"]

headers = {"Authorization": f"Bearer {KEY}"}
people = httpx.get(f"{BASE}/organisations/{ORGANISATION_ID}/people", headers=headers)
people.raise_for_status()
for person in people.json()["items"]:
    print(person["person_id"], person["name"], person["organisation_role"])

keys = httpx.get(f"{BASE}/organisations/{ORGANISATION_ID}/people/{PERSON_ID}/keys", headers=headers)
keys.raise_for_status()
for key in keys.json()["items"]:
    print(key["id"], key["name"], key["key_prefix"])
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID, PERSON_ID } = process.env;

const headers = { Authorization: `Bearer ${RASEN_API_KEY}` };
const people = await fetch(`${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/people`, { headers });
if (!people.ok) throw new Error(`HTTP ${people.status}`);
for (const person of (await people.json()).items) {
  console.log(person.person_id, person.name, person.organisation_role);
}

const keys = await fetch(
  `${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/people/${PERSON_ID}/keys`,
  { headers },
);
if (!keys.ok) throw new Error(`HTTP ${keys.status}`);
for (const key of (await keys.json()).items) console.log(key.id, key.name, key.key_prefix);
```

The people list has the Owner, each Admin, and each person with a role in a workspace, with their
workspaces and roles. Set `PERSON_ID` to a `person_id` from it. The key list has the workspace keys
that the person created: name and prefix only, never a secret. An organisation key is never listed.

### 9. Archive and restore a workspace

**`curl`**

```bash curl
curl -sS -X POST "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/archive" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
curl -sS -X POST "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces/$WORKSPACE_ID/restore" \
  -H "Authorization: Bearer $RASEN_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

**`Python`**

```python Python
import os
import uuid

import httpx

BASE = os.environ["RASEN_API_BASE"]
KEY = os.environ["RASEN_API_KEY"]
ORGANISATION_ID = os.environ["ORGANISATION_ID"]
WORKSPACE_ID = os.environ["WORKSPACE_ID"]

for action in ("archive", "restore"):
    response = httpx.post(
        f"{BASE}/organisations/{ORGANISATION_ID}/workspaces/{WORKSPACE_ID}/{action}",
        headers={"Authorization": f"Bearer {KEY}", "Idempotency-Key": str(uuid.uuid4())},
    )
    response.raise_for_status()
    print(action, response.json())
```

**`TypeScript`**

```typescript TypeScript
const { RASEN_API_BASE, RASEN_API_KEY, ORGANISATION_ID, WORKSPACE_ID } = process.env;

for (const action of ["archive", "restore"]) {
  const response = await fetch(
    `${RASEN_API_BASE}/organisations/${ORGANISATION_ID}/workspaces/${WORKSPACE_ID}/${action}`,
    {
      method: "POST",
      headers: { Authorization: `Bearer ${RASEN_API_KEY}`, "Idempotency-Key": crypto.randomUUID() },
    },
  );
  if (!response.ok) throw new Error(`HTTP ${response.status}`);
  console.log(action, await response.json());
}
```

The archive answers with `access_state`, `delete_at` and `numbers_released`. It releases the
workspace's inbound numbers and its call-line share at once, and every key of the workspace then
gets `403 workspace_archived`. The restore must come before `delete_at`. The inbound numbers and
the share do not come back: set the share again (step 5).

## Rules

* MUST send the organisation key only from a server. MUST NOT put it in browser or mobile code.
* MUST send `Rasen-Workspace` on every workspace operation. There is no default workspace.
* MUST send a new `Idempotency-Key` for each new change. To retry a lost answer, send the same key
  and the same body again.
* MUST read `getOrganisationConcurrency` before each share change, and send the `revision` of the
  workspace as `expected_revision`.
* MUST stop the running calls and campaigns of a workspace before you archive it.
* MUST keep an unknown value of `state`, `access_state`, `organisation_role` or `role`. These are
  open lists.

## Verify

```bash
curl -sS "$RASEN_API_BASE/organisations/$ORGANISATION_ID/workspaces?limit=50" \
  -H "Authorization: Bearer $RASEN_API_KEY"
```

Expected output: the new workspace is in `items`, with its `concurrency_share`.

```json
{"items": [{"id": "ws_01j00000000000000000000000", "name": "Clinic north", "state": "active", "concurrency_share": 5}], "next_cursor": null}
```

## Errors

| Code                                | Cause                                                                                                                                                        | Fix                                                                                                 |
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------- |
| `organisation_api_not_enabled`      | Rasen has not turned on the Enterprise API for the organisation. Every operation answers `403`.                                                              | Contact Rasen at [`team@rasen.ai`](mailto:team@rasen.ai). Do not retry.                             |
| `forbidden`                         | A workspace key called an organisation operation, or the organisation key lacks organisation operations or the capability (`details.required_capabilities`). | Use an organisation key with organisation operations on. Use a `full_access` key for the 4 changes. |
| `not_found`                         | The `organisation_id` is not the key's organisation, or the workspace is outside the organisation or the key's workspace list.                               | Check the ID. Use a key whose workspace list has the workspace.                                     |
| `invalid_request`                   | A workspace operation has no valid `Rasen-Workspace` (`details.field` `Rasen-Workspace`), or a field is invalid.                                             | Send the workspace ID in `Rasen-Workspace`. Fix the field that `details` names.                     |
| `workspace_limit_reached`           | The organisation has as many workspaces as its plan allows. `402` on create and restore.                                                                     | The organisation owner upgrades the plan or archives another workspace. Do not retry.               |
| `caller_region_unavailable`         | The caller region offers no language now (`details.caller_region`). `409` on create.                                                                         | Choose another `caller_region`.                                                                     |
| `workspace_busy`                    | Calls, campaigns or other work still run in the workspace (`details.kinds`). `409` on archive.                                                               | Stop the work, then archive with a new `Idempotency-Key`.                                           |
| `conflict` (`concurrency_not_open`) | Shares cannot be set yet: `open` is `false` on `getOrganisationConcurrency`. `409` on a share change.                                                        | Wait until `open` is `true`. Each workspace keeps the standard limit until then.                    |
| `conflict` (`share_above_free`)     | The raise is above the free call lines of the organisation. `409` on a share change.                                                                         | Lower another share first, or send a lower share.                                                   |
| `conflict` (`stale_share`)          | `expected_revision` is not the current `revision` of the share. `409` on a share change.                                                                     | Read `getOrganisationConcurrency` again and send the new `revision`.                                |
| `workspace_archived`                | The workspace is archived. A share change takes only `0`, and a workspace operation is refused.                                                              | Restore the workspace first.                                                                        |
| `idempotency_key_reused`            | The `Idempotency-Key` was used for another body.                                                                                                             | Send a new key for a new change.                                                                    |

## Related

* [Enterprise API](/enterprise/overview)
* [Enterprise API reference](/enterprise/api-reference)
* [Idempotency and replay](/concepts/idempotency)
* [Rate limits](/concepts/rate-limits)
* [Pagination](/concepts/pagination)