{"openapi":"3.1.0","info":{"title":"Omazy Core API","version":"2026-11-20","description":"The Core API lets your own backend use an Omazy workspace: call a model, search and manage the agent's knowledge, run the agent, speak and transcribe, place phone calls, read and update customers, and post into conversations.\n\nEvery request carries a bearer token of the form `cai_<prefix>.<rest>`. The workspace is read from the token and is never sent in a request.\n\nJSON responses use one envelope: `{\"success\": true, \"data\": {...}}` on success and `{\"success\": false, \"error\": {\"code\": \"...\", \"message\": \"...\"}}` on failure. Branch on `error.code`. Log `error.message` and the `X-Request-Id` response header.\n\nTwo refusals come from the workspace and apply to every route: `403 WORKSPACE_INACTIVE` when the workspace is suspended or closed, and `402 SUBSCRIPTION_PAUSED` when its subscription is paused.\n\nRate limits are counted per token over a sliding window of 10 minutes. Model, agent, speech and voice job calls share one bucket. Knowledge reads and knowledge writes each have their own. Each of these buckets holds ten times the plan's calls per minute. Call placement is 30 per 10 minutes on every plan. A limited route reports where the token stands in the `X-RateLimit-*` response headers.\n\nA request that changes something can be made safe to send again. Send an `Idempotency-Key` header, a name you choose for the request, on the routes that list it. The first request that succeeds is remembered for 24 hours, and a repeat with the same key gets that answer back with `Idempotent-Replayed: true` and runs nothing. A request that fails is not remembered, so the retry runs. Keys are kept per token."},"servers":[{"url":"https://mw.omazy.ai/api/v1/core"}],"security":[{"CoreToken":[]}],"tags":[{"name":"Account","description":"Check a token and read what the workspace's plan allows."},{"name":"Models","description":"Model completions through the gateway, whole or streamed."},{"name":"Knowledge","description":"Search the agent's knowledge base, manage its documents and sources, and export what changed."},{"name":"Agent","description":"Run one turn of the workspace's own agent."},{"name":"Speech","description":"Turn text into speech and a short recording into text."},{"name":"Calls","description":"Place outbound phone calls answered by the agent, and read their outcome."},{"name":"Voice jobs","description":"Transcribe long recordings and write meeting notes in the background."},{"name":"Data","description":"Read and update customers, and post messages into conversations."},{"name":"Channels","description":"Publish to a connected page channel."},{"name":"Sessions","description":"Bind a signed-in user's own tool credential to their conversation."},{"name":"MCP","description":"The same routes as tools on a Model Context Protocol server."},{"name":"Usage","description":"What the workspace used and what it cost, per day."}],"paths":{"/whoami":{"get":{"operationId":"whoami","tags":["Account"],"summary":"Check a token","description":"Returns the workspace the token belongs to, the scopes it holds, when it expires and what the workspace's plan allows. Works with any valid token: no scope is needed. Use it in a health check, and when a call is refused and you want to see the scopes the token holds. `plan` is left out when the plan cannot be read.","responses":{"200":{"description":"The token's context.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Whoami"}}},"example":{"success":true,"data":{"install_id":"0d6c3a7e-3f3f-4b1b-9d0c-1f5a2f1c9a11","workspace_id":"5b0c1c5e-8f0e-4a55-9a51-2f6d1f3f6a10","app_slug":"backoffice","scopes":["ai:complete","kb:search"],"status":"active","token":"current","token_expires_at":"2027-02-17T12:14:11Z","plan":{"sku":"free","rate_per_minute":60,"ai_turns":{"used":412,"limit":6000,"resets_at":"2026-12-07T10:40:52Z"},"voice_minutes":{"used":37,"limit":2000,"resets_at":"2026-12-07T10:40:52Z"}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/ai/complete":{"post":{"operationId":"aiComplete","tags":["Models"],"summary":"Run a model completion","x-omazy-scope":"ai:complete","description":"One model call through the gateway. Scope: `ai:complete`. You send the conversation and get the text and the token counts back. Nothing is stored between calls.\n\nWhich model runs: with nothing named, the model profile the app's agent answers on. `profile` names another model profile, and an unknown name is a `400`. `model` names a model, and one the workspace may not use is a `403 FORBIDDEN` with a message naming the model.\n\nTools: describe them in `tools`. When the model wants one, the reply carries `tool_calls`. Run the tool yourself, then call again with the whole conversation: the assistant turn as it came back and a user turn holding your `tool_results`.\n\nStreaming: with `stream: true` the reply is Server-Sent Events (`text/event-stream`). A `delta` frame carries `{\"text\": \"...\"}`, the next piece of the reply. A `done` frame is sent once, last, and carries the full result: the same object a non-streamed call returns in `data`, without the envelope. An `error` frame is sent once, last, in place of `done`. It carries `{\"code\": \"...\", \"message\": \"...\", \"request_id\": \"...\"}`: the same `code` values a refused call carries, so branch on it the same way. Only text streams: tool calls arrive complete in the `done` frame. A refusal before the stream starts is the usual status code and error envelope. A failure after the stream starts is an `error` frame on a `200`.\n\nResponse cache: the AI gateway can answer a byte-identical request with the reply it stored for it, without calling the model. `cache_ttl` is your say over that for this call: leave it out for the gateway's own setting, send `0` for a reply that never comes from the cache (any request that carries live data, such as a booking or a calendar read), or 60 to 2592000 seconds to bound how long a stored reply may be served again. The cache keys on the whole request, so a change in the prompt, the knowledge passages or a tool result is a new request. A reply from the cache says `cache_hit: true`, costs nothing and uses no AI turn.\n\nAn answered call uses one of the plan's AI turns. When they are used up the route answers `402 PLAN_LIMIT_REACHED`. The call has 120 seconds. Rate limit: the AI and speech bucket, sized by the plan.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CompleteRequest"},"example":{"system":"You are a support engineer. Answer briefly.","messages":[{"role":"user","content":"Our export job fails at midnight. Why?"}],"max_tokens":600,"temperature":0.2}}}},"responses":{"200":{"description":"The model's reply. JSON by default, Server-Sent Events when the request set `stream: true`.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/CompleteResult"}}},"example":{"success":true,"data":{"text":"The job starts before the nightly backup releases its lock.","stop_reason":"stop","model":"openai/gpt-4o","usage":{"input_tokens":41,"output_tokens":14,"cached_input_tokens":0}}}},"text/event-stream":{"schema":{"type":"string","description":"Frames of the form `event: <name>` and `data: <json>`, separated by a blank line. Events: `delta`, then one `done` or one `error`."},"example":"event: delta\ndata: {\"text\":\"The job starts \"}\n\nevent: delta\ndata: {\"text\":\"before the nightly backup releases its lock.\"}\n\nevent: done\ndata: {\"text\":\"The job starts before the nightly backup releases its lock.\",\"stop_reason\":\"stop\",\"model\":\"openai/gpt-4o\",\"usage\":{\"input_tokens\":41,\"output_tokens\":14,\"cached_input_tokens\":0}}\n\n"}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/knowledge/search":{"post":{"operationId":"knowledgeSearch","tags":["Knowledge"],"summary":"Search the knowledge base","x-omazy-scope":"kb:search","description":"Returns passages from the knowledge base of the app's agent, with the same retrieval that grounds the agent's replies in chat. Scope: `kb:search`. The agent is the app's published agent, or its newest draft when nothing is published. An app with no agent answers `404`. No match is not an error: the answer is `200` with an empty `passages` array. The search has 60 seconds. Rate limit: the knowledge read bucket, sized by the plan.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KnowledgeSearchRequest"},"example":{"query":"How long do refunds take?","top_k":3}}}},"responses":{"200":{"description":"The matching passages.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeSearchResult"}}},"example":{"success":true,"data":{"passages":[{"document_id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","title":"Refund policy","content":"Refunds are returned to the original payment method within 7 working days.","language":"en","score":0.83}]}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/knowledge/documents":{"get":{"operationId":"knowledgeDocumentsList","tags":["Knowledge"],"summary":"List knowledge documents","x-omazy-scope":"kb:read","description":"Lists the documents of the agent's knowledge base, newest first, with how indexing of each stands. Scope: `kb:read`. `content` and `data` are left out: read one document to get them. The call has 90 seconds. Rate limit: the knowledge read bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/AppQuery"},{"name":"cursor","in":"query","required":false,"description":"The `next_cursor` of the previous page.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Documents per page. A higher value is lowered to 200.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}}],"responses":{"200":{"description":"One page of documents.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/DocumentPage"}}},"example":{"success":true,"data":{"documents":[{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","kind":"text","title":"Refund policy","source_url":"https://www.example.com/refunds","language":"en","is_active":true,"index":{"status":"ready","indexed_at":"2026-11-19T09:30:04Z","chunks":1,"tokens":18},"version":128,"created_at":"2026-11-19T09:30:00Z","updated_at":"2026-11-19T09:30:00Z"}],"next_cursor":"","version":128}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"post":{"operationId":"knowledgeDocumentsCreate","tags":["Knowledge"],"summary":"Add a knowledge document","x-omazy-scope":"kb:write","description":"Adds a document to the agent's knowledge base and queues it for indexing. Scope: `kb:write`. The agent can use the document once its `index.status` is `ready`. A document needs `content` or `data`. Sending a document that already exists in every field returns the existing one, so a retried request does not make a second copy. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentCreateRequest"},"example":{"title":"Refund policy","content":"Refunds are returned to the original payment method within 7 working days.","source_url":"https://www.example.com/refunds","language":"en"}}}},"responses":{"201":{"description":"The document, queued for indexing.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeDocument"}}},"example":{"success":true,"data":{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","kind":"text","title":"Refund policy","source_url":"https://www.example.com/refunds","language":"en","is_active":true,"content":"Refunds are returned to the original payment method within 7 working days.","index":{"status":"queued","indexed_at":null,"chunks":0,"tokens":0},"version":0,"created_at":"2026-11-19T09:30:00Z","updated_at":"2026-11-19T09:30:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailableOrKeyNotChecked"},"504":{"$ref":"#/components/responses/GatewayTimeout"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}]}},"/knowledge/documents/{id}":{"get":{"operationId":"knowledgeDocumentsGet","tags":["Knowledge"],"summary":"Read a knowledge document","x-omazy-scope":"kb:read","description":"Reads one knowledge document with its content and its index status. Scope: `kb:read`. The call has 90 seconds. Rate limit: the knowledge read bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/DocumentId"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The document.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeDocument"}}},"example":{"success":true,"data":{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","kind":"text","title":"Refund policy","source_url":"https://www.example.com/refunds","language":"en","is_active":true,"content":"Refunds are returned to the original payment method within 7 working days.","index":{"status":"ready","indexed_at":"2026-11-19T09:30:04Z","chunks":1,"tokens":18},"version":128,"created_at":"2026-11-19T09:30:00Z","updated_at":"2026-11-19T09:30:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"patch":{"operationId":"knowledgeDocumentsUpdate","tags":["Knowledge"],"summary":"Change a knowledge document","x-omazy-scope":"kb:write","description":"Changes the fields it is given and queues the document for indexing again. Scope: `kb:write`. Fields left out are kept. A body with nothing to change is a `400`. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/DocumentId"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentUpdateRequest"},"example":{"content":"Refunds are returned to the original payment method within 5 working days."}}}},"responses":{"200":{"description":"The changed document, queued for indexing.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeDocument"}}},"example":{"success":true,"data":{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","kind":"text","title":"Refund policy","source_url":"https://www.example.com/refunds","language":"en","is_active":true,"content":"Refunds are returned to the original payment method within 5 working days.","index":{"status":"queued","indexed_at":null,"chunks":0,"tokens":0},"version":0,"created_at":"2026-11-19T09:30:00Z","updated_at":"2026-11-19T10:05:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"delete":{"operationId":"knowledgeDocumentsDelete","tags":["Knowledge"],"summary":"Delete a knowledge document","x-omazy-scope":"kb:write","description":"Deletes a document and removes its passages from search. Scope: `kb:write`. The agent stops using it. This cannot be undone. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/DocumentId"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The document was deleted.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/DocumentDeleted"}}},"example":{"success":true,"data":{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","deleted":true}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/knowledge/import":{"post":{"operationId":"knowledgeImportFile","tags":["Knowledge"],"summary":"Import a file as a knowledge document","x-omazy-scope":"kb:write","description":"Turns one file into a document: a PDF, a spreadsheet, an image or text. Scope: `kb:write`. The text is extracted, stored as a `text` document titled with the file's name, and queued for indexing. Send the file as the raw request body and name it with `filename`, or send a `multipart/form-data` form with the file in a part named `file`. The file is at most 20 MB. A file no text can be extracted from is a `400`. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"filename","in":"query","required":false,"description":"The file's name, with its extension. Required when the file is the raw request body. A multipart upload uses the name of its `file` part.","schema":{"type":"string","maxLength":255},"example":"refund-policy.pdf"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"description":"The file. With a raw body, the `Content-Type` header and the file's extension decide how it is read: PDF, spreadsheet (`.xlsx`, `.xls`), image (`image/*`), and text for anything else.","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}},"application/pdf":{"schema":{"type":"string","format":"binary"}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary","description":"The file."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app. The `app` query parameter is read first."}}}}}},"responses":{"201":{"description":"The document made from the file, queued for indexing.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeDocument"}}},"example":{"success":true,"data":{"id":"01JD3K2R7N5P8S1L4U6Y9A0D2F","kind":"text","title":"refund-policy.pdf","source_url":"refund-policy.pdf","language":"en","is_active":true,"content":"Refunds are returned to the original payment method within 7 working days.","index":{"status":"queued","indexed_at":null,"chunks":0,"tokens":0},"version":0,"created_at":"2026-11-19T09:30:00Z","updated_at":"2026-11-19T09:30:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailableOrKeyNotChecked"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/knowledge/sources":{"get":{"operationId":"knowledgeSourcesList","tags":["Knowledge"],"summary":"List knowledge sources","x-omazy-scope":"kb:read","description":"Lists the websites the agent's knowledge is crawled from, newest first, with the state of each crawl. Scope: `kb:read`. The call has 90 seconds. Rate limit: the knowledge read bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The agent's sources.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/SourceList"}}},"example":{"success":true,"data":{"sources":[{"id":"4e8a1c7d-2b5f-4d9a-a3c6-7f1e0b9d8c2a","kind":"website","root_url":"https://www.example.com","status":"ready","crawler":"native","schedule":null,"config":{"max_pages":50,"max_depth":2},"stats":{},"last_error":null,"last_crawled_at":"2026-11-19T09:41:12Z","created_at":"2026-11-19T09:30:00Z"}]}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"post":{"operationId":"knowledgeSourcesCreate","tags":["Knowledge"],"summary":"Crawl a website into knowledge","x-omazy-scope":"kb:write","description":"Adds a website as a knowledge source and queues its first crawl. Scope: `kb:write`. Each page becomes a document. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SourceCreateRequest"},"example":{"root_url":"https://www.example.com","max_pages":50,"max_depth":2}}}},"responses":{"201":{"description":"The source, with its first crawl queued.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeSource"}}},"example":{"success":true,"data":{"id":"4e8a1c7d-2b5f-4d9a-a3c6-7f1e0b9d8c2a","kind":"website","root_url":"https://www.example.com","status":"queued","crawler":"native","schedule":null,"config":{"max_pages":50,"max_depth":2},"stats":{},"last_error":null,"last_crawled_at":null,"created_at":"2026-11-19T09:30:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}]}},"/knowledge/sources/{id}/crawl":{"post":{"operationId":"knowledgeSourcesCrawl","tags":["Knowledge"],"summary":"Crawl a source again","x-omazy-scope":"kb:write","description":"Queues a fresh crawl of a knowledge source, to pick up what changed on the website. Scope: `kb:write`. The body is optional. The call has 90 seconds. Rate limit: the knowledge write bucket, sized by the plan. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"description":"The source's id.","schema":{"type":"string","format":"uuid"},"example":"4e8a1c7d-2b5f-4d9a-a3c6-7f1e0b9d8c2a"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":false,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CrawlRequest"},"example":{"app":"nordwell"}}}},"responses":{"202":{"description":"The crawl was queued.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/CrawlQueued"}}},"example":{"success":true,"data":{"id":"4e8a1c7d-2b5f-4d9a-a3c6-7f1e0b9d8c2a","queued":true}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/knowledge/export":{"get":{"operationId":"knowledgeExport","tags":["Knowledge"],"summary":"Export knowledge changes","x-omazy-scope":"kb:read","description":"Returns the documents that changed after `since`, each with the passages search uses, so you can keep your own copy. Scope: `kb:read`. Without `since` it returns every indexed document, which is how a copy is first built. Keep the `version` of the answer and pass it as `since` next time. Follow `next_cursor` until it is empty. When `resync` is `true`, drop your copy and export again without `since`. The call has 90 seconds. Rate limit: the knowledge read bucket, sized by the plan.","parameters":[{"name":"since","in":"query","required":false,"description":"The `version` an earlier export returned.","schema":{"type":"integer","minimum":0},"example":120},{"name":"cursor","in":"query","required":false,"description":"The `next_cursor` of the previous page.","schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"description":"Documents per page. A higher value is lowered to 200.","schema":{"type":"integer","minimum":1,"maximum":200,"default":50}},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"One page of changes.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/KnowledgeExport"}}},"example":{"success":true,"data":{"version":128,"documents":[{"id":"01JD3K8Z6Q4X9T2M5V7W0B1C3E","kind":"text","title":"Refund policy","source_url":"https://www.example.com/refunds","language":"en","is_active":true,"version":128,"updated_at":"2026-11-19T09:30:00Z","chunks":[{"ordinal":0,"text":"Refunds are returned to the original payment method within 7 working days.","tokens":18,"checksum":"3b7e0c5d9a1f4e62"}]}],"deleted":[{"id":"01JD3K2R7N5P8S1L4U6Y9A0D2F","version":126}],"resync":false,"next_cursor":""}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/agent/turn":{"post":{"operationId":"agentTurn","tags":["Agent"],"summary":"Run one turn of the agent","x-omazy-scope":"agent:run","description":"One message in, one reply out, produced the way the app's agent produces it: its brief, knowledge base, guided flows and connected tools all take part. Scope: `agent:run`. The agent is the app's published agent, or its newest draft when nothing is published. An app with no agent answers `404`.\n\nThe caller keeps the conversation. Nothing is stored between turns: the agent sees the `history` you send and the new `message`. `session_id` labels the turns of one conversation and does not bring earlier turns back.\n\nContext: `context` is where the person is, one JSON object of at most 2048 bytes, the same object a widget page sends to the session's `/context`. The agent reads it as a hint from the caller, flattened, cleaned and capped: never as an instruction or a permission. `{\"interaction\": \"voice\"}` makes the agent answer for the ear.\n\nStreaming: with `stream: true` the reply is Server-Sent Events, with the frames of a streamed completion. A `delta` frame carries `{\"text\": \"...\"}`, the next piece of the reply, with the agent's reply markup (quick replies, images) held back. A `done` frame is sent once, last, and carries the whole turn: the same object a non-streamed turn returns in `data`. Keep the text from `done`; the deltas are for showing and speaking early. An `error` frame is sent once, last, in place of `done`, with `code`, `message` and `request_id`. When the agent's own settings turn streaming off or redaction on, no `delta` is sent and `done` carries the turn. An agent with connected tools sends its whole reply in one `delta` for now, whether or not it calls a tool on that turn: its tool loop does not stream a turn made through this route yet. The pieces arrive as they are written only for an agent without tools. A turn a guided flow answered also arrives as one piece.\n\nAn answered turn uses one of the plan's AI turns. When they are used up the route answers `402 PLAN_LIMIT_REACHED`. The turn has 120 seconds. Rate limit: the AI and speech bucket, sized by the plan. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing. A streamed answer is not kept for a repeat.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentTurnRequest"},"example":{"session_id":"2f1c7c1e-0a5e-4a4f-9d55-7a2f3f0f8c11","message":"And how much is it?","history":[{"role":"user","text":"Do you deliver on Fridays?"},{"role":"assistant","text":"Yes. Friday deliveries run from 10am to 6pm."}]}}}},"responses":{"200":{"description":"The agent's reply. JSON by default, Server-Sent Events when the request set `stream: true`.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/AgentTurnResult"}}},"example":{"success":true,"data":{"session_id":"2f1c7c1e-0a5e-4a4f-9d55-7a2f3f0f8c11","text":"Friday delivery costs the same as any other day.","quick_replies":["Delivery charges","Track my order"],"sources":2,"model":"openai/gpt-4o","usage":{"input_tokens":1840,"output_tokens":22,"cached_input_tokens":0}}}},"text/event-stream":{"schema":{"type":"string","description":"Frames of the form `event: <name>` and `data: <json>`, separated by a blank line. Events: `delta`, then one `done` or one `error`."},"example":"event: delta\ndata: {\"text\":\"Yes. Friday deliveries \"}\n\nevent: delta\ndata: {\"text\":\"run from 10am to 6pm.\"}\n\nevent: done\ndata: {\"session_id\":\"2f1c7c1e-0a5e-4a4f-9d55-7a2f3f0f8c11\",\"text\":\"Yes. Friday deliveries run from 10am to 6pm.\",\"quick_replies\":[\"Book a delivery\"],\"sources\":2,\"model\":\"openai/gpt-4.1-mini\",\"usage\":{\"input_tokens\":5480,\"output_tokens\":14,\"cached_input_tokens\":1792}}\n\n"}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}]}},"/voice/speak":{"post":{"operationId":"voiceSpeak","tags":["Speech"],"summary":"Read text aloud","x-omazy-scope":"voice:speech","description":"Speaks the text in the app's own voice and returns the audio. Scope: `voice:speech`. Markdown and links are cleaned out before the text is read. On success the body is not JSON: it is a WAV file, 16-bit PCM, mono, 24000 Hz. On failure the answer is the usual error envelope, so check the status before you treat the body as sound. The call has 60 seconds. Rate limit: the AI and speech bucket, sized by the plan. The route draws on the plan's voice minutes. When they are used up it answers `402 PLAN_LIMIT_REACHED`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SpeakRequest"},"example":{"text":"Your order has shipped and arrives on Thursday."}}}},"responses":{"200":{"description":"The audio.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"X-Omazy-Speech-Lang":{"$ref":"#/components/headers/X-Omazy-Speech-Lang"}},"content":{"audio/wav":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/voice/transcribe":{"post":{"operationId":"voiceTranscribe","tags":["Speech"],"summary":"Transcribe a recording","x-omazy-scope":"voice:speech","description":"Turns one recorded clip into text. Scope: `voice:speech`. The request body is the audio file itself: not JSON and not a form upload. It is at most 8 MB (8388608 bytes). The format is detected from the audio, and the `Content-Type` header is not read. Pass `terms` so names come back spelled right. This route is for a short clip, and it answers only after the whole clip is heard: about 4 s for a 5.5 s clip. To get the text as the person stops speaking, stream the audio while they speak on `GET /voice/transcribe/stream`. For a long recording, create a voice job. The call has 60 seconds. Rate limit: the AI and speech bucket, sized by the plan. The route draws on the plan's voice minutes. When they are used up it answers `402 PLAN_LIMIT_REACHED`.","parameters":[{"name":"lang","in":"query","required":false,"description":"The language to expect first. Other values are ignored.","schema":{"type":"string","enum":["en","bn"]},"example":"en"},{"name":"terms","in":"query","required":false,"description":"Vocabulary hints: names and words the recognizer should expect, such as staff names or a brand. Comma-separated, or repeat the parameter. At most 200 terms of at most 100 bytes each; more is refused with 400, never cut short.","schema":{"type":"string"},"example":"Rashed Karim,Betopia"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"description":"The audio bytes.","content":{"application/octet-stream":{"schema":{"type":"string","format":"binary"}},"audio/webm":{"schema":{"type":"string","format":"binary"}},"audio/ogg":{"schema":{"type":"string","format":"binary"}},"audio/wav":{"schema":{"type":"string","format":"binary"}}}},"responses":{"200":{"description":"The transcript.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Transcription"}}},"example":{"success":true,"data":{"text":"Where is my order?","language":"en"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/voice/transcribe/stream":{"get":{"operationId":"voiceTranscribeStream","tags":["Speech"],"summary":"Transcribe live audio (WebSocket)","x-omazy-scope":"voice:speech","x-omazy-websocket":true,"description":"Live speech to text over a WebSocket. Scope: `voice:speech`. Send the GET as a WebSocket upgrade with the same `Authorization: Bearer` header as every Core call. The install token never goes to a browser: a browser or app streams to your own backend, which relays to this route.\n\n**Frames from you.** The first frame is text: `{\"type\":\"start\",\"language\":\"bn\",\"terms\":[\"Rashed Karim\"],\"audio_format\":\"pcm_s16le\",\"sample_rate\":16000,\"num_channels\":1}`. `language` is the language to expect first (`en` or `bn`; the other is still heard). `terms` are vocabulary hints, at most 200 of at most 100 bytes. `audio_format` is `auto` (a WebM/Opus, Ogg or WAV stream, which names its own rate; the default), `pcm_s16le`, `mulaw` or `alaw`; raw formats need `sample_rate` (8000 to 48000) and `num_channels` (1 or 2, default 1). Then send audio as binary frames, in real time, while the person speaks. Text frames: `{\"type\":\"commit\"}` ends the current utterance and keeps the session open (one press of a hold-to-talk button); `{\"type\":\"keepalive\"}` holds the session while no audio flows; `{\"type\":\"end\"}` ends the audio.\n\n**Frames from Omazy.** `{\"type\":\"ready\"}` when the recognizer is up; audio you sent before it is kept and heard in order, so start sending at once. `{\"type\":\"partial\",\"text\",\"language\"}` as words arrive: the utterance so far. `{\"type\":\"final\",\"text\",\"language\"}` when an utterance ends, with `\"committed\":true` on the one that answers a commit (sent even when its text is empty, so you never wait for nothing). `{\"type\":\"done\",\"text\",\"language\",\"audio_ms\",\"request_id\"}` after `end`, with every final joined, then the socket closes with 1000. `{\"type\":\"error\",\"code\",\"message\",\"request_id\"}` then a close: a bad start frame is `BAD_REQUEST` with close 1008; a recognizer that cannot be reached or stops is `UPSTREAM_UNAVAILABLE` or `UPSTREAM_REJECTED` with close 1011.\n\n**Limits.** A session with no frame for 60 seconds is closed; a session ends as if you sent `end` after 30 minutes; a frame is at most 256 KB. Opening a session counts once against the AI and speech rate bucket. The plan's voice minutes are checked before the upgrade (`402 PLAN_LIMIT_REACHED`) and charged when the session ends: its audio length, rounded up, at least one minute per session. Hold one session open for a whole conversation and send `commit` per utterance, rather than one session per utterance.","parameters":[{"$ref":"#/components/parameters/AppQuery"},{"name":"Upgrade","in":"header","required":true,"schema":{"type":"string","const":"websocket"}}],"responses":{"101":{"description":"Switching Protocols. The connection is now a WebSocket that carries the frames below."},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"426":{"description":"The request was not a WebSocket upgrade.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"$ref":"#/components/responses/RateLimited"},"501":{"$ref":"#/components/responses/NotImplemented"},"503":{"$ref":"#/components/responses/ServiceUnavailable"}}}},"/voice/calls":{"post":{"operationId":"voiceCallsPlace","tags":["Calls"],"summary":"Place a phone call","x-omazy-scope":"voice:calls","description":"Asks the app's agent to phone a person from a number the app holds. Scope: `voice:calls`. The route does not dial on demand: it records the request, checks it against the calling rules and places the call when the rules allow. The answer is `202` with a `ref` to read the outcome with.\n\nThe rules, each refused with a `400` that names it: the purpose must be one of the list and marketing calls are refused. The consent basis must fit the purpose. Calls are placed between 09:00 and 20:00 in the person's own time zone, so a time zone must be known: send `tz` unless the number starts with `+880` or `+44`. The app must hold an active number to call from. Premium-rate and short-code numbers are never dialled. Attempts are capped at 2, or 3 for `survey` and `collection`.\n\nA number on the workspace's do-not-call list is not an error: the request is accepted with `status` `suppressed` and the number is not rung. Accepting the request has 60 seconds. Rate limit: 30 call placements per token per 10 minutes, on every plan. The route draws on the plan's voice minutes. When they are used up it answers `402 PLAN_LIMIT_REACHED`. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CallRequest"},"example":{"to":"+447700900123","purpose":"confirmation","consent_basis":"transaction","opening":"Hello, this is Nordwell calling about your delivery tomorrow.","goal":"Confirm that someone will be home between 10am and 2pm.","callback_url":"https://api.example.com/hooks/omazy-call"}}}},"responses":{"202":{"description":"The call was recorded. It has not been placed yet.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/CallResult"}}},"example":{"success":true,"data":{"ref":"7d3b0d2a-51a5-4f0b-8b56-3d0f3f7a9c21","from":"+442079460018","to":"+447700900123","status":"pending","next_attempt_at":"2026-11-20T09:00:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailableOrKeyNotChecked"},"504":{"$ref":"#/components/responses/GatewayTimeout"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}]}},"/voice/calls/{ref}":{"get":{"operationId":"voiceCallsGet","tags":["Calls"],"summary":"Read a call's outcome","x-omazy-scope":"voice:calls","description":"Reads where a placed call stands and what the person answered. Scope: `voice:calls`. An unknown `ref`, or one that belongs to another app, answers `404`. This route has no rate limit.","parameters":[{"name":"ref","in":"path","required":true,"description":"The `ref` the call was accepted with.","schema":{"type":"string","format":"uuid"},"example":"7d3b0d2a-51a5-4f0b-8b56-3d0f3f7a9c21"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The call.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/CallStatus"}}},"example":{"success":true,"data":{"ref":"7d3b0d2a-51a5-4f0b-8b56-3d0f3f7a9c21","status":"done","outcome":"completed","disposition":"answered","attempts":1,"max_attempts":2,"result":{"on_time":true,"rating":5}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"}}}},"/voice/jobs":{"post":{"operationId":"voiceJobsCreate","tags":["Voice jobs"],"summary":"Start a voice job","x-omazy-scope":"voice:tasks","description":"Queues a job that transcribes a recording with speakers and timestamps, or writes meeting notes from one. Scope: `voice:tasks`. It runs in the background. The answer is `202` with the job in status `queued`. Read it back with its `id`. Give exactly one source: `source_url` or `source_call_id`. The app can be named in the body or with the `app` query parameter. The query parameter wins. A job that has not finished within four hours fails. Rate limit: the AI and speech bucket, sized by the plan. The route draws on the plan's voice minutes. When they are used up it answers `402 PLAN_LIMIT_REACHED`. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VoiceJobRequest"},"example":{"kind":"meeting_notes","source_url":"https://files.example.com/standup-tuesday.mp3","template":"standup","diarize":true}}}},"responses":{"202":{"description":"The job was queued.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/VoiceJob"}}},"example":{"success":true,"data":{"id":"b7f5a7a0-4f0b-4d53-9a3e-6f0a3f1c2d44","workspace_id":"5b0c1c5e-8f0e-4a55-9a51-2f6d1f3f6a10","app_id":"c2a4e6f8-1b3d-4f5a-8c7e-9d0b2a4c6e8f","kind":"meeting_notes","status":"queued","source_url":"https://files.example.com/standup-tuesday.mp3","options":{"lang":["en","bn"],"diarize":true,"template":"standup","keep_source":false},"result":null,"attempts":0,"created_at":"2026-11-19T09:30:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"}}}},"/voice/jobs/{id}":{"get":{"operationId":"voiceJobsGet","tags":["Voice jobs"],"summary":"Read a voice job","x-omazy-scope":"voice:tasks","description":"Reads a voice job's status and, when it is done, its transcript or notes. Scope: `voice:tasks`. A `transcribe` job fills `result.transcript`. A `meeting_notes` job fills `result.notes`, and `result.transcript` as well when the notes were written from audio. An unknown `id`, or one that belongs to another app, answers `404`. This route has no rate limit.","parameters":[{"name":"id","in":"path","required":true,"description":"The job's id.","schema":{"type":"string","format":"uuid"},"example":"b7f5a7a0-4f0b-4d53-9a3e-6f0a3f1c2d44"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The job.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/VoiceJob"}}},"example":{"success":true,"data":{"id":"b7f5a7a0-4f0b-4d53-9a3e-6f0a3f1c2d44","workspace_id":"5b0c1c5e-8f0e-4a55-9a51-2f6d1f3f6a10","app_id":"c2a4e6f8-1b3d-4f5a-8c7e-9d0b2a4c6e8f","kind":"meeting_notes","status":"done","source_url":"https://files.example.com/standup-tuesday.mp3","options":{"lang":["en","bn"],"diarize":true,"template":"standup","keep_source":false},"result":{"transcript":{"text":"Morning. Yesterday I finished the export fix.","segments":[{"speaker":"1","start_ms":0,"end_ms":4200,"text":"Morning. Yesterday I finished the export fix."}],"duration_ms":912000},"notes":{"summary":"The export fix is done. The release moves to Thursday.","decisions":["Release on Thursday"],"action_items":[{"item":"Write the release note","owner":"Sam","due":"Wednesday"}],"open_questions":[]}},"attempts":1,"created_at":"2026-11-19T09:30:00Z","audio_seconds":912,"started_at":"2026-11-19T09:30:02Z","finished_at":"2026-11-19T09:33:40Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"}}}},"/customers/{id}":{"get":{"operationId":"customersGet","tags":["Data"],"summary":"Read a customer","x-omazy-scope":"core:read","description":"Reads one customer of the workspace by id. Scope: `core:read`. `external_id`, `email`, `phone` and `name` are left out when the customer has none. `tags` and `custom_fields` are always present. A customer in another workspace answers `404`.","parameters":[{"$ref":"#/components/parameters/CustomerId"}],"responses":{"200":{"description":"The customer.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/Customer"}}},"example":{"success":true,"data":{"id":"a3d1c1b2-7f6e-4d7a-9a0b-1c2d3e4f5a6b","external_id":"crm-4410","email":"sam@example.com","phone":"+447700900123","name":"Sam Rivera","tags":["wholesale"],"custom_fields":{"tier":"gold"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}},"patch":{"operationId":"customersUpdate","tags":["Data"],"summary":"Update a customer's custom fields","x-omazy-scope":"memory:write","description":"Merges keys into a customer's custom fields. Scope: `memory:write`. Keys you send replace the keys of the same name, and keys you do not send are kept. The merge is one level deep: a nested object replaces the whole value under its key. Only `custom_fields` can be written.","parameters":[{"$ref":"#/components/parameters/CustomerId"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CustomerUpdateRequest"},"example":{"custom_fields":{"tier":"platinum","renewal":"2027-03-01"}}}}},"responses":{"200":{"description":"The customer's id and the merged custom fields.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/CustomerUpdateResult"}}},"example":{"success":true,"data":{"id":"a3d1c1b2-7f6e-4d7a-9a0b-1c2d3e4f5a6b","custom_fields":{"tier":"platinum","renewal":"2027-03-01"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"}}}},"/conversations/{id}/messages":{"post":{"operationId":"conversationsPostMessage","tags":["Data"],"summary":"Post a message into a conversation","x-omazy-scope":"core:write","description":"Posts a message into an existing conversation as the agent. Scope: `core:write`. The person in the conversation sees it, and an open chat widget shows it straight away. The body holds 1 to 12 content blocks, and every block needs a `type`. A conversation in another workspace answers `404`. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"},{"name":"id","in":"path","required":true,"description":"The conversation's id.","schema":{"type":"string","format":"uuid"},"example":"9c1e2d3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PostMessageRequest"},"example":{"blocks":[{"type":"text","markdown":"Your report is ready."}]}}}},"responses":{"201":{"description":"The message was posted.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/PostMessageResult"}}},"example":{"success":true,"data":{"message_id":"6e5d4c3b-2a19-4f08-b7c6-d5e4f3a2b1c0"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"}}}},"/channels/linkedin/publish":{"post":{"operationId":"channelsLinkedinPublish","tags":["Channels"],"summary":"Publish to a LinkedIn Page","x-omazy-scope":"channels:publish","description":"Publishes a post to the LinkedIn Page connected to an app in the workspace. Scope: `channels:publish`. Your server hands over the text and never holds the Page's LinkedIn credential. Send the body with `Content-Type: application/json`. Without a connected Page the route answers `404`. When more than one app has a connected Page, `app` is required and the `400` lists the handles to choose from. A refusal from LinkedIn itself comes back as a `400` with LinkedIn's reason in the message. Send an `Idempotency-Key` to make this request safe to send again: a repeat with the same key returns the first answer and runs nothing.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkedinPublishRequest"},"example":{"text":"We now deliver on Fridays.","app":"nordwell"}}}},"responses":{"201":{"description":"The post was published.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/LinkedinPublishResult"}}},"example":{"success":true,"data":{"ext_id":"urn:li:share:7300000000000000000","permalink_url":"https://www.linkedin.com/feed/update/urn:li:share:7300000000000000000/"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/IdempotencyInProgress"},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"500":{"$ref":"#/components/responses/InternalError"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"}},"parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}]}},"/sessions/{sid}/mcp-credentials/{server}":{"put":{"operationId":"sessionsBindCredential","tags":["Sessions"],"summary":"Bind a user's token to their conversation","x-omazy-scope":"sessions:credentials","description":"Binds a signed-in user's token for your own MCP server to that user's conversation. Scope: `sessions:credentials`. From then on, every call the agent makes to that MCP server in the conversation carries the user's token. Send the body with `Content-Type: application/json`.\n\nThree checks run before anything is stored. The token must belong to the user you named: your MCP server is asked who the token belongs to, and an answer other than `subject.id` is a `403 FORBIDDEN`. A server without `whoami`, such as Notion's, is bound on your word instead when its `subject_check` is `host`: no call is made, and the answer's `verified` says `host`. A conversation belongs to one user for good: the first bind locks it to that `subject.id`, and binding another user's token later is a `409 CONFLICT`, even after the first token was removed. Your MCP server must answer: if it cannot be reached or it rejects the token, the bind fails with `502 UPSTREAM_REJECTED` (on a `whoami` server).\n\nBind again with a fresh token and the same `subject.id` before the old one runs out.","parameters":[{"$ref":"#/components/parameters/SessionId"},{"$ref":"#/components/parameters/ServerName"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BindCredentialRequest"},"example":{"token":"<the user's token for your MCP server>","expires_at":"2026-11-19T15:00:00Z","subject":{"id":"4410","login":"sam","name":"Sam Rivera"}}}}},"responses":{"200":{"description":"The token was bound.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/BindCredentialResult"}}},"example":{"success":true,"data":{"bound":true,"subject_key":"4410","expires_at":"2026-11-19T15:00:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"}}},"delete":{"operationId":"sessionsUnbindCredential","tags":["Sessions"],"summary":"Remove a user's token from their conversation","x-omazy-scope":"sessions:credentials","description":"Removes the bound token, for example when the user signs out. Scope: `sessions:credentials`. It answers `200` whether or not a token was bound, so you can call it on every sign-out. The conversation stays locked to its user. An unknown conversation or server answers `404`.","parameters":[{"$ref":"#/components/parameters/SessionId"},{"$ref":"#/components/parameters/ServerName"}],"responses":{"200":{"description":"The token was removed, or none was bound.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/UnbindCredentialResult"}}},"example":{"success":true,"data":{"revoked":true}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"}}}},"/mcp":{"post":{"operationId":"mcp","tags":["MCP"],"summary":"Call the Core API over MCP","description":"The Core API as a Model Context Protocol server. The endpoint itself needs no scope: each tool needs the scope of the route it runs. It takes JSON-RPC 2.0 over one `POST` and answers with one JSON body. There is no session and no stream. It implements `initialize`, `ping`, `tools/list` and `tools/call`. A batch of up to 20 messages is accepted. A request that holds only notifications gets `202` with no body.\n\n`tools/list` returns only the tools the token's scopes allow. The tools are `whoami`, `ai_complete`, `knowledge_search`, `knowledge_documents_list`, `knowledge_document_create`, `knowledge_document_get`, `knowledge_document_update`, `knowledge_document_delete`, `knowledge_sources_list`, `knowledge_source_create`, `knowledge_source_crawl`, `agent_turn`, `call_place`, `call_status`, `voice_job_create`, `voice_job_get`, `customer_get`, `customer_update`, `conversation_post_message`. A tool takes the same fields as the route it runs, as one object, and path fields such as `id` and `ref` are arguments too. Calling a tool outside the token's scopes answers the same as one that does not exist: JSON-RPC error `-32602`.\n\nA tool's answer is what its route puts in `data`: as text in `content` and as `structuredContent`. A refusal by the route (a bad argument, a spent budget, a rate limit) is a tool result with `isError: true` whose text is the route's error code and message. A tool call spends the rate bucket and the plan allowance of the route it runs. `ai_complete` never streams.\n\nAnswers on this route are JSON-RPC bodies, not the usual envelope. A request refused before the route runs (`401`, `402`, `403`) still gets the error envelope.","requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/JsonRpcRequest"},{"type":"array","minItems":1,"maxItems":20,"items":{"$ref":"#/components/schemas/JsonRpcRequest"}}]},"example":{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"knowledge_search","arguments":{"query":"What are your opening hours?","top_k":3}}}}}},"responses":{"200":{"description":"The JSON-RPC answer, or an array of answers for a batch. A JSON-RPC `error` for a message that could be parsed also arrives with this status.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/JsonRpcResponse"},{"type":"array","items":{"$ref":"#/components/schemas/JsonRpcResponse"}}]},"example":{"jsonrpc":"2.0","id":7,"result":{"content":[{"type":"text","text":"{\"passages\":[]}"}],"structuredContent":{"passages":[]},"isError":false}}}}},"202":{"description":"The request held only notifications. There is no body.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}}},"400":{"description":"The body is empty or not JSON (`-32700`), or a batch holds more than 20 messages (`-32600`). The body is a JSON-RPC error, not the error envelope.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/JsonRpcResponse"},"example":{"jsonrpc":"2.0","id":null,"error":{"code":-32700,"message":"Parse error"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/SubscriptionPaused"},"403":{"$ref":"#/components/responses/Forbidden"}}}},"/agent/settings":{"get":{"operationId":"getAgentSettings","tags":["Agent"],"summary":"Read how the agent runs","x-omazy-scope":"agent:configure","description":"The model the app's agent answers on, with its reply cap and temperature, the models the workspace may set on its plan, and the loop switches: whether a turn runs on the shared agent loop, streams its reply and masks personal data. Scope: `agent:configure`.\n\n`model.source` says where the binding comes from. An agent with its own binding has `overridden: true` and `inherited_model` names what it would go back to. `loop.overrides` holds only the switches this agent set; the others follow the platform's default.\n\nRate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The agent's settings.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/AgentSettings"}}},"example":{"success":true,"data":{"app_id":"5b552a51-3193-4c06-9443-0ba655a38058","app":"nordwell","model":{"id":"openai/gpt-4o","source":"app","overridden":true,"inherited_model":"openai/gpt-4o-mini","max_tokens":1200,"temperature":0.3},"models":[{"id":"openai/gpt-4o","label":"GPT-4o","vendor":"openai","tier":"premium","tools":true,"source":"managed"},{"id":"openai/gpt-4o-mini","label":"GPT-4o mini","vendor":"openai","tier":"standard","tools":true,"source":"managed"}],"plan_tier":"premium","loop":{"harness":true,"stream":true,"redact":false,"overrides":{"harness":true}}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"patch":{"operationId":"updateAgentSettings","tags":["Agent"],"summary":"Change how the agent runs","x-omazy-scope":"agent:configure","description":"Changes the agent's model, its reply cap, its temperature and its loop switches. Send only what changes. Scope: `agent:configure`. The answer is the settings after the change.\n\n**The model.** It must be one of `models` in the settings, or the route answers `403 MODEL_NOT_AVAILABLE`. Before a new model is saved the platform makes one test call to it through the agent's own binding. A model that does not answer, or that a fallback answered for, is refused with `422 MODEL_NOT_SERVING` and nothing changes. The test makes this request slow: allow up to 90 seconds.\n\n`max_tokens` and `temperature` are part of the agent's own binding. Setting either on an agent that inherits its model gives it a binding of its own on the model it runs on now, so a later change of the platform's default no longer moves it. `model: null` removes the agent's own binding and all three go back to what it inherits.\n\n**The loop switches.** `true` or `false` sets a switch for this agent; `null` puts it back to the platform's default. A change takes effect on the next turn.\n\nThe request is safe to send again: the same body leaves the same settings. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AgentSettingsUpdateRequest"},"examples":{"model":{"summary":"Move the agent to another model with a longer reply","value":{"model":"openai/gpt-4o","max_tokens":1200}},"loop":{"summary":"Turn streaming on and put redaction back to the default","value":{"loop":{"stream":true,"redact":null}}},"inherit":{"summary":"Go back to the inherited model","value":{"model":null}}}}}},"responses":{"200":{"description":"The agent's settings after the change.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/AgentSettings"}}},"example":{"success":true,"data":{"app_id":"5b552a51-3193-4c06-9443-0ba655a38058","app":"nordwell","model":{"id":"openai/gpt-4o","source":"app","overridden":true,"inherited_model":"openai/gpt-4o-mini","max_tokens":1200,"temperature":0.3},"models":[{"id":"openai/gpt-4o","label":"GPT-4o","vendor":"openai","tier":"premium","tools":true,"source":"managed"},{"id":"openai/gpt-4o-mini","label":"GPT-4o mini","vendor":"openai","tier":"standard","tools":true,"source":"managed"}],"plan_tier":"premium","loop":{"harness":true,"stream":true,"redact":false,"overrides":{"harness":true}}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"description":"The token lacks `agent:configure`, or the model is not on the workspace's plan (`MODEL_NOT_AVAILABLE`).","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"success":false,"error":{"code":"MODEL_NOT_AVAILABLE","message":"the model openai/o3 is not available on this workspace's plan; GET /core/agent/settings lists the ones that are"}}}}},"404":{"$ref":"#/components/responses/NotFound"},"409":{"$ref":"#/components/responses/Conflict"},"422":{"description":"The model did not answer a test call (`MODEL_NOT_SERVING`). Nothing was changed.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"success":false,"error":{"code":"MODEL_NOT_SERVING","message":"openai/gpt-4.1 could not serve a test message: the gateway rejected it. Nothing was changed"}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/agent/mcp-servers":{"get":{"operationId":"listAgentMcpServers","tags":["Agent"],"summary":"List the agent's MCP servers","x-omazy-scope":"agent:tools","description":"The MCP tool servers the app's agent may call, newest first. Scope: `agent:tools`. A credential is never returned; `has_credentials` says whether one is stored. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The agent's MCP servers.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"type":"array","items":{"$ref":"#/components/schemas/McpServer"}}}},"example":{"success":true,"data":[{"id":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e","name":"front-desk","endpoint_url":"https://tools.nordwell.example/mcp","auth_type":"bearer","allowed_tools":["visitor_lookup","book_meeting"],"is_active":true,"write_mode":"confirm","action_policy":{},"has_credentials":true,"created_at":"2026-11-20T06:40:00Z","updated_at":"2026-11-20T06:40:00Z"}]}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"post":{"operationId":"createAgentMcpServer","tags":["Agent"],"summary":"Connect an MCP server to the agent","x-omazy-scope":"agent:tools","description":"Connects an MCP tool server to the app's agent. Scope: `agent:tools`. From the agent's next turn its tools are offered to the model as `mcp_<name>__<tool>`, in the channels where the agent uses tools.\n\n**The endpoint** must be https on a public host. Any other address is refused here with `400`, because the agent would refuse to call it.\n\n**The name** is unique within the app, ignoring case. A second server with the name answers `409 CONFLICT`.\n\n**The credential** is stored encrypted and never returned by any route. Send a bearer token for `bearer`, or `Header-Name: value` for `header`. A `session_bearer` server takes none: each signed-in user's own token is bound to their conversation with `PUT /sessions/{sid}/mcp-credentials/{server}`.\n\n**`write_mode`** decides what the agent may do with a tool that changes data, and defaults to `confirm`: the visitor sees a card and the tool runs only when they agree.\n\nNothing is called when the server is connected. A server that cannot be reached, or whose credential is wrong, is skipped by the agent at the turn. Send an `Idempotency-Key` to make this request safe to send again. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpServerCreateRequest"},"example":{"name":"front-desk","endpoint_url":"https://tools.nordwell.example/mcp","auth_type":"bearer","credentials":"<the server's token>","allowed_tools":["visitor_lookup","book_meeting"]}}}},"responses":{"201":{"description":"The server, connected.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"},"Idempotent-Replayed":{"$ref":"#/components/headers/Idempotent-Replayed"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/McpServer"}}},"example":{"success":true,"data":{"id":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e","name":"front-desk","endpoint_url":"https://tools.nordwell.example/mcp","auth_type":"bearer","allowed_tools":["visitor_lookup","book_meeting"],"is_active":true,"write_mode":"confirm","action_policy":{},"has_credentials":true,"created_at":"2026-11-20T06:40:00Z","updated_at":"2026-11-20T06:40:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"The app already has an MCP server with this name.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"success":false,"error":{"code":"CONFLICT","message":"this app already has an MCP server named \"front-desk\""}}}}},"422":{"$ref":"#/components/responses/IdempotencyKeyReused"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"503":{"$ref":"#/components/responses/IdempotencyUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/agent/mcp-servers/{id}":{"get":{"operationId":"getAgentMcpServer","tags":["Agent"],"summary":"Read one MCP server","x-omazy-scope":"agent:tools","description":"One MCP server of the app's agent. Scope: `agent:tools`. A server of another app answers `404`. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/McpServerId"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The server.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/McpServer"}}},"example":{"success":true,"data":{"id":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e","name":"front-desk","endpoint_url":"https://tools.nordwell.example/mcp","auth_type":"bearer","allowed_tools":["visitor_lookup","book_meeting"],"is_active":true,"write_mode":"confirm","action_policy":{},"has_credentials":true,"created_at":"2026-11-20T06:40:00Z","updated_at":"2026-11-20T06:40:00Z"}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"patch":{"operationId":"updateAgentMcpServer","tags":["Agent"],"summary":"Change an MCP server","x-omazy-scope":"agent:tools","description":"Changes an MCP server of the app's agent. Send only what changes. Scope: `agent:tools`.\n\n`credentials` replaces the stored credential, and an empty string removes it. `allowed_tools` and `action_policy` replace what is stored. Changing `auth_type` to `session_bearer` removes the stored credential. Renaming a server renames its tools for the model. `is_active: false` keeps the server and stops the agent calling it.\n\nThe request is safe to send again: the same body leaves the same server. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/McpServerId"},{"$ref":"#/components/parameters/AppQuery"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/McpServerUpdateRequest"},"examples":{"rotate":{"summary":"Replace the credential","value":{"credentials":"<the new token>"}},"pause":{"summary":"Stop the agent calling the server","value":{"is_active":false}}}}}},"responses":{"200":{"description":"The server after the change.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/McpServer"}}},"example":{"success":true,"data":{"id":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e","name":"front-desk","endpoint_url":"https://tools.nordwell.example/mcp","auth_type":"bearer","allowed_tools":["visitor_lookup","book_meeting"],"is_active":true,"write_mode":"confirm","action_policy":{},"has_credentials":true,"created_at":"2026-11-20T06:40:00Z","updated_at":"2026-11-20T06:40:00Z"}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"409":{"description":"The app already has an MCP server with this name.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"success":false,"error":{"code":"CONFLICT","message":"this app already has an MCP server named \"front-desk\""}}}}},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}},"delete":{"operationId":"deleteAgentMcpServer","tags":["Agent"],"summary":"Remove an MCP server","x-omazy-scope":"agent:tools","description":"Removes an MCP server from the app's agent, with its stored credential. Scope: `agent:tools`. The agent stops offering its tools at the next turn. Removing a server that is already gone answers `404`. Rate limit: the settings bucket, sized by the plan.","parameters":[{"$ref":"#/components/parameters/McpServerId"},{"$ref":"#/components/parameters/AppQuery"}],"responses":{"200":{"description":"The server was removed.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/McpServerDeleted"}}},"example":{"success":true,"data":{"id":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e","deleted":true}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"404":{"$ref":"#/components/responses/NotFound"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"502":{"$ref":"#/components/responses/BadGateway"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}},"/usage":{"get":{"operationId":"getUsage","tags":["Usage"],"summary":"Read usage and cost per day","x-omazy-scope":"usage:read","description":"What the token's workspace used and what it cost, per UTC day, both ends of the range included. Scope: `usage:read`.\n\nThe cost fields come from the platform's cost ledger: every model call, cache hit and speech session of the workspace, whichever product or screen made it. The plan's counters (`conversations`, `ai_turns`, `api_calls`, `voice_minutes`) are the ones the plan limits read. A reply from the gateway's response cache is counted in `cache_hits` and costs nothing. Text to speech is priced from a list price per character, so it is in `estimated_cost_micros` until the price is confirmed.\n\nA range covers at most 90 days; the last 30 days, today included, when `from` and `to` are left out. Today's numbers grow as the day goes on.\n\nRate limit: the usage bucket, sized by the plan.","parameters":[{"name":"from","in":"query","required":false,"description":"First day, YYYY-MM-DD (UTC). Defaults to 29 days before `to`.","schema":{"type":"string","format":"date"}},{"name":"to","in":"query","required":false,"description":"Last day, YYYY-MM-DD (UTC). Defaults to today.","schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"The workspace's usage.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"type":"object","required":["success","data"],"properties":{"success":{"type":"boolean","const":true},"data":{"$ref":"#/components/schemas/UsageReport"}}},"example":{"success":true,"data":{"workspace_id":"7d6b032b-83b1-4e92-ab19-c2bd902faf2c","from":"2026-11-22","to":"2026-11-23","totals":{"model_calls":206,"cache_hits":29,"errors":0,"input_tokens":1112400,"output_tokens":7828,"cached_input_tokens":803400,"speech_sessions":0,"speech_seconds":0,"cost_micros":707000,"cost_usd":0.707,"estimated_cost_micros":0,"unpriced_calls":0,"conversations":43,"ai_turns":177,"api_calls":210,"voice_minutes":0},"days":[{"date":"2026-11-22","model_calls":120,"cache_hits":18,"errors":0,"input_tokens":648000,"output_tokens":4560,"cached_input_tokens":468000,"speech_sessions":0,"speech_seconds":0,"cost_micros":412000,"cost_usd":0.412,"estimated_cost_micros":0,"unpriced_calls":0,"conversations":25,"ai_turns":102,"api_calls":122,"voice_minutes":0},{"date":"2026-11-23","model_calls":86,"cache_hits":11,"errors":0,"input_tokens":464400,"output_tokens":3268,"cached_input_tokens":335400,"speech_sessions":0,"speech_seconds":0,"cost_micros":295000,"cost_usd":0.295,"estimated_cost_micros":0,"unpriced_calls":0,"conversations":18,"ai_turns":75,"api_calls":88,"voice_minutes":0}]}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/PaymentRequired"},"403":{"$ref":"#/components/responses/Forbidden"},"429":{"$ref":"#/components/responses/RateLimited"},"500":{"$ref":"#/components/responses/InternalError"},"501":{"$ref":"#/components/responses/NotImplemented"},"503":{"$ref":"#/components/responses/ServiceUnavailable"},"504":{"$ref":"#/components/responses/GatewayTimeout"}}}}},"components":{"securitySchemes":{"CoreToken":{"type":"http","scheme":"bearer","bearerFormat":"cai_<prefix>.<rest>","description":"A Core API token, sent as `Authorization: Bearer cai_<prefix>.<rest>`. A workspace owner creates the token and chooses its scopes. It belongs to one workspace. It must stay on a server: never ship it in a browser bundle or a mobile app."}},"parameters":{"AppQuery":{"name":"app","in":"query","required":false,"description":"Handle of the app to run against. Needed only when the workspace has more than one app.","schema":{"type":"string"},"example":"nordwell"},"DocumentId":{"name":"id","in":"path","required":true,"description":"The document's id.","schema":{"type":"string"},"example":"01JD3K8Z6Q4X9T2M5V7W0B1C3E"},"CustomerId":{"name":"id","in":"path","required":true,"description":"The customer's id.","schema":{"type":"string","format":"uuid"},"example":"a3d1c1b2-7f6e-4d7a-9a0b-1c2d3e4f5a6b"},"SessionId":{"name":"sid","in":"path","required":true,"description":"The conversation's id.","schema":{"type":"string","format":"uuid"},"example":"9c1e2d3f-4a5b-4c6d-8e7f-0a1b2c3d4e5f"},"ServerName":{"name":"server","in":"path","required":true,"description":"The name of the MCP server as it is set up on the conversation's app. It is matched without regard to case. The server must be set to use a per-user token.","schema":{"type":"string"},"example":"backoffice"},"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":false,"description":"A name you choose for this request, 1 to 255 printable ASCII characters with no spaces. A UUID works. Send the same key when you repeat the request after a lost answer: the work runs once and the first answer comes back. Only a `2xx` answer is remembered, for 24 hours. Use a new key for a new request.","schema":{"type":"string","minLength":1,"maxLength":255},"example":"7f1f3c0a-2a53-4d0e-9a57-6b8d1c1e5f20"},"McpServerId":{"name":"id","in":"path","required":true,"description":"The MCP server's id.","schema":{"type":"string","format":"uuid"},"example":"7b0c2f6e-3a41-4d0f-9e5c-1f2a3b4c5d6e"}},"headers":{"X-Request-Id":{"description":"The id of this request. It is on every response, a refused one included. Log it next to an error. Send your own `X-Request-Id` request header and it is kept, as long as it is at most 128 characters of letters, digits, `-`, `_`, `.` and `:`.","schema":{"type":"string"},"example":"req_4b09ccab08ad46afb5556107d238f6a1"},"X-RateLimit-Limit":{"description":"The size of this route's rate bucket: requests per token in a sliding window of 10 minutes. Sent by rate-limited routes once the token and its scope are accepted.","schema":{"type":"integer"},"example":600},"X-RateLimit-Remaining":{"description":"Requests left in the bucket after this one.","schema":{"type":"integer"},"example":587},"X-RateLimit-Reset":{"description":"Seconds until a place frees in the bucket. `0` while places are free.","schema":{"type":"integer"},"example":0},"Retry-After":{"description":"Seconds to wait before retrying. Sent when the token is over its own rate limit. The same number as `X-RateLimit-Reset`.","schema":{"type":"integer"},"example":212},"X-Omazy-Token-Expires-At":{"description":"When the presented token stops working, in UTC. Sent only when the token has a deadline: its own expiry, or the end of the overlap after a rotation.","schema":{"type":"string","format":"date-time"},"example":"2027-02-17T12:14:11Z"},"X-Omazy-Token-Use":{"description":"Sent with the value `previous` while the caller is still on a token that a rotation replaced. Deploy the new token before the overlap ends.","schema":{"type":"string","enum":["previous"]},"example":"previous"},"X-Omazy-Speech-Lang":{"description":"The language that was spoken.","schema":{"type":"string"},"example":"en"},"WWW-Authenticate":{"description":"Says that a bearer token is wanted.","schema":{"type":"string"},"example":"Bearer"},"Idempotent-Replayed":{"description":"`true` when the answer is the remembered answer of an earlier request with the same `Idempotency-Key`. Absent otherwise.","schema":{"type":"string","enum":["true"]}}},"responses":{"BadRequest":{"description":"`BAD_REQUEST`: the request is malformed, breaks a limit or breaks a rule. Read `message` and fix the request. Do not retry it unchanged.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"bad_request":{"value":{"success":false,"error":{"code":"BAD_REQUEST","message":"messages is required"}}}}}}},"Unauthorized":{"description":"`UNAUTHORIZED`: the token is missing, malformed, revoked, expired or wrong. The message says which.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"WWW-Authenticate":{"$ref":"#/components/headers/WWW-Authenticate"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing":{"value":{"success":false,"error":{"code":"UNAUTHORIZED","message":"missing core token"}}},"expired":{"value":{"success":false,"error":{"code":"UNAUTHORIZED","message":"core token expired; rotate the install to get a new one"}}}}}}},"PaymentRequired":{"description":"`PAYMENT_REQUIRED`: the workspace's AI budget is spent. `PLAN_LIMIT_REACHED`: the workspace has used the AI turns or the voice minutes its plan includes for the period. `SUBSCRIPTION_PAUSED`: the workspace's subscription is paused. Retrying does not help. Stop calling and tell whoever owns the workspace.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"budget_spent":{"value":{"success":false,"error":{"code":"PAYMENT_REQUIRED","message":"the workspace's AI budget is spent"}}},"plan_limit":{"value":{"success":false,"error":{"code":"PLAN_LIMIT_REACHED","message":"this workspace has used its plan's AI turns for the period (6601 of 6000); it resets on 2026-12-07"}}},"subscription_paused":{"value":{"success":false,"error":{"code":"SUBSCRIPTION_PAUSED","message":"this workspace's subscription is paused; resume it to use the Core API"}}}}}}},"SubscriptionPaused":{"description":"`SUBSCRIPTION_PAUSED`: the workspace's subscription is paused. Resume it. Retrying does not help.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"subscription_paused":{"value":{"success":false,"error":{"code":"SUBSCRIPTION_PAUSED","message":"this workspace's subscription is paused; resume it to use the Core API"}}}}}}},"Forbidden":{"description":"`FORBIDDEN`: the token lacks the scope the route needs, and the message names the scope. Some routes add a case of their own, described on the route. `WORKSPACE_INACTIVE`: the workspace is suspended or closed. Retrying does not help.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"missing_scope":{"value":{"success":false,"error":{"code":"FORBIDDEN","message":"missing scope: ai:complete"}}},"workspace_inactive":{"value":{"success":false,"error":{"code":"WORKSPACE_INACTIVE","message":"this workspace is suspended; the Core API is not available to it"}}}}}}},"NotFound":{"description":"`NOT_FOUND`: no such record in this workspace. An id that belongs to another workspace answers the same. An unknown `app` handle, and an app with no agent on routes that need one, also answer `404`.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"not_found":{"value":{"success":false,"error":{"code":"NOT_FOUND","message":"customer not found"}}}}}}},"Conflict":{"description":"`CONFLICT`: the conversation is already bound to another user. Do not retry.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"conflict":{"value":{"success":false,"error":{"code":"CONFLICT","message":"this chat session is bound to another user"}}}}}}},"RateLimited":{"description":"`RATE_LIMIT_EXCEEDED`: the token passed its rate limit, or the model provider is rate-limiting. Wait, then retry with backoff. A request refused this way does not count against the limit.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Retry-After":{"$ref":"#/components/headers/Retry-After"},"X-RateLimit-Limit":{"$ref":"#/components/headers/X-RateLimit-Limit"},"X-RateLimit-Remaining":{"$ref":"#/components/headers/X-RateLimit-Remaining"},"X-RateLimit-Reset":{"$ref":"#/components/headers/X-RateLimit-Reset"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"token_limit":{"value":{"success":false,"error":{"code":"RATE_LIMIT_EXCEEDED","message":"this install made more than 600 AI calls in 10 minutes; slow down"}}},"provider_limit":{"value":{"success":false,"error":{"code":"RATE_LIMIT_EXCEEDED","message":"the model provider is rate-limiting; retry shortly"}}}}}}},"InternalError":{"description":"`INTERNAL_ERROR`: something failed on the server. Retry once, then report it with the `X-Request-Id`.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"internal":{"value":{"success":false,"error":{"code":"INTERNAL_ERROR","message":"customer read failed"}}}}}}},"NotImplemented":{"description":"The feature behind this route is not enabled on this deployment. The code is `UPSTREAM_UNAVAILABLE`, or `NOT_IMPLEMENTED` on the session credential routes. Retrying does not help.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"feature_off":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"speech is not enabled on this deployment"}}},"credentials_off":{"value":{"success":false,"error":{"code":"NOT_IMPLEMENTED","message":"session credentials are not enabled"}}}}}}},"BadGateway":{"description":"`UPSTREAM_REJECTED`: a provider refused or failed the call, or your MCP server could not verify a token. Retry once. If it persists, check the request.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"upstream_rejected":{"value":{"success":false,"error":{"code":"UPSTREAM_REJECTED","message":"the model provider rejected the request"}}}}}}},"ServiceUnavailable":{"description":"`UPSTREAM_UNAVAILABLE`: knowledge search, speech or telephony is not configured on this deployment. `NOT_AVAILABLE`: knowledge documents are not available on this deployment yet. Retrying does not help.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"not_configured":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"speech is not configured on this deployment"}}},"not_available":{"value":{"success":false,"error":{"code":"NOT_AVAILABLE","message":"knowledge documents are not available on this deployment yet"}}}}}}},"GatewayTimeout":{"description":"`UPSTREAM_UNAVAILABLE`: the work did not finish inside the time allowed. Retry, with a smaller request if you can.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"timeout":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"completion timed out"}}}}}}},"IdempotencyInProgress":{"description":"`IDEMPOTENCY_IN_PROGRESS`: a request with this `Idempotency-Key` is still running. Nothing ran for this one. Wait the seconds in `Retry-After` and send it again.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"in_progress":{"value":{"success":false,"error":{"code":"IDEMPOTENCY_IN_PROGRESS","message":"a request with this Idempotency-Key is still running; send it again shortly"}}}}}}},"IdempotencyKeyReused":{"description":"`IDEMPOTENCY_KEY_REUSED`: this `Idempotency-Key` was first sent with a different request. Nothing ran. Use a new key for a new request.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"key_reused":{"value":{"success":false,"error":{"code":"IDEMPOTENCY_KEY_REUSED","message":"this Idempotency-Key was used with a different request; use a new key for a new request"}}}}}}},"IdempotencyUnavailable":{"description":"`UPSTREAM_UNAVAILABLE`: the request carried an `Idempotency-Key` and the key could not be checked. Nothing ran. Wait the seconds in `Retry-After` and send it again. On other routes: a part of the platform this route needs is not configured on this deployment.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"key_not_checked":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"idempotency keys cannot be checked right now; nothing ran, send the request again"}}}}}}},"ServiceUnavailableOrKeyNotChecked":{"description":"`UPSTREAM_UNAVAILABLE`: knowledge search, speech or telephony is not configured on this deployment. `NOT_AVAILABLE`: knowledge documents are not available on this deployment yet. Retrying does not help. On a request with an `Idempotency-Key`: the key could not be checked, nothing ran, and the request can be sent again after the seconds in `Retry-After`.","headers":{"X-Request-Id":{"$ref":"#/components/headers/X-Request-Id"},"X-Omazy-Token-Expires-At":{"$ref":"#/components/headers/X-Omazy-Token-Expires-At"},"X-Omazy-Token-Use":{"$ref":"#/components/headers/X-Omazy-Token-Use"},"Retry-After":{"$ref":"#/components/headers/Retry-After"}},"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"examples":{"not_configured":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"speech is not configured on this deployment"}}},"not_available":{"value":{"success":false,"error":{"code":"NOT_AVAILABLE","message":"knowledge documents are not available on this deployment yet"}}},"key_not_checked":{"value":{"success":false,"error":{"code":"UPSTREAM_UNAVAILABLE","message":"idempotency keys cannot be checked right now; nothing ran, send the request again"}}}}}}}},"schemas":{"ErrorCode":{"type":"string","description":"The stable, machine-readable reason. Branch on this value.","enum":["BAD_REQUEST","UNAUTHORIZED","PAYMENT_REQUIRED","PLAN_LIMIT_REACHED","SUBSCRIPTION_PAUSED","WORKSPACE_INACTIVE","FORBIDDEN","NOT_FOUND","CONFLICT","IDEMPOTENCY_IN_PROGRESS","IDEMPOTENCY_KEY_REUSED","RATE_LIMIT_EXCEEDED","INTERNAL_ERROR","UPSTREAM_UNAVAILABLE","NOT_IMPLEMENTED","NOT_AVAILABLE","UPSTREAM_REJECTED","MODEL_NOT_AVAILABLE","MODEL_NOT_SERVING"]},"Error":{"type":"object","description":"The error envelope. Every refused or failed request answers with it.","required":["success","error"],"properties":{"success":{"type":"boolean","const":false},"error":{"type":"object","required":["code","message"],"properties":{"code":{"$ref":"#/components/schemas/ErrorCode"},"message":{"type":"string","description":"A sentence for a person. It names the field or the rule that failed. The wording can change, so log it and do not branch on it."}}}}},"Usage":{"type":"object","description":"Token counts for one call.","required":["input_tokens","output_tokens","cached_input_tokens"],"properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"},"cached_input_tokens":{"type":"integer"}}},"AiTurnsAllowance":{"type":"object","description":"AI turns used and included in the current billing period.","required":["used","limit","resets_at"],"properties":{"used":{"type":"integer","description":"AI turns used this period."},"limit":{"type":"integer","description":"AI turns the plan includes. `-1` means the plan does not cap them."},"resets_at":{"type":"string","format":"date-time","description":"When the period resets."}}},"Plan":{"type":"object","description":"The plan the workspace is on and what it allows this token.","required":["sku","rate_per_minute"],"properties":{"sku":{"type":"string","description":"The plan's identifier."},"rate_per_minute":{"type":"integer","description":"Calls per minute the plan allows. Each plan-sized rate bucket holds ten times this number per 10 minutes."},"ai_turns":{"$ref":"#/components/schemas/AiTurnsAllowance"},"voice_minutes":{"$ref":"#/components/schemas/VoiceMinutesAllowance"}}},"Whoami":{"type":"object","required":["install_id","workspace_id","app_slug","scopes","status","token"],"properties":{"install_id":{"type":"string","format":"uuid","description":"The id of the token's record."},"workspace_id":{"type":"string","format":"uuid","description":"The workspace the token belongs to."},"app_slug":{"type":"string","description":"The name the token was issued under. It identifies your integration. It is not the handle of an app, and it is not what you pass as `app` on other routes."},"scopes":{"type":"array","items":{"type":"string"},"description":"The scopes the token holds."},"status":{"type":"string","description":"The status of the token's record. A token that authenticates is `active`."},"token":{"type":"string","enum":["current","previous"],"description":"`previous` while the caller is still on a token that a rotation replaced. Deploy the new token before the overlap ends."},"token_expires_at":{"type":"string","format":"date-time","description":"When the presented token stops working. Present only when the token has a deadline."},"plan":{"$ref":"#/components/schemas/Plan"}}},"ToolCall":{"type":"object","description":"A tool call the model made.","required":["id","name","input"],"properties":{"id":{"type":"string","description":"The id to answer with in a tool result."},"name":{"type":"string","description":"The tool's name."},"input":{"description":"The arguments, as JSON that follows the tool's `input_schema`."}}},"ToolResult":{"type":"object","description":"Your answer to one tool call.","required":["call_id","content"],"properties":{"call_id":{"type":"string","description":"The `id` of the call it answers."},"content":{"type":"string","description":"The result, as a string. Serialise JSON yourself."},"is_error":{"type":"boolean","default":false,"description":"`true` when the tool failed."}}},"Message":{"type":"object","description":"One turn of the conversation. A message must carry something: text, tool calls or tool results.","required":["role"],"properties":{"role":{"type":"string","enum":["user","assistant"],"description":"There is no `system` role. Put instructions in `system`."},"content":{"type":"string","description":"The text of the turn. It can be empty when the turn carries tool calls or tool results."},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ToolCall"},"description":"On an assistant turn, the tool calls the model made."},"tool_results":{"type":"array","items":{"$ref":"#/components/schemas/ToolResult"},"description":"On the user turn that follows, your answers to those calls."}}},"ToolDefinition":{"type":"object","description":"A tool the model may ask you to run. Omazy relays the call and never runs it.","required":["name","input_schema"],"properties":{"name":{"type":"string"},"description":{"type":"string","description":"What the model reads to decide whether to call the tool."},"input_schema":{"type":"object","description":"A JSON Schema object for the tool's arguments.","additionalProperties":true}}},"CompleteRequest":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","minItems":1,"maxItems":200,"items":{"$ref":"#/components/schemas/Message"},"description":"The conversation, oldest first. `system`, every message's `content` and every tool result's `content` together are at most 400000 bytes of UTF-8."},"system":{"type":"string","description":"Instructions for the model."},"max_tokens":{"type":"integer","default":1024,"maximum":8192,"description":"Ceiling on the reply."},"temperature":{"type":"number","minimum":0,"maximum":2,"description":"Left out, the model profile's own setting applies."},"tools":{"type":"array","maxItems":64,"items":{"$ref":"#/components/schemas/ToolDefinition"},"description":"Tools the model may ask you to run."},"tool_choice":{"type":"string","enum":["auto","any","none"],"description":"`auto` lets the model decide, `any` requires a tool call, `none` forbids one. Left out, it behaves as `auto`."},"model":{"type":"string","description":"Run on this model. A model id carries its provider, for example `openai/gpt-4o-mini`. It must be a model the workspace may use."},"profile":{"type":"string","description":"Run on this model profile in place of the one the app's agent answers on."},"stream":{"type":"boolean","default":false,"description":"`true` answers as Server-Sent Events."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."},"cache_ttl":{"type":"integer","description":"Response cache for this call. Unset: the gateway's setting. 0: never from the cache. 60 to 2592000: seconds a stored reply may be served again.","oneOf":[{"const":0},{"minimum":60,"maximum":2592000}]}}},"CompleteResult":{"type":"object","required":["text","stop_reason","model","usage"],"properties":{"text":{"type":"string","description":"The reply. Empty when the model only called tools."},"tool_calls":{"type":"array","items":{"$ref":"#/components/schemas/ToolCall"},"description":"Present when the model wants tools run."},"stop_reason":{"type":"string","description":"Why the model stopped, as the provider reported it. Providers use different words, so check `tool_calls` to decide whether to run tools."},"model":{"type":"string","description":"The model the call was sent to."},"usage":{"$ref":"#/components/schemas/Usage"},"cache_hit":{"type":"boolean","description":"True when the gateway answered from its response cache: the model was not called, the call cost nothing and used no AI turn. Left out otherwise."}}},"KnowledgeSearchRequest":{"type":"object","required":["query"],"properties":{"query":{"type":"string","minLength":1,"maxLength":2000,"description":"What to look for, in natural language. At most 2000 bytes of UTF-8."},"top_k":{"type":"integer","default":8,"maximum":20,"description":"How many passages to return. A higher value is lowered to 20."},"language":{"type":"string","description":"The language of the conversation, such as `en` or `bn`."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."}}},"KnowledgePassage":{"type":"object","required":["document_id","title","content","score"],"properties":{"document_id":{"type":"string","description":"The document the passage came from."},"title":{"type":"string","description":"That document's title."},"content":{"type":"string","description":"The passage text."},"language":{"type":"string","description":"The passage's language, when it is known."},"score":{"type":"number","description":"Relevance. Higher is closer. Compare scores within one response only."}}},"KnowledgeSearchResult":{"type":"object","required":["passages"],"properties":{"passages":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgePassage"},"description":"Best matches first. Empty when nothing matched."}}},"KnowledgeIndex":{"type":"object","description":"How indexing of a document stands.","required":["status","indexed_at","chunks","tokens"],"properties":{"status":{"type":"string","enum":["queued","indexing","ready","failed"],"description":"`queued`: written, waiting to be indexed. `indexing`: a pass is running. `ready`: searchable as it stands. `failed`: the last pass failed, and indexing is tried again on its own."},"error":{"type":"string","description":"Why the last pass failed. Present only while `status` is `failed`."},"indexed_at":{"type":["string","null"],"format":"date-time","description":"When the document was last indexed."},"chunks":{"type":"integer","description":"How many passages the document was split into."},"tokens":{"type":"integer","description":"How many tokens those passages hold."}}},"KnowledgeDocument":{"type":"object","description":"One document of the agent's knowledge base.","required":["id","kind","title","source_url","language","is_active","index","version","created_at","updated_at"],"properties":{"id":{"type":"string","description":"The document's id."},"kind":{"type":"string","enum":["text","faq","structured","pricing","catalog"]},"title":{"type":"string"},"source_url":{"type":["string","null"],"description":"Where the text came from. For an imported file, the file's name."},"language":{"type":"string","description":"Language code of the text."},"is_active":{"type":"boolean","description":"`false` when the document is kept out of search."},"content":{"type":"string","description":"The text of the document. Left out of a list, and when the document has none."},"data":{"description":"The document's structured data, as JSON. Left out when the document has none."},"index":{"$ref":"#/components/schemas/KnowledgeIndex"},"version":{"type":"integer","description":"The knowledge version of the document's last index. `0` until it has been indexed."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"DocumentCreateRequest":{"type":"object","description":"A document needs `content` or `data`.","required":["title"],"anyOf":[{"required":["content"]},{"required":["data"]}],"properties":{"title":{"type":"string","minLength":1,"maxLength":300,"description":"A short title. Shown as the source of an answer."},"content":{"type":"string","maxLength":2097152,"description":"The text of the document. At most 2 MB of UTF-8."},"data":{"description":"Structured data for the document, as JSON. At most 256 KB."},"kind":{"type":"string","enum":["text","faq","structured","pricing","catalog"],"default":"text"},"source_url":{"type":"string","description":"Where the text came from, if it has a public address."},"language":{"type":"string","default":"en","description":"Language code of the text."},"is_active":{"type":"boolean","default":true,"description":"`false` stores the document without making it searchable."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."}}},"DocumentUpdateRequest":{"type":"object","description":"Fields left out are kept. Send at least one field to change.","minProperties":1,"properties":{"title":{"type":"string","minLength":1,"maxLength":300},"content":{"type":"string","maxLength":2097152,"description":"The new text. At most 2 MB of UTF-8."},"data":{"description":"New structured data, as JSON. At most 256 KB."},"kind":{"type":"string","enum":["text","faq","structured","pricing","catalog"]},"source_url":{"type":"string"},"language":{"type":"string"},"is_active":{"type":"boolean","description":"`false` takes the document out of search without deleting it."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app. It can also be sent as the `app` query parameter."}}},"DocumentPage":{"type":"object","required":["documents","next_cursor","version"],"properties":{"documents":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeDocument"},"description":"Newest first, without `content` and `data`."},"next_cursor":{"type":"string","description":"Pass it as `cursor` to read the next page. Empty on the last page."},"version":{"type":"integer","description":"The agent's knowledge version now."}}},"DocumentDeleted":{"type":"object","required":["id","deleted"],"properties":{"id":{"type":"string"},"deleted":{"type":"boolean","const":true}}},"KnowledgeSource":{"type":"object","description":"A website the agent's knowledge is crawled from.","required":["id","kind","root_url","status","crawler","schedule","config","stats","last_error","last_crawled_at","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["website","sitemap","url_list","feed"],"description":"A source added through this API is a `website`."},"root_url":{"type":"string","description":"The address the crawl starts from."},"status":{"type":"string","enum":["idle","queued","crawling","ready","error","disabled"],"description":"The state of the crawl."},"crawler":{"type":["string","null"],"description":"The crawler that fetches the source."},"schedule":{"type":["string","null"],"description":"The source's crawl schedule, when it has one."},"config":{"type":"object","description":"The crawl limits.","properties":{"max_pages":{"type":"integer"},"max_depth":{"type":"integer"}},"additionalProperties":true},"stats":{"type":"object","description":"Figures from the last crawl. Empty until one has run.","additionalProperties":true},"last_error":{"type":["string","null"],"description":"Why the last crawl failed, when it did."},"last_crawled_at":{"type":["string","null"],"format":"date-time"},"created_at":{"type":"string","format":"date-time"}}},"SourceCreateRequest":{"type":"object","required":["root_url"],"properties":{"root_url":{"type":"string","format":"uri","maxLength":2000,"pattern":"^https?://","description":"The address to start from, with `https://` or `http://`."},"max_pages":{"type":"integer","minimum":0,"maximum":200,"default":25,"description":"How many pages to fetch at most. `0` uses the default."},"max_depth":{"type":"integer","minimum":0,"maximum":4,"default":2,"description":"How many links deep to follow. `0` uses the default."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."}}},"SourceList":{"type":"object","required":["sources"],"properties":{"sources":{"type":"array","items":{"$ref":"#/components/schemas/KnowledgeSource"},"description":"Newest first."}}},"CrawlRequest":{"type":"object","properties":{"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app. It can also be sent as the `app` query parameter."}}},"CrawlQueued":{"type":"object","required":["id","queued"],"properties":{"id":{"type":"string","description":"The source's id."},"queued":{"type":"boolean","const":true}}},"ExportedChunk":{"type":"object","description":"One passage of a document, as search holds it.","required":["ordinal","text","tokens","checksum"],"properties":{"ordinal":{"type":"integer","description":"The passage's position in the document."},"text":{"type":"string"},"tokens":{"type":"integer"},"checksum":{"type":"string","description":"A checksum of the passage."}}},"ExportedDocument":{"type":"object","description":"A changed document with its passages. A document that was switched off has `is_active` false and no passages: drop it from your copy.","required":["id","kind","title","source_url","language","is_active","version","updated_at","chunks"],"properties":{"id":{"type":"string"},"kind":{"type":"string","enum":["text","faq","structured","pricing","catalog"]},"title":{"type":"string"},"source_url":{"type":["string","null"]},"language":{"type":"string"},"is_active":{"type":"boolean"},"version":{"type":"integer","description":"The knowledge version of the document's last index."},"updated_at":{"type":"string","format":"date-time"},"chunks":{"type":"array","items":{"$ref":"#/components/schemas/ExportedChunk"}}}},"DeletedDocument":{"type":"object","description":"A document that no longer exists.","required":["id","version"],"properties":{"id":{"type":"string"},"version":{"type":"integer","description":"The knowledge version of the deletion."}}},"KnowledgeExport":{"type":"object","description":"One page of changes.","required":["version","documents","deleted","resync","next_cursor"],"properties":{"version":{"type":"integer","description":"The version the export is complete up to. The same on every page. Pass it as `since` next time."},"documents":{"type":"array","items":{"$ref":"#/components/schemas/ExportedDocument"},"description":"Changed documents, oldest change first."},"deleted":{"type":"array","items":{"$ref":"#/components/schemas/DeletedDocument"},"description":"Documents deleted since `since`. Sent on the first page of an export that named `since`."},"resync":{"type":"boolean","description":"`true` when more documents were deleted than one export lists. Drop your copy and export again without `since`."},"next_cursor":{"type":"string","description":"Pass it as `cursor` to read the next page. Empty on the last page."}}},"AgentHistoryTurn":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["user","assistant"]},"text":{"type":"string","description":"What was said. The field is `text` here, not `content` as in a completion."}}},"AgentTurnRequest":{"type":"object","required":["message"],"properties":{"message":{"type":"string","minLength":1,"maxLength":8000,"description":"What the person said. At most 8000 bytes of UTF-8."},"session_id":{"type":"string","format":"uuid","description":"The `session_id` an earlier turn returned. It labels the turns of one conversation. It does not bring earlier turns back."},"history":{"type":"array","maxItems":200,"items":{"$ref":"#/components/schemas/AgentHistoryTurn"},"description":"Earlier turns of this conversation, oldest first. The agent sees only what you send here."},"language":{"type":"string","description":"Language code to answer in, such as `bn`."},"caller_id":{"type":"string","description":"A phone number for the person, if you have one."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."}}},"AgentTurnResult":{"type":"object","required":["session_id","text","sources","usage"],"properties":{"session_id":{"type":"string","format":"uuid","description":"The id of this conversation. Send it on the next turn."},"text":{"type":"string","description":"The reply."},"quick_replies":{"type":"array","items":{"type":"string"},"description":"Suggested next messages. Left out when there are none."},"image_url":{"type":"string","description":"An image the agent attached. Left out when there is none."},"sources":{"type":"integer","description":"How many knowledge sources the reply cited. A count, not a list."},"model":{"type":"string","description":"The model that answered. Left out when it is not known."},"tool_fired":{"type":"boolean","description":"`true` when the agent called a connected tool. Left out when false."},"flow_fired":{"type":"boolean","description":"`true` when a guided flow answered in place of the model. Left out when false."},"usage":{"$ref":"#/components/schemas/Usage"}}},"SpeakRequest":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":1,"maxLength":2000,"description":"The text to speak. At most 2000 characters."},"lang":{"type":"string","description":"A language code such as `en` or `bn`. Left out, it is read from the text."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."}}},"Transcription":{"type":"object","required":["text","language"],"properties":{"text":{"type":"string","description":"What was said."},"language":{"type":"string","description":"The language that was heard."}}},"CallQuestion":{"type":"object","description":"One thing the call must find out. The answer is recorded under the question's `id`.","required":["id","ask","type"],"properties":{"id":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,39}$","description":"Unique within the script. Lower case letters, digits and underscores."},"ask":{"type":"string","description":"The question, as the agent asks it."},"type":{"type":"string","enum":["yes_no","choice","rating","number","date","text"]},"options":{"type":"array","items":{"type":"string"},"description":"For `choice`: at least two options."},"min":{"type":"integer","description":"For `rating`: the lowest value."},"max":{"type":"integer","maximum":10,"description":"For `rating`: the highest value. Higher than `min`, at most 10."},"required":{"type":"boolean","default":false},"when":{"type":"string","description":"Ask only when an earlier question was answered a given way, for example `on_time == no` or `rating != 5`."},"dtmf":{"type":"object","additionalProperties":{"type":"string"},"description":"Keypad answers. Each key is a single digit, `*` or `#`, and maps to the answer it stands for."}}},"CallScript":{"type":"object","description":"A one-off script. It needs a `goal` or at least one question. `{{name}}` gaps are filled from `variables`.","properties":{"opening":{"type":"string","description":"The first thing the agent says."},"goal":{"type":"string","description":"What the call should achieve."},"questions":{"type":"array","maxItems":12,"items":{"$ref":"#/components/schemas/CallQuestion"}},"closing":{"type":"object","additionalProperties":{"type":"string"},"description":"Closing lines. `default` is used unless a key matches the first question's answer (`yes` or `no` for a `yes_no` question)."},"voicemail":{"type":"string","description":"What to leave on voicemail."},"lang":{"type":"string","description":"The language of the call. The request's own `lang` wins when both are sent."}}},"CallRequest":{"type":"object","description":"Give the call something to say: a `script_id`, a `script`, or an `opening` and a `goal`.","required":["to","purpose","consent_basis"],"properties":{"to":{"type":"string","pattern":"^\\+[1-9][0-9]{6,14}$","description":"The number to call, in E.164 form. Premium-rate and short-code ranges are refused."},"purpose":{"type":"string","enum":["confirmation","reminder","survey","collection","callback","notification"],"description":"Why you are calling. Marketing calls are refused."},"consent_basis":{"type":"string","enum":["requested","transaction","relationship","explicit"],"description":"Why you are allowed to call. It must fit the purpose: a `callback` needs `requested`. A `confirmation` or `reminder` needs `transaction`, `requested` or `explicit`. The other purposes accept any of the four."},"opening":{"type":"string","maxLength":500,"description":"The first thing the agent says. At most 500 bytes of UTF-8. Sent alone, it is also used as the goal."},"goal":{"type":"string","maxLength":500,"description":"What the call should achieve. At most 500 bytes of UTF-8."},"script_id":{"type":"string","format":"uuid","description":"The id of a script published for the app. Its purpose must match `purpose`."},"script":{"allOf":[{"$ref":"#/components/schemas/CallScript"}],"description":"A one-off script with questions. At most 16 KB."},"variables":{"type":"object","maxProperties":32,"additionalProperties":{"type":"string"},"description":"String values that fill `{{name}}` gaps in a script."},"from":{"type":"string","pattern":"^\\+[1-9][0-9]{6,14}$","description":"The number to call from, in E.164 form. It must be an active number the app holds. Left out, one of the app's numbers is used."},"tz":{"type":"string","description":"The person's time zone, such as `America/Chicago`. Required unless the number starts with `+880` or `+44`, where the zone is known from the number."},"lang":{"type":"string","description":"The language of the call."},"not_before":{"type":"string","format":"date-time","description":"No attempt is made before this time."},"not_after":{"type":"string","format":"date-time","description":"The call expires if it has not been placed by this time."},"max_attempts":{"type":"integer","description":"How many times to try. The cap is 2, or 3 for `survey` and `collection`. A higher value, or none, uses the cap."},"callback_url":{"type":"string","format":"uri","pattern":"^https://","description":"An `https` URL that receives the outcome when the call is settled."},"fallback":{"type":"string","enum":["sms","whatsapp","task","none"],"default":"none","description":"What to do when every attempt fails."},"consent_ref":{"type":"string","description":"Your own reference for the consent, kept on the record."},"contact_ref":{"type":"string","description":"Your own id for the person."},"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."},"context":{"type":"object","additionalProperties":true,"description":"Where the person is, as the caller knows it: the object a widget page sends to `/context`, at most 2048 bytes. The agent reads it as an untrusted hint. `interaction: \"voice\"` makes it answer for the ear."},"stream":{"type":"boolean","default":false,"description":"Answer as Server-Sent Events: `delta` frames, then `done` with the whole turn."}}},"CallResult":{"type":"object","description":"An accepted call. It has been recorded, not placed.","required":["ref","from","to","status"],"properties":{"ref":{"type":"string","format":"uuid","description":"Keep it. It is how you read the call later."},"from":{"type":"string","description":"The number the call comes from."},"to":{"type":"string","description":"The number being called."},"status":{"type":"string","enum":["pending","suppressed"],"description":"`pending`: waiting to be placed. `suppressed`: the number is on the workspace's do-not-call list and will not be rung."},"next_attempt_at":{"type":"string","format":"date-time","description":"The earliest time of the next attempt."}}},"CallStatus":{"type":"object","required":["ref","status","attempts","max_attempts","result"],"properties":{"ref":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["pending","dialling","in_call","done","failed","suppressed","expired","cancelled"],"description":"`pending`: waiting for its next attempt. `in_call`: ringing or in progress. `done`: the person answered. `failed`: every attempt was used, or the call could not be placed. `suppressed`: the number is on the do-not-call list. `expired`: `not_after` passed before the call could be placed. `cancelled`: the call was cancelled before it was placed."},"outcome":{"type":"string","description":"On a `done` call: `completed` when every required question was answered, `partial` when some were, `answered` when no answers were recorded."},"disposition":{"type":"string","description":"How the last attempt ended, as the carrier reported it."},"attempts":{"type":"integer","description":"Attempts made so far."},"max_attempts":{"type":"integer"},"next_attempt_at":{"type":"string","format":"date-time","description":"Present while `status` is `pending`."},"result":{"type":"object","additionalProperties":true,"description":"The answers the agent recorded, keyed by question id. Empty until there are any."},"last_error":{"type":"string","description":"Why the call is waiting or why it failed."}}},"VoiceJobRequest":{"type":"object","description":"Give exactly one source: `source_url` or `source_call_id`.","required":["kind"],"oneOf":[{"required":["source_url"]},{"required":["source_call_id"]}],"properties":{"app":{"type":"string","description":"Handle of the app to run against. Needed only when the workspace has more than one app."},"kind":{"type":"string","enum":["transcribe","meeting_notes"]},"source_url":{"type":"string","format":"uri","pattern":"^https://","description":"An `https` URL of the recording, reachable from the public internet."},"source_call_id":{"type":"string","format":"uuid","description":"The id of a call in this workspace to use as the recording."},"lang":{"type":"array","items":{"type":"string"},"default":["en","bn"],"description":"Languages to expect."},"diarize":{"type":"boolean","default":false,"description":"Label who is speaking."},"template":{"type":"string","enum":["general","standup","client_call","interview","board"],"default":"general","description":"The notes template."},"callback_url":{"type":"string","format":"uri","pattern":"^https://","description":"An `https` URL that receives the finished job."}}},"VoiceJobOptions":{"type":"object","required":["diarize","keep_source"],"properties":{"lang":{"type":"array","items":{"type":"string"}},"diarize":{"type":"boolean"},"template":{"type":"string"},"keep_source":{"type":"boolean"}}},"TranscriptSegment":{"type":"object","description":"One run of speech by one speaker.","required":["start_ms","end_ms","text"],"properties":{"speaker":{"type":"string"},"start_ms":{"type":"integer"},"end_ms":{"type":"integer"},"text":{"type":"string"},"lang":{"type":"string"}}},"Transcript":{"type":"object","required":["text","segments","duration_ms"],"properties":{"text":{"type":"string"},"segments":{"type":"array","items":{"$ref":"#/components/schemas/TranscriptSegment"}},"duration_ms":{"type":"integer"}}},"ActionItem":{"type":"object","required":["item"],"properties":{"item":{"type":"string"},"owner":{"type":"string"},"due":{"type":"string"}}},"MeetingNotes":{"type":"object","required":["summary","decisions","action_items","open_questions"],"properties":{"summary":{"type":"string"},"decisions":{"type":"array","items":{"type":"string"}},"action_items":{"type":"array","items":{"$ref":"#/components/schemas/ActionItem"}},"open_questions":{"type":"array","items":{"type":"string"}}}},"VoiceJobResult":{"type":"object","description":"What a finished job holds.","properties":{"transcript":{"$ref":"#/components/schemas/Transcript"},"notes":{"$ref":"#/components/schemas/MeetingNotes"}}},"VoiceJob":{"type":"object","required":["id","workspace_id","kind","status","options","attempts","created_at"],"properties":{"id":{"type":"string","format":"uuid"},"workspace_id":{"type":"string","format":"uuid"},"app_id":{"type":"string","format":"uuid"},"kind":{"type":"string","enum":["transcribe","meeting_notes"]},"status":{"type":"string","enum":["queued","running","done","failed"],"description":"`queued`: accepted, not started. `running`: being transcribed. `done`: `result` is filled. `failed`: `error` says why."},"source_url":{"type":"string"},"source_call_id":{"type":"string","format":"uuid"},"options":{"$ref":"#/components/schemas/VoiceJobOptions"},"result":{"oneOf":[{"$ref":"#/components/schemas/VoiceJobResult"},{"type":"null"}],"description":"`null` until the job is done."},"audio_seconds":{"type":"integer","description":"The length of the audio. Present once it is known."},"error":{"type":"string","description":"Why the job failed."},"callback_url":{"type":"string"},"callback_state":{"type":"string","enum":["delivered","failed"],"description":"Whether the callback was delivered. Present once it has been sent."},"attempts":{"type":"integer"},"created_at":{"type":"string","format":"date-time"},"started_at":{"type":"string","format":"date-time"},"finished_at":{"type":"string","format":"date-time"}}},"Customer":{"type":"object","required":["id","tags","custom_fields"],"properties":{"id":{"type":"string","format":"uuid"},"external_id":{"type":"string","description":"Left out when the customer has none."},"email":{"type":"string","description":"Left out when the customer has none."},"phone":{"type":"string","description":"Left out when the customer has none."},"name":{"type":"string","description":"Left out when the customer has none."},"tags":{"type":"array","items":{"type":"string"}},"custom_fields":{"type":"object","additionalProperties":true}}},"CustomerUpdateRequest":{"type":"object","required":["custom_fields"],"properties":{"custom_fields":{"type":"object","additionalProperties":true,"description":"Keys to set. They are merged one level deep: a key you send replaces the key of the same name, and keys you do not send are kept."}}},"CustomerUpdateResult":{"type":"object","required":["id","custom_fields"],"properties":{"id":{"type":"string","format":"uuid"},"custom_fields":{"type":"object","additionalProperties":true,"description":"The merged result."}}},"Block":{"type":"object","description":"One content block of a message. Every block needs a `type`. The other fields depend on the type, for example `{\"type\": \"text\", \"markdown\": \"...\"}`.","required":["type"],"properties":{"type":{"type":"string","minLength":1}},"additionalProperties":true},"PostMessageRequest":{"type":"object","required":["blocks"],"properties":{"blocks":{"type":"array","minItems":1,"maxItems":12,"items":{"$ref":"#/components/schemas/Block"}}}},"PostMessageResult":{"type":"object","required":["message_id"],"properties":{"message_id":{"type":"string","format":"uuid"}}},"LinkedinPublishRequest":{"type":"object","required":["text"],"properties":{"text":{"type":"string","minLength":1,"maxLength":3000,"description":"The post. At most 3000 characters."},"app":{"type":"string","description":"Handle of the app whose Page to publish to. Required when more than one app in the workspace has a connected Page."}}},"LinkedinPublishResult":{"type":"object","required":["ext_id"],"properties":{"ext_id":{"type":"string","description":"LinkedIn's id for the post."},"permalink_url":{"type":"string","description":"A link to the post."}}},"CredentialSubject":{"type":"object","description":"The user the token belongs to.","required":["id"],"properties":{"id":{"type":"string","minLength":1,"description":"Your id for the user."},"login":{"type":"string","description":"Kept for your own audit trail."},"name":{"type":"string","description":"Kept for your own audit trail."}}},"BindCredentialRequest":{"type":"object","required":["token","expires_at","subject"],"properties":{"token":{"type":"string","minLength":1,"maxLength":4096,"description":"The user's token for your MCP server."},"expires_at":{"type":"string","format":"date-time","description":"When the token expires. It must be in the future and at most 24 hours ahead."},"subject":{"$ref":"#/components/schemas/CredentialSubject"}}},"BindCredentialResult":{"type":"object","required":["bound","subject_key","expires_at","verified"],"properties":{"bound":{"type":"boolean","const":true},"subject_key":{"type":"string","description":"The `subject.id` the conversation is bound to."},"expires_at":{"type":"string","format":"date-time"},"verified":{"type":"string","enum":["whoami","host"],"description":"Who proved the subject: `whoami` (your MCP server) or `host` (you, for a server whose `subject_check` is `host`)."}}},"UnbindCredentialResult":{"type":"object","required":["revoked"],"properties":{"revoked":{"type":"boolean","const":true}}},"JsonRpcRequest":{"type":"object","description":"One JSON-RPC 2.0 message. A message without an `id` is a notification and gets no answer.","required":["jsonrpc","method"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"type":["string","integer"],"description":"Echoed in the answer."},"method":{"type":"string","description":"`initialize`, `ping`, `tools/list` or `tools/call`."},"params":{"type":"object","additionalProperties":true,"description":"For `tools/call`: `name` and `arguments`."}}},"JsonRpcError":{"type":"object","required":["code","message"],"properties":{"code":{"type":"integer","description":"`-32700`: the body is not JSON. `-32600`: not a JSON-RPC 2.0 message, or a batch over 20. `-32601`: a method this server does not implement. `-32602`: a tool that does not exist for this token, or `params.name` is missing."},"message":{"type":"string"}}},"JsonRpcResponse":{"type":"object","description":"One JSON-RPC 2.0 answer. It carries `result` or `error`.","required":["jsonrpc","id"],"properties":{"jsonrpc":{"type":"string","const":"2.0"},"id":{"type":["string","integer","null"]},"result":{"type":"object","additionalProperties":true},"error":{"$ref":"#/components/schemas/JsonRpcError"}}},"VoiceMinutesAllowance":{"type":"object","description":"Voice minutes used and included in the current billing period. Speech, voice jobs and phone calls all draw on them.","required":["used","limit","resets_at"],"properties":{"used":{"type":"integer","description":"Voice minutes used this period."},"limit":{"type":"integer","description":"Voice minutes the plan includes. `-1` means the plan does not cap them."},"resets_at":{"type":"string","format":"date-time","description":"When the period resets."}}},"AgentModel":{"type":"object","description":"The binding the agent answers on.","required":["id","source","overridden","max_tokens","temperature"],"properties":{"id":{"type":"string","description":"The model, in the form the gateway takes it.","example":"openai/gpt-4o"},"source":{"type":"string","enum":["app","workspace","platform"],"description":"Where the binding comes from. `app` when the agent has its own; otherwise the one it inherits."},"overridden":{"type":"boolean","description":"True when the agent has its own binding."},"inherited_model":{"type":"string","description":"What the agent would answer on without its own binding. Present only when `overridden` is true."},"max_tokens":{"type":["integer","null"],"description":"The cap on one reply. Null leaves the platform's own cap."},"temperature":{"type":["number","null"],"description":"Null leaves the model's default."}}},"AgentModelOption":{"type":"object","description":"A model this workspace may set, on its plan.","required":["id","label","vendor","tier","tools","source"],"properties":{"id":{"type":"string","example":"openai/gpt-4o"},"label":{"type":"string"},"vendor":{"type":"string"},"tier":{"type":"string","description":"The capability tier the plan gates on."},"tools":{"type":"boolean","description":"True when the model can call tools."},"source":{"type":"string","description":"`managed` for the platform's provider, `byo` for the workspace's own."}}},"AgentLoop":{"type":"object","description":"What a turn of the agent does, and which of those the agent set for itself.","required":["harness","stream","redact","memory","files","overrides"],"properties":{"harness":{"type":"boolean","description":"The turn runs on the shared agent loop."},"stream":{"type":"boolean","description":"The reply is sent as it is written."},"redact":{"type":"boolean","description":"Personal data is masked in the reply."},"memory":{"type":"boolean","description":"The agent has `remember` and `forget` tools: a person can ask it to keep something about them for their later conversations, or to drop it. Each person sees and deletes their own memories. Off unless set. While on, every turn runs on the tool loop."},"files":{"type":"boolean","description":"The agent has a `create_file` tool: it writes a Word document, a Markdown or text file, or a CSV, and hands it over as a download under its reply (a `file` block with a signed link). Off unless set. While on, every turn runs on the tool loop."},"overrides":{"type":"object","description":"The switches this agent set. A switch that is not here follows the platform's default.","properties":{"harness":{"type":"boolean"},"stream":{"type":"boolean"},"redact":{"type":"boolean"},"memory":{"type":"boolean"},"files":{"type":"boolean"}}}}},"AgentSettings":{"type":"object","description":"How the agent runs.","required":["app_id","app","model","models","loop"],"properties":{"app_id":{"type":"string","format":"uuid"},"app":{"type":"string","description":"The app's handle."},"model":{"$ref":"#/components/schemas/AgentModel"},"models":{"type":"array","description":"The models this workspace may set, on its plan.","items":{"$ref":"#/components/schemas/AgentModelOption"}},"plan_tier":{"type":"string","description":"The plan's model tier."},"loop":{"$ref":"#/components/schemas/AgentLoop"}}},"AgentSettingsUpdateRequest":{"type":"object","description":"A field left out is left as it is. Null puts a field back to what the agent inherits.","properties":{"app":{"type":"string","description":"Handle of the app. Needed only when the workspace has more than one app."},"model":{"type":["string","null"],"maxLength":200,"description":"The model the agent answers on, one of `models` in the settings. Null removes the agent's own binding: the model, `max_tokens` and `temperature` go back to what it inherits.","example":"openai/gpt-4o"},"max_tokens":{"type":["integer","null"],"minimum":16,"maximum":32000,"description":"The cap on one reply. Null removes the agent's own cap."},"temperature":{"type":["number","null"],"minimum":0,"maximum":2,"description":"Null removes the agent's own value."},"loop":{"type":"object","description":"The loop switches. Null puts a switch back to the platform's default.","properties":{"harness":{"type":["boolean","null"]},"stream":{"type":["boolean","null"]},"redact":{"type":["boolean","null"]},"memory":{"type":["boolean","null"]},"files":{"type":["boolean","null"]}}}}},"McpServer":{"type":"object","description":"One MCP tool server the agent may call. The credential is never part of it.","required":["id","name","endpoint_url","auth_type","allowed_tools","is_active","write_mode","action_policy","subject_check","has_credentials","created_at","updated_at"],"properties":{"id":{"type":"string","format":"uuid"},"name":{"type":"string","description":"Unique within the app, ignoring case. The agent's tools are named after it: `mcp_<name>__<tool>`."},"endpoint_url":{"type":"string","format":"uri","description":"The server's Streamable HTTP endpoint. https, on a public host."},"auth_type":{"type":"string","enum":["none","bearer","header","session_bearer"],"description":"How the agent signs in to the server. `session_bearer` holds no shared secret: each signed-in user brings a token of their own, bound through `PUT /sessions/{sid}/mcp-credentials/{server}`."},"allowed_tools":{"type":"array","items":{"type":"string"},"description":"The tools the agent may use. Empty means every tool the server lists."},"is_active":{"type":"boolean","description":"An inactive server is kept and not called."},"write_mode":{"type":"string","enum":["open","read_only","confirm","trusted"],"description":"What the agent may do with a tool that changes data. `confirm` shows the visitor a card first. `read_only` hides such tools. `trusted` runs them. `open` treats every tool alike."},"action_policy":{"type":"object","description":"Per-tool rules and how results are shown. `{}` when none is set.","additionalProperties":true},"subject_check":{"type":"string","enum":["whoami","host"],"description":"Who proves whose token a conversation carries on a `session_bearer` server. `whoami`: the server's own `whoami` tool is asked, and must name the `subject.id` you bind. `host`: you vouch for it, for a server that has no `whoami` (Notion, Slack, Microsoft 365), because your backend ran that person's own sign-in with the server. The conversation is locked to one person either way. `host` is refused on any other auth type, and a server moved off `session_bearer` goes back to `whoami`."},"has_credentials":{"type":"boolean","description":"Whether a credential is stored."},"created_at":{"type":"string","format":"date-time"},"updated_at":{"type":"string","format":"date-time"}}},"McpServerCreateRequest":{"type":"object","required":["name","endpoint_url","auth_type"],"properties":{"name":{"type":"string","maxLength":80,"description":"Unique within the app, ignoring case."},"endpoint_url":{"type":"string","format":"uri","maxLength":2000,"description":"https, on a public host."},"auth_type":{"type":"string","enum":["none","bearer","header","session_bearer"]},"credentials":{"type":"string","maxLength":8192,"writeOnly":true,"description":"The bearer token for `bearer`, or `Header-Name: value` for `header`. Stored encrypted and never returned. Not allowed with `none` or `session_bearer`."},"allowed_tools":{"type":"array","maxItems":200,"items":{"type":"string","maxLength":128},"description":"Left out or empty, the agent may use every tool the server lists."},"is_active":{"type":"boolean","default":true},"write_mode":{"type":"string","enum":["open","read_only","confirm","trusted"],"default":"confirm"},"action_policy":{"type":"object","additionalProperties":true},"subject_check":{"type":"string","enum":["whoami","host"],"description":"Who proves whose token a conversation carries on a `session_bearer` server. `whoami`: the server's own `whoami` tool is asked, and must name the `subject.id` you bind. `host`: you vouch for it, for a server that has no `whoami` (Notion, Slack, Microsoft 365), because your backend ran that person's own sign-in with the server. The conversation is locked to one person either way. `host` is refused on any other auth type, and a server moved off `session_bearer` goes back to `whoami`.","default":"whoami"},"app":{"type":"string","description":"Handle of the app. Needed only when the workspace has more than one app."}}},"McpServerUpdateRequest":{"type":"object","description":"A field left out is left as it is.","properties":{"name":{"type":"string","maxLength":80},"endpoint_url":{"type":"string","format":"uri","maxLength":2000},"auth_type":{"type":"string","enum":["none","bearer","header","session_bearer"],"description":"Changing to `session_bearer` removes the stored credential."},"credentials":{"type":"string","maxLength":8192,"writeOnly":true,"description":"Replaces the stored credential. An empty string removes it."},"allowed_tools":{"type":"array","maxItems":200,"items":{"type":"string","maxLength":128},"description":"Replaces the list. `[]` allows every tool."},"is_active":{"type":"boolean"},"write_mode":{"type":"string","enum":["open","read_only","confirm","trusted"]},"action_policy":{"type":"object","additionalProperties":true,"description":"Replaces the policy."},"subject_check":{"type":"string","enum":["whoami","host"],"description":"Who proves whose token a conversation carries on a `session_bearer` server. `whoami`: the server's own `whoami` tool is asked, and must name the `subject.id` you bind. `host`: you vouch for it, for a server that has no `whoami` (Notion, Slack, Microsoft 365), because your backend ran that person's own sign-in with the server. The conversation is locked to one person either way. `host` is refused on any other auth type, and a server moved off `session_bearer` goes back to `whoami`."},"app":{"type":"string"}}},"McpServerDeleted":{"type":"object","required":["id","deleted"],"properties":{"id":{"type":"string","format":"uuid"},"deleted":{"type":"boolean","const":true}}},"UsageTotals":{"type":"object","description":"What was used and what it cost over a span. The cost fields come from the platform's cost ledger, the last four from the plan's counters; the two are never added together.","required":["model_calls","cache_hits","errors","input_tokens","output_tokens","cached_input_tokens","speech_sessions","speech_seconds","cost_micros","cost_usd","estimated_cost_micros","unpriced_calls","conversations","ai_turns","api_calls","voice_minutes"],"properties":{"model_calls":{"type":"integer","description":"Calls to a model: completions, each model round of an agent turn, knowledge search embeddings. Speech is counted apart."},"cache_hits":{"type":"integer","description":"Model calls the gateway answered from its response cache. They cost nothing and are counted in model_calls."},"errors":{"type":"integer","description":"Calls, model or speech, that failed."},"input_tokens":{"type":"integer","description":"Input tokens of the model calls."},"output_tokens":{"type":"integer","description":"Output tokens of the model calls."},"cached_input_tokens":{"type":"integer","description":"The part of input_tokens the provider served from its prompt cache."},"speech_sessions":{"type":"integer","description":"Speech to text and text to speech sessions: one per request or stream."},"speech_seconds":{"type":"number","description":"Seconds of audio heard or spoken."},"cost_micros":{"type":"integer","description":"What the calls cost, in millionths of a US dollar. Calls on the workspace's own provider key are not in it."},"cost_usd":{"type":"number","description":"cost_micros in US dollars."},"estimated_cost_micros":{"type":"integer","description":"The part of cost_micros priced from an estimate: a list price, or a quantity the vendor did not report."},"unpriced_calls":{"type":"integer","description":"Calls with no price at all. They are not in cost_micros."},"conversations":{"type":"integer","description":"Conversations started, as the plan counts them."},"ai_turns":{"type":"integer","description":"AI turns, as the plan counts them."},"api_calls":{"type":"integer","description":"Core API calls, as the plan counts them."},"voice_minutes":{"type":"integer","description":"Voice minutes, as the plan counts them: rounded up per session with a one-minute floor."}}},"UsageDay":{"allOf":[{"$ref":"#/components/schemas/UsageTotals"},{"type":"object","required":["date"],"properties":{"date":{"type":"string","format":"date","description":"The UTC day."}}}]},"UsageReport":{"type":"object","required":["workspace_id","from","to","totals","days"],"properties":{"workspace_id":{"type":"string","format":"uuid"},"from":{"type":"string","format":"date"},"to":{"type":"string","format":"date"},"totals":{"$ref":"#/components/schemas/UsageTotals"},"days":{"type":"array","description":"Every day of the range, oldest first, empty days included.","items":{"$ref":"#/components/schemas/UsageDay"}}}}}}}