# API reference

> The HTTP surface by group, with the credential each route needs. Base URL https://chatwork.io or https://api.chatwork.io.

URL: https://chatwork.io/en/docs/api
Section: Reference

Credentials go in `Authorization: Bearer <key>` (also `X-Admin-Key` / `X-API-Key`). Responses are JSON with `ok` and, on failure, `error`.

## Public (no credential)

| Route | Effect |
|---|---|
| `GET /api/v1/pricing` | plan catalogue with computed quotes per plan and interval (integer halalas, VAT, yearly saving, cost per 1,000 replies) |
| `GET /api/v1/pricing/quote?replies=&interval=&plan=` | plan calculator: recommended plan for a monthly volume and each plan's quote |
| `GET /api/v1/signup/config` | signup mode, trial days, password minimum, plan ids |
| `GET /api/v1/signup/check?slug=` | workspace ID availability |
| `POST /api/v1/signup` | create a workspace, its owner and a trial; returns a member session |
| `GET /api/v1/agents` | agent catalogue without prompts |
| `GET /ready` | readiness: `200 ready` when Redis (and the database, when it is the system of record) answer; `503 not_ready` otherwise |

## Tenants (admin)

| Route | Effect |
|---|---|
| `GET /api/v1/plans` | plan catalogue |
| `GET /api/v1/tenants` | list tenants (never returns keys) |
| `POST /api/v1/tenants/onboard` | create a tenant; provisions an inbox or leaves `needs_setup`; key shown once |
| `GET/PATCH/DELETE /api/v1/tenants/{slug}` | manage a tenant |
| `POST /api/v1/tenants/{slug}/api-key/rotate` | new key shown once |
| `GET /api/v1/tenants/{slug}/public` | public widget config (no auth) |

## Conversations and control (tenant)

| Route | Effect |
|---|---|
| `GET …/chatwoot-hub?status=&page=` | paged inbox with server counts |
| `GET/POST …/conversations/{id}/messages` | read; agent reply, private note, or `use_ai` |
| `POST …/conversations/{id}/status` | `open` / `pending` / `resolved` |
| `GET/POST …/control/{id}` | ownership: `claim`, `release`, `pause` |
| `POST …/ask`, `POST …/inbound` | run the pipeline; `/inbound` mirrors to the inbox and accepts widget sessions |

## Agents and knowledge — Chatwork Router (tenant)

| Route | Effect |
|---|---|
| `GET …/cloudrag/agents` | catalogue with per-tenant enabled flags |
| `PATCH …/cloudrag/agents/{agent}` `{enabled}` | enable or disable an agent (the default agent cannot be disabled) |
| `POST …/cloudrag/route` `{text, channel_type}` | routing preview: decision, candidates, matched keywords; no model call |
| `GET/POST …/cloudrag/sources` | list; add `{kind: text\|url, title, collection, content\|url}` |
| `DELETE …/cloudrag/sources/{id}` | remove a source and its chunks |
| `GET …/cloudrag/decisions?limit=` | recent routing log and 30-day stats |

Store-backed routes answer `503 cloudrag_unavailable` without `DOT_DATABASE_URL`.

## Tickets, contacts, members, billing, connections, commerce (tenant)

`GET/POST …/tickets`, `GET/PATCH …/tickets/{id}`, `POST …/tickets/{id}/comments` · `GET …/contacts`, `GET …/contacts/{id}`, `GET …/contacts/{id}/tickets` · `POST /api/v1/auth/login`, `/auth/logout`, `GET /auth/me`, `/auth/mfa/*`, `/auth/password`, `GET/POST …/members`, `PATCH/DELETE …/members/{id}`, `POST …/members/{id}/reset` · `POST …/billing/change-plan`, `GET …/billing/subscription`, `POST …/billing/checkout`, `POST …/billing/bank-transfer`, `GET …/invoices/{id}` · `GET …/connections`, `POST …/connections/{channel}`, `POST …/connections/{channel}/test`, `DELETE …/connections/{channel}` · `GET …/commerce`, `POST …/commerce/{provider}/authorize`, `GET …/commerce/orders`.

## Platform

| Route | Effect |
|---|---|
| `GET /health` | `{status, service, version}`; detailed with the admin key |
| `GET /mcp`, `GET /.well-known/mcp.json`, `POST /mcp` | MCP discovery (public) and calls (bearer) |
| `POST /webhooks/chatwoot?token=…` | agent-bot webhook |
| `GET /api/v1/admin/events`, `…/stats`, `POST …/{id}/retry` | event inbox/outbox (admin) |
| `GET /widget.js?tenant=` | the embeddable widget |
