# REST API

> Everything the console does goes through a REST API. Where its reference lives, how requests are authorized and how to pick a workspace.

The console is built on the same REST API you can use. Every route, parameter and response is listed in the interactive [API reference](https://nomongeta.zenhalab.com/api/nomongeta/docs), generated from the code, so it is always current.

## Base URL

All routes live under:

```text
https://nomongeta.zenhalab.com/api/nomongeta/v1
```

The machine-readable OpenAPI 3.1 document is at `https://nomongeta.zenhalab.com/api/nomongeta/openapi.json`. Import it into Postman, Insomnia or a code generator.

## Authorization

Requests run as a signed-in person, with the session your browser gets when you sign in, and can do exactly what that person can do in the console.

> [!IMPORTANT]
> Requests that change something (`POST`, `PUT`, `PATCH`, `DELETE`) are only accepted from pages on this same site. Reading works from any tool that sends your session.

## Choosing a workspace

Every route acts in one workspace:

1. the workspace in the `x-workspace-id` header, when you send one;
2. otherwise the workspace you last chose in the console;
3. otherwise your personal workspace.

`GET /api/nomongeta/v1/workspaces` lists the workspaces you can open, with their ids. A workspace you can't open, and any id that belongs to another workspace, answers `404`.

```js
const res = await fetch("/api/nomongeta/v1/agents", {
  headers: { "x-workspace-id": "<workspace id>" },
});
const agents = await res.json();
```

## Roles

Each route needs a minimum role in the workspace. The reference shows it on every route as `x-required-role`.

| Role | In the API | Can |
| --- | --- | --- |
| Viewer | `viewer` | Sees the agents and their numbers. Read-only. |
| Agent | `agent` | Reads conversations and answers handoffs. Can't change agents. |
| Builder | `builder` | Builds agents, skills and knowledge, and tests them in the playground. |
| Admin | `admin` | Members and channels, plus everything a builder does. |
| Owner | `owner` | Everything, including members, billing and the workspace itself. |

## Errors worth knowing

| Status | Meaning |
| --- | --- |
| `402 billing_hold` | The workspace's subscription is unpaid past its grace period. Only billing routes answer. |
| `403 workspace_suspended` | The workspace, or the agency it belongs to, is suspended. |
| `404` | Not found, or not in this workspace. |
| `422` | Publishing a flow that still has errors. |
| `429` | Too many writes from your address (`rate_limited`: wait the seconds in `Retry-After`), or a plan limit reached (`agent_limit`, `flow_limit`, `connection_limit` …). |
| `503` | The platform is in maintenance: reads work, writes wait. |

## Limits

Writes (`POST`, `PUT`, `PATCH`, `DELETE`) are limited to 240 a minute from one IP address; reads aren't limited. Your plan's limits apply as they do in the console: creating more agents, flows or channels than it allows answers `429` with the limit reached. See [plans and limits](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/billing/plans-and-limits).

## What's only in the API

- The [vault of secrets](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/secrets-and-contacts#secrets) your flows sign in with.
- [Contacts](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/secrets-and-contacts#contacts): listing, searching and erasing them.

See also [calling your systems from a flow](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/webhooks) and the [widget reference](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/developers/widget).

> [!TIP]
> Connecting other software (a CRM, Zapier, a script on a server)? Use the [integration API](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/api) instead: it works with [API keys](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/api-keys) and scopes, and sends [events](https://nomongeta.zenhalab.com/www/nomongeta/en/docs/integrations/events) as webhooks.
