# Otobiz API and MCP

The Otobiz API lets your system or an AI agent act on one Otobiz brand: its inbox, contacts, knowledge, automations, posts, reviews and webhooks. The same operations are served three ways:

| Surface | Address | Auth |
|---|---|---|
| REST | `https://app.otobiz.ai/api/v1` | API key: `Authorization: Bearer otbz_...` |
| MCP server | `https://mcp.otobiz.ai` (streamable HTTP) | API key, or the user's Otobiz sign-in (OAuth) |
| Docs MCP server | `https://mcp.otobiz.ai/docs` | none: docs only, no brand data |

## Start in three steps

1. Create a key in Otobiz at **Developers > API** (`https://app.otobiz.ai/apikeys`). Pick the role it acts as (your own by default); it can do what a teammate with that role can do.
2. Call `GET https://app.otobiz.ai/api/v1/brands/current` with `Authorization: Bearer <key>`. It answers the brand and the scopes the key holds.
3. Read the operation you need with the docs MCP server's `get_operation`, or the OpenAPI document at `GET /api/v1/openapi.json` (needs the key).

## Rules every caller meets

- **Sends run at once, recorded.** A message, automation start, post, public reply or billing change from a key or a sign-in runs in the same call as the key's creator or the signed-in person (their role decides; billing is the owner's) and is recorded, answering the operation's own documented status and body (a message: `SendResult`, `202` while queued). Nothing holds it.
- **Consent and opt-outs hold for every send**, on every channel. A refusal is final for that request; explain it, do not retry it.
- **Errors carry a stable `code`** and a fix. Branch on `code`, never on `message`.
- **Retry writes with the same `Idempotency-Key`**, never a fresh one.

## Topics

| Page | Read it when |
|---|---|
| [Authentication](authentication.md) | Creating a key, choosing its role, signing in an AI client |
| [Scopes](scopes.md) | A `403` names a scope, or you want to know what a role or a sign-in reaches |
| [Keys and credentials](credentials.md) | Telling your key apart from channel logins, AI keys and Otobiz's own; setting a brand up |
| [Errors](errors.md) | Any `4xx` or `5xx` |
| [Pagination and filters](pagination.md) | Reading a list |
| [Idempotency and retries](idempotency.md) | Writing, or retrying after a timeout |
| [Rate limits](rate-limits.md) | A `429` or a `503` |
| [Plan and balance](billing.md) | A `402`, or how the plan, the balance and top-up pay for work |
| [Webhooks](webhooks.md) | Receiving events from Otobiz |
| [Channels](channels.md) | An operation works on some channels only |
| [MCP server](mcp.md) | Connecting an AI client |
| [MCP tools](mcp-tools.md) | Choosing a tool, or reading its approval policy |
| [Things to ask](things-to-ask.md) | You use Otobiz from Claude or ChatGPT and want to know what to ask |
| [Glossary](glossary.md) | A word such as brand, location, connection or action is unclear |

## If it fails

| Answer | What to do |
|---|---|
| Any `4xx` or `5xx` | Read `error.code` and its fix in [Errors](errors.md). Quote `requestId` when you write to support. |
| `429` or `503` | Wait `Retry-After`, then retry with the same `Idempotency-Key`. See [Rate limits](rate-limits.md). |
| Not sure a write happened | Read the resource before you repeat it. See [Idempotency and retries](idempotency.md). |
