{"openapi":"3.1.0","info":{"title":"Rylvo Public API","version":"1.0.0","description":"The public Rylvo REST surface: run an agentic bot turn, read/write the knowledge base, read/change a bot's tracked details (state), and ask from CI whether a bot's tests clear the release gate — with an org API key. Configuration (bots, prompts, guardrails, flows, connectors, …) is managed in the dashboard or through the MCP endpoint at POST /mcp, not through this API.","contact":{"name":"Rylvo Engineering","url":"https://rylvo.com"}},"servers":[{"url":"https://rylvo.com","description":"Rylvo production"}],"security":[{"bearerApiKey":[]},{"apiKeyHeader":[]},{"rylvoKeyHeader":[]}],"tags":[{"name":"Runtime","description":"Execute bot turns."},{"name":"Knowledge Base","description":"Query and maintain KB documents."},{"name":"Tracked details","description":"Typed details a bot remembers per conversation (`session`), per person (`person`) or shared (`bot`, subject `shared`). Every change is a revision."},{"name":"Memory","description":"Long-term memories a bot keeps about each person (`scope: person`, `subjectId` = their endUserExternalId) and for everyone (`scope: shared`). New memories that say what an existing one says update it instead."},{"name":"Sessions","description":"A bot's conversations: list and search them (by person, status or tracked details), read one with its transcript, end one, fork one."},{"name":"Tests","description":"Ask whether a bot's tests clear the release gate."}],"components":{"securitySchemes":{"bearerApiKey":{"type":"http","scheme":"bearer","description":"Org API key, `rylv_<40 hex>`, created in Dashboard → API Keys. Scopes: `respond`, `kb:read`, `kb:write`, `state:read`, `state:write`, `sessions:read`, `sessions:write`, `memory:read`, `memory:write`, `tests:read`."},"apiKeyHeader":{"type":"apiKey","in":"header","name":"X-API-Key"},"rylvoKeyHeader":{"type":"apiKey","in":"header","name":"X-Rylvo-Key"}},"schemas":{"Error":{"type":"object","required":["error","code"],"properties":{"error":{"type":"string","description":"Human-readable failure message."},"code":{"type":"string","description":"Stable machine-readable error code."}}},"StateRecord":{"type":"object","description":"One record's values. Sensitive values read as \"[sensitive]\".","properties":{"scope":{"type":"string","enum":["session","person","bot"]},"subjectId":{"type":"string"},"exists":{"type":"boolean"},"revision":{"type":"integer","description":"Send as `expectedRevision` to guard a write."},"updatedAtMs":{"type":["integer","null"]},"environment":{"type":"string","enum":["test","production"]},"values":{"type":"object","additionalProperties":true},"fields":{"type":"array","items":{"type":"object","properties":{"key":{"type":"string"},"label":{"type":"string"},"type":{"type":"string"},"set":{"type":"boolean"},"isDefault":{"type":"boolean"},"sensitive":{"type":"boolean"},"updatedAtMs":{"type":"integer"},"by":{"type":"string","enum":["bot","api","team","restore","system","carry_over"]},"expiresAtMs":{"type":"integer"}}}},"sessionRules":{"type":"array","description":"On a write: the conversation rules it set off. The matching live conversations end (see `sessionsEnded`); the person's next message starts a new one.","items":{"type":"object","properties":{"ruleId":{"type":"string"},"label":{"type":"string"},"key":{"type":"string"},"scope":{"type":"string","enum":["session","person"]},"op":{"type":"string","enum":["becomes","changes","is_set","is_cleared"]}}}},"sessionsEnded":{"type":["integer","null"],"description":"On a write that set off a rule: how many live conversations ended (null when ending failed)."}}},"StatePatchRequest":{"type":"object","properties":{"ops":{"type":"array","maxItems":50,"items":{"type":"object","required":["field"],"properties":{"field":{"type":"string"},"op":{"type":"string","enum":["update","replace","clear"],"default":"update","description":"`update` applies the detail's update behavior (append, increment, merge, …); `replace` sets this exact value; `clear` removes it."},"value":{}}}},"values":{"type":"object","additionalProperties":true,"description":"Shorthand: one `update` per key."},"expectedRevision":{"type":"integer","description":"Fail with 409 if the record changed since this revision."},"idempotencyKey":{"type":"string","maxLength":200,"description":"Or send the `Idempotency-Key` header."}}},"Memory":{"type":"object","properties":{"memoryId":{"type":"string"},"scope":{"type":"string","enum":["person","shared"]},"subjectId":{"type":"string"},"text":{"type":"string","maxLength":500},"kind":{"type":"string","enum":["fact","preference","event"]},"tags":{"type":"array","items":{"type":"string"}},"pinned":{"type":"boolean","description":"Always shown to the bot; never expires."},"status":{"type":"string","enum":["active","pending"],"description":"`pending` = a shared memory waiting for review."},"source":{"type":"object","properties":{"kind":{"type":"string","enum":["bot","extractor","api","team"]},"actor":{"type":"string"}}},"createdAtMs":{"type":"integer"},"updatedAtMs":{"type":"integer"},"lastUsedAtMs":{"type":["integer","null"]},"useCount":{"type":"integer"},"expiresAtMs":{"type":["integer","null"]},"searchable":{"type":"boolean","description":"Has a vector for search by meaning."}}},"Session":{"type":"object","properties":{"sessionId":{"type":"string"},"botId":{"type":"string"},"endUserExternalId":{"type":["string","null"]},"channel":{"type":["string","null"]},"status":{"type":"string","enum":["open","ended"]},"startedAt":{"type":["string","null"],"format":"date-time"},"startedReason":{"type":["string","null"]},"lastActivityAt":{"type":["string","null"],"format":"date-time"},"endedAt":{"type":["string","null"],"format":"date-time"},"endedReason":{"type":["string","null"]},"endedNote":{"type":["string","null"]},"turnCount":{"type":"integer"},"forkedFrom":{"type":["object","null"],"properties":{"sessionId":{"type":"string"},"throughMessageId":{"type":["string","null"]},"stateRevision":{"type":["integer","null"]}}}}},"StateConfig":{"type":"object","properties":{"enabled":{"type":"boolean"},"instructions":{"type":"string"},"configVersion":{"type":"integer"},"fields":{"type":"array","items":{"type":"object","additionalProperties":true}},"sessionRules":{"type":"array","maxItems":20,"description":"Start a new conversation when a detail remembered for the conversation or the person changes. Omit on PUT to keep the saved rules.","items":{"type":"object","required":["field","op"],"properties":{"ruleId":{"type":"string"},"field":{"type":"string","description":"The detail's key."},"op":{"type":"string","enum":["becomes","changes","is_set","is_cleared"],"description":"Fires on the transition: `becomes` a value, `changes` from one value to another, gets its first value, or is emptied."},"value":{"description":"For `becomes`."},"label":{"type":"string","maxLength":80},"enabled":{"type":"boolean","default":true}}}},"context":{"type":"object","description":"Settings for the run `context` sent to bot-run. Omit on PUT to keep the saved settings.","properties":{"schema":{"type":"object","description":"JSON Schema (type object) every `context` must match."},"shownToBot":{"type":"boolean","default":true,"description":"Show the context to the bot as RUN CONTEXT."}}}}},"Message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string"}}},"KnownFact":{"type":"object","required":["key","value"],"properties":{"key":{"type":"string","pattern":"^[a-z][a-z0-9_]{0,63}$","description":"A Data Collection field key of the bot: lower case letters, digits and underscores, starting with a letter, at most 64 characters. Send each key once."},"value":{"type":"string","maxLength":1000,"description":"What you know, as text. A blank value is ignored."}}},"BotRunRequest":{"type":"object","required":["message"],"description":"Exactly one of `botId` or `groupId` is required.","properties":{"botId":{"type":"string","description":"Bot id from Dashboard → Bots."},"groupId":{"type":"string","description":"Agent-group id. Wins if both are sent."},"message":{"type":"string","description":"The end user's current message."},"conversationHistory":{"type":"array","items":{"$ref":"#/components/schemas/Message"},"description":"Prior turns. Omit it for an identified end user and the server replays the session's own transcript."},"sessionId":{"type":["string","null"],"description":"Session hint. Honored only alongside `endUserExternalId`; the server may return a fresh id — always send back the `sessionId` from the last response."},"endUserExternalId":{"type":["string","null"],"maxLength":256,"description":"Stable end-user id in your namespace. Required for server-side session memory and for the two fields below."},"endUserDisplayName":{"type":["string","null"],"maxLength":200},"endUserEmail":{"type":["string","null"],"format":"email","maxLength":320},"endUserAccessGroups":{"type":"array","items":{"type":"string"},"maxItems":200,"description":"Groups your system asserts for this end user. Knowledge connections with `config.accessControl.mode: \"restricted\"` ground the reply only in documents whose `accessGroups` intersect these, and in nothing when none are sent. Not accepted from the widget."},"known_facts":{"type":"array","maxItems":20,"items":{"$ref":"#/components/schemas/KnownFact"},"description":"What you already know about this person, so the bot doesn't ask for it again: each entry names a Data Collection field of the bot (`key`, e.g. `email`) and its `value`. Facts are your word, not the person's: used to decide what to ask, never saved to the Audience, and a `key` the bot has no field for does nothing. A value only counts if it would be accepted as an answer to that field (its type, options and pattern; not a placeholder such as `n/a`), never for a field that has an external validator, and never toward a checkpoint; otherwise the bot asks. Anything sent with the public widget key is the visitor's browser talking, and the bot reads it as not checked. A malformed list is a 400 (`invalid_request`). The widget's `RylvoWidget.identify()` sends its values here."},"channel":{"type":"string","enum":["api","widget","unknown"],"default":"api","description":"Operator surfaces (`test`, `dashboard`) and deployed-channel identities (`whatsapp`, `slack`, …) are set server-side and are rejected here."},"model":{"type":["string","null"],"description":"Model override for this turn."},"maxTokens":{"type":"integer"},"temperature":{"type":"number"},"disableTools":{"type":"boolean"},"maxToolIterations":{"type":"integer"},"responseFormat":{"type":"object","description":"Structured output: {\"type\":\"json_object\"} or {\"type\":\"json_schema\", …}."},"context":{"type":["object","null"],"additionalProperties":true,"description":"Run context: facts your app sends with this message (the person's plan, the page they're on), ≤16 KB. Checked against the bot's context schema (422 with `details.problems` when it doesn't match), shown to the bot and usable as {{context.key}} in prompts. Never stored. Ignored from the widget."},"stream":{"type":"boolean","description":"Stream the reply as Server-Sent Events. Single-bot only; `Idempotency-Key` is ignored."}}},"BotRunResponse":{"type":"object","required":["response","runId","model"],"properties":{"response":{"type":"string","description":"The assistant's reply."},"conversationId":{"type":"string","description":"The effective session id, or an empty string when the turn ran without an identified end user."},"sessionId":{"type":["string","null"],"description":"Session id to send on the next turn; null when no session was resolved."},"sessionNew":{"type":"boolean"},"runId":{"type":"string","description":"Trace id — find it in Dashboard → Traces."},"model":{"type":"string"},"latencyMs":{"type":"number"},"tokens":{"type":"object","properties":{"prompt":{"type":"integer"},"completion":{"type":"integer"},"total":{"type":"integer"}}},"guardrails":{"type":"object","properties":{"inputBlocked":{"type":"boolean","description":"A guardrail blocked the user's message before the model ran."},"outputBlocked":{"type":"boolean","description":"A guardrail blocked the bot's reply after it was generated."},"outputRewritten":{"type":"boolean"},"blockedBy":{"type":["string","null"]},"escalated":{"type":"boolean"},"escalatedBy":{"type":["string","null"]}}},"toolCalls":{"type":"array","items":{"type":"object"}},"augmentation":{"type":"object","properties":{"rulesApplied":{"type":"integer"},"skillsMatched":{"type":"integer"},"episodicRecallCount":{"type":"integer"},"userModelApplied":{"type":"boolean"}}},"collectionEvents":{"type":"array","items":{"type":"object"},"description":"Data-collection writes attempted this turn."},"collectionState":{"type":"object","description":"Slot-filling state after this turn."},"sessionEnd":{"type":["object","null"]},"kb":{"type":["object","null"],"description":"KB grounding telemetry and citations."},"pendingApproval":{"type":["object","null"]},"fallback":{"type":"string","enum":["lead_capture"],"description":"Widget traffic only (`channel: \"widget\"`), when the workspace's own AI key cannot answer: `response` then asks the visitor to leave a name and number instead, and `fallbackToken` is what `POST /api/v1/widget-lead` takes to save what they leave. API traffic gets a `provider_key_unavailable` error instead."},"fallbackToken":{"type":"string","description":"Present with `fallback`. Signed, bound to this workspace, bot and visitor, and valid for 30 minutes."}}},"WidgetLeadRequest":{"type":"object","required":["token","contact"],"properties":{"token":{"type":"string","description":"The `fallbackToken` from the bot-run reply whose `fallback` is `lead_capture`."},"name":{"type":"string","maxLength":80,"description":"Optional."},"contact":{"type":"string","description":"A phone number or an email address."}}},"WidgetLeadResponse":{"type":"object","required":["ok","message"],"properties":{"ok":{"type":"boolean"},"message":{"type":"string","description":"What to show the visitor."}}},"KbQueryRequest":{"type":"object","required":["connectionId","query"],"properties":{"connectionId":{"type":"string"},"query":{"type":"string"},"topK":{"type":"integer","minimum":1,"maximum":100,"default":5},"accessGroups":{"type":"array","items":{"type":"string"},"maxItems":200,"description":"End-user access groups. A connection with `config.accessControl.mode: \"restricted\"` returns only chunks from documents whose `accessGroups` intersect these, and no results when none are given. Shared connections ignore it. Rylvo does not verify the groups; send only what your authenticated system asserts."},"filters":{"type":"object","description":"Optional retrieval filters. Supported keys: `sourceId`, `documentId`. Any other key is rejected with 400.","properties":{"sourceId":{"type":"string"},"documentId":{"type":"string"}},"additionalProperties":false}}},"KbQueryResponse":{"type":"object","properties":{"query":{"type":"string"},"connectionId":{"type":"string"},"results":{"type":"array","items":{"type":"object","properties":{"chunkId":{"type":"string"},"content":{"type":"string"},"score":{"type":"number"},"metadata":{"type":"object"}}}}}},"KbDocumentsRequest":{"type":"object","required":["sourceId","connectionId","documents"],"properties":{"sourceId":{"type":"string"},"connectionId":{"type":"string"},"documents":{"type":"array","minItems":1,"maxItems":100,"items":{"type":"object","required":["name","content"],"properties":{"id":{"type":"string","description":"Existing document id — supply it to update in place."},"name":{"type":"string"},"content":{"type":"string"},"mimeType":{"type":"string","default":"text/plain"},"metadata":{"type":"object"},"accessGroups":{"type":"array","items":{"type":"string"},"maxItems":200,"description":"Groups allowed to retrieve this document through a restricted connection. Omit on update to keep the current groups."}}}}}},"GateCriteria":{"type":"object","description":"What a run must show. With none set, the original rule: none of its tests fail and at least one passes.","properties":{"minPassRate":{"type":["number","null"],"minimum":0,"maximum":100,"description":"Percent of the run's tests that must pass; a test that errors counts as not passing."},"noFailingCritical":{"type":"boolean","description":"Every test marked critical must pass."},"testSetName":{"type":["string","null"],"maxLength":80,"description":"Only a run of the bot's test set with this name counts."},"minJudgeAgreement":{"type":["number","null"],"minimum":0,"maximum":100,"description":"Percent of your reviewers' verdicts the judge must agree with. Fewer than 10 verdicts on the bot and the gate does not pass."}},"additionalProperties":false},"GateRequest":{"type":"object","required":["botId"],"properties":{"botId":{"type":"string","description":"Bot id from Dashboard → Bots."},"runId":{"type":["string","null"],"description":"Judge this run. Otherwise the bot's latest completed run."},"testSetId":{"type":["string","null"],"description":"Only runs of this test set count."},"criteria":{"oneOf":[{"$ref":"#/components/schemas/GateCriteria"},{"type":"null"}],"description":"Criteria for this call. Omit it to use the ones saved in Tests → Release gate."}}},"GateResponse":{"type":"object","required":["passing","reasons","failing","criteria","botId"],"properties":{"passing":{"type":"boolean","description":"Whether the run clears the gate. Fail your pipeline when it is false."},"reasons":{"type":"array","items":{"type":"string"},"description":"Why it doesn't pass, a sentence each. Empty when it does."},"failing":{"type":"array","description":"Every test that didn't pass — critical first.","items":{"type":"object","properties":{"resultId":{"type":"string"},"testCaseId":{"type":"string"},"testCaseName":{"type":"string"},"priority":{"type":"string","enum":["critical","high","medium","low"]},"verdict":{"type":"string","enum":["fail","partial","error"]},"why":{"type":"string"},"url":{"type":["string","null"],"description":"The result in the dashboard."}}}},"criteria":{"$ref":"#/components/schemas/GateCriteria"},"botId":{"type":"string"},"runId":{"type":["string","null"],"description":"The run judged; null when no run qualifies."},"runStartedAt":{"type":["string","null"],"format":"date-time"},"runUrl":{"type":["string","null"],"description":"The run's report in the dashboard."},"testSetName":{"type":["string","null"]},"testSetVersion":{"type":["integer","null"]},"passed":{"type":"integer"},"failed":{"type":"integer"},"errors":{"type":"integer"},"passRate":{"type":["number","null"],"description":"Percent of the run's tests that passed."}}},"KbDocumentsResponse":{"type":"object","properties":{"success":{"type":"boolean"},"results":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["created","updated","error"]},"error":{"type":"string"}}}}}}}},"paths":{"/api/v1/bot-run":{"post":{"tags":["Runtime"],"operationId":"runBotTurn","summary":"Run one bot or agent-group turn","description":"Executes a full agentic turn on your own LLM key (BYOK): prompt assembly, guardrails, tools/connectors, KB retrieval, skills, reply. Requires the `respond` scope. Rate limited per API key (60/min by default, overridable per key); responses carry `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"},"description":"Stripe-style replay. Re-sending the same key returns the recorded response with `Idempotent-Replay: true`. Ignored when `stream` is true."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BotRunRequest"}}}},"responses":{"200":{"description":"The turn result. When `stream` is true the body is `text/event-stream` instead, ending with a `result` event carrying this same object.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BotRunResponse"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`bot_not_found` / `group_not_found` — no such bot or agent group in this org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"`bot_not_runnable` — the bot exists but is draft or archived. `conversation_busy` — this end user's conversation is still answering an earlier message (the bot's double-texting setting); retry after `Retry-After` seconds.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`provider_key_unavailable` — the workspace has no AI key this bot can use in this environment (`reason: key_missing`), or has keys but none this bot's model may use under its key routing (`reason: key_blocked`). `detail` is the runtime's own sentence naming the key to add; `provider` names it when known. Add one in Settings → LLM Providers.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"424":{"description":"`provider_key_unavailable` — the workspace's own AI key was rejected (`reason: key_rejected`), is out of credit with its provider (`out_of_credit`) or its included trial credit is spent (`trial_exhausted`), so no reply exists. Fix the key in Settings → LLM Providers; the workspace owner is emailed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"`engine_unreachable` — the runtime engine could not be reached.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`feature_disabled` / `engine_not_ready`. Also `provider_key_unavailable` with `reason: vault_unreadable` — a saved AI key could not be read on Rylvo's side; nothing to fix in the workspace, retry shortly.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/widget-lead":{"post":{"tags":["Runtime"],"operationId":"saveWidgetLead","summary":"Save the details a widget visitor leaves when the assistant cannot answer","description":"Called by the embeddable widget's small lead form, shown when the workspace's own AI key cannot answer (a `bot-run` reply with `fallback: \"lead_capture\"`). The lead goes where every captured lead goes: the Leads page, the in-app bell and the workspace's lead email, in the environment the failed turn ran in. The `token` must be one `bot-run` returned for this API key's workspace (and bot, for a bot-bound key) in the last 30 minutes, so only a visitor whose own turn failed can use it. Requires the `respond` scope. Rate limited per API key (10/min; a key's own rate-limit setting does not change this), per token, and per workspace per day (429).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/WidgetLeadRequest"}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WidgetLeadResponse"}}}},"400":{"description":"`invalid_json` / `invalid_request` — the body is not JSON, or `contact` is not a phone number or an email address.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"`invalid_token` — the token is missing, expired, tampered with, or belongs to another workspace or bot. Ask the visitor to send their message again. Also: key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`save_failed` — the lead could not be saved; the visitor should try again in a moment.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/kb/query":{"post":{"tags":["Knowledge Base"],"operationId":"queryKnowledgeBase","summary":"Run retrieval against a knowledge-base connection","description":"Requires the `kb:read` scope. Rate limited per API key (60/min by default).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KbQueryRequest"}}}},"responses":{"200":{"description":"Ranked chunks.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KbQueryResponse"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such connection in this org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`vector_store_unavailable`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/tests/gate":{"post":{"tags":["Tests"],"operationId":"checkReleaseGate","summary":"Does a bot's test run clear the release gate?","description":"For a CI pipeline to block a deploy. Judges the bot's latest completed test run (or the run named, or the latest of a test set) against the workspace's release gate — the same gate a release to Production waits on — or against criteria sent with the request. A judged bot is always a 200: read `passing`. Writes nothing. Requires the `tests:read` scope and the Enterprise plan. Rate limited per API key (30/min by default).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GateRequest"}}}},"responses":{"200":{"description":"The run through the gate.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GateResponse"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — the bot has no test runs, or no such run.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"502":{"description":"`engine_unreachable` / `engine_error` — the test engine could not answer.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"`engine_not_ready`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/kb/documents":{"post":{"tags":["Knowledge Base"],"operationId":"pushKnowledgeBaseDocuments","summary":"Push documents into a KB source (max 100 per request)","description":"Each document is chunked, embedded and indexed synchronously, so it is queryable when the call returns. Requires the `kb:write` scope. Rate limited per API key (20/min by default).","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/KbDocumentsRequest"}}}},"responses":{"200":{"description":"Per-document outcome. A document that failed to index is reported with `status: \"error\"` inside a 200 body.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/KbDocumentsResponse"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such source or connection in this org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Knowledge Base"],"operationId":"deleteKnowledgeBaseDocument","summary":"Remove one KB document","description":"Deletes the document's vector chunks and stored bytes and soft-deletes its record. Requires the `kb:write` scope.","parameters":[{"name":"documentId","in":"query","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"documentId":{"type":"string"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such document in this org.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/memory/{botId}/memories":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Memory"],"operationId":"listMemories","summary":"A person's or the shared memories","description":"Newest first. Requires `memory:read` (or `memory:write`).","parameters":[{"name":"scope","in":"query","required":true,"schema":{"type":"string","enum":["person","shared"]}},{"name":"subjectId","in":"query","required":false,"schema":{"type":"string"},"description":"The person (scope person)."},{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["active","pending"]}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":1000,"default":200}}],"responses":{"200":{"description":"The memories.","content":{"application/json":{"schema":{"type":"object","properties":{"memories":{"type":"array","items":{"$ref":"#/components/schemas/Memory"}},"total":{"type":"integer"},"pending":{"type":"integer"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"post":{"tags":["Memory"],"operationId":"createMemory","summary":"Remember something","description":"Requires `memory:write` and the bot's long-term memory switched on. One that says what an existing memory says updates it (`outcome: updated`). A full space answers 409 — delete some first.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["text"],"properties":{"scope":{"type":"string","enum":["person","shared"],"default":"person"},"subjectId":{"type":"string"},"text":{"type":"string","maxLength":500},"kind":{"type":"string","enum":["fact","preference","event"]},"tags":{"type":"array","items":{"type":"string"},"maxItems":8},"pinned":{"type":"boolean"}}}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"type":"object","properties":{"memory":{"$ref":"#/components/schemas/Memory"},"outcome":{"type":"string","enum":["created","updated","unchanged"]}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The space is full (`maxPerPerson`, or 500 shared).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Memory is off for this bot, or the text isn't usable.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/memory/{botId}/memories/{memoryId}":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}},{"name":"memoryId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Memory"],"operationId":"getMemory","summary":"One memory","responses":{"200":{"description":"The memory.","content":{"application/json":{"schema":{"type":"object","properties":{"memory":{"$ref":"#/components/schemas/Memory"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such memory.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Memory"],"operationId":"updateMemory","summary":"Correct, pin or approve a memory","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"text":{"type":"string","maxLength":500},"kind":{"type":"string","enum":["fact","preference","event"]},"tags":{"type":"array","items":{"type":"string"}},"pinned":{"type":"boolean"},"approve":{"type":"boolean","description":"Make a pending shared memory active."}}}}}},"responses":{"200":{"description":"The memory after the change.","content":{"application/json":{"schema":{"type":"object","properties":{"memory":{"$ref":"#/components/schemas/Memory"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such memory.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Memory"],"operationId":"deleteMemory","summary":"Delete a memory","responses":{"200":{"description":"Deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"string"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"No such memory.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/memory/{botId}/search":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}}],"post":{"tags":["Memory"],"operationId":"searchMemories","summary":"Search memories by meaning","description":"Searches the person's (with `subjectId`) and the shared memories, closest in meaning first. Falls back to matching words when no embedding key is available (`mode: keyword`). Requires `memory:read`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["query"],"properties":{"query":{"type":"string","maxLength":1000},"scope":{"type":"string","enum":["person","shared"]},"subjectId":{"type":"string"},"limit":{"type":"integer","minimum":1,"maximum":50,"default":10}}}}}},"responses":{"200":{"description":"Matches with a 0–1 `score` (semantic mode).","content":{"application/json":{"schema":{"type":"object","properties":{"results":{"type":"array","items":{"$ref":"#/components/schemas/Memory"}},"mode":{"type":"string","enum":["semantic","keyword"]},"searched":{"type":"integer"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/memory/{botId}/people/{subjectId}":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}},{"name":"subjectId","in":"path","required":true,"schema":{"type":"string"}}],"delete":{"tags":["Memory"],"operationId":"forgetPerson","summary":"Forget everything about a person","description":"Deletes every memory this bot keeps about them, in the key's environment. Requires `memory:write`.","responses":{"200":{"description":"How many were deleted.","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"integer"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sessions":{"get":{"tags":["Sessions"],"operationId":"listSessions","summary":"List or search a bot's conversations","description":"Newest first. Requires `sessions:read` (or `sessions:write`). Search by tracked details with up to three `state.<key>=<value>` parameters, e.g. `state.issue_type=Refund` — the value matches text, numbers or yes/no.","parameters":[{"name":"botId","in":"query","required":true,"schema":{"type":"string"}},{"name":"endUserExternalId","in":"query","required":false,"schema":{"type":"string"}},{"name":"status","in":"query","required":false,"schema":{"type":"string","enum":["open","ended"]}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":25}},{"name":"before","in":"query","required":false,"schema":{"type":"integer"},"description":"`nextBefore` from the previous page."}],"responses":{"200":{"description":"A page of conversations.","content":{"application/json":{"schema":{"type":"object","properties":{"sessions":{"type":"array","items":{"$ref":"#/components/schemas/Session"}},"nextBefore":{"type":["integer","null"]}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sessions/{sessionId}":{"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Sessions"],"operationId":"getSession","summary":"One conversation and its transcript","description":"Requires `sessions:read` (or `sessions:write`). Its tracked details: the state API, scope `session`.","parameters":[{"name":"botId","in":"query","required":true,"schema":{"type":"string"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":500,"default":500}}],"responses":{"200":{"description":"The conversation, and its messages oldest first.","content":{"application/json":{"schema":{"type":"object","properties":{"session":{"$ref":"#/components/schemas/Session"},"messages":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"role":{"type":"string","enum":["user","assistant"]},"content":{"type":"string"},"createdAt":{"type":["string","null"],"format":"date-time"},"traceId":{"type":["string","null"]}}}}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such conversation for this bot.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sessions/{sessionId}/end":{"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string"}}],"post":{"tags":["Sessions"],"operationId":"endSession","summary":"End a conversation","description":"The person's next message starts a new conversation. `note` is kept as the close summary (carried into the next conversation under continuity \"profile + summary\"). Idempotent. Requires `sessions:write`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["botId"],"properties":{"botId":{"type":"string"},"note":{"type":"string","maxLength":2000}}}}}},"responses":{"200":{"description":"Ended (or it already was).","content":{"application/json":{"schema":{"type":"object","properties":{"sessionId":{"type":"string"},"ended":{"type":"boolean"},"alreadyEnded":{"type":"boolean"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such conversation for this bot.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/sessions/{sessionId}/fork":{"parameters":[{"name":"sessionId","in":"path","required":true,"schema":{"type":"string"}}],"post":{"tags":["Sessions"],"operationId":"forkSession","summary":"Fork a conversation","description":"A copy with the transcript (all, or up to and including `throughMessageId`) and the tracked details (now, or as they were at `stateRevision`). Nothing is sent; continue it with bot-run and its `sessionId` — with the same end user it becomes their current conversation. Requires `sessions:write`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["botId"],"properties":{"botId":{"type":"string"},"throughMessageId":{"type":"string"},"stateRevision":{"type":"integer","minimum":1}}}}}},"responses":{"201":{"description":"The new conversation.","content":{"application/json":{"schema":{"type":"object","properties":{"session":{"$ref":"#/components/schemas/Session"},"messagesCopied":{"type":"integer"},"detailsCopied":{"type":"integer"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"`not_found` — no such conversation for this bot.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"`throughMessageId` isn't in the conversation, or that revision is no longer kept.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/config":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Tracked details"],"operationId":"getStateConfig","summary":"The bot's tracked details","description":"Requires `state:read` or `state:write`. The key's environment decides Test or Production.","responses":{"200":{"description":"The schema.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateConfig"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"put":{"tags":["Tracked details"],"operationId":"putStateConfig","summary":"Replace the bot's tracked details (Test keys)","description":"Requires `state:write` and a Test key — Production receives the schema through a release. Send `expectedConfigVersion` to avoid overwriting someone else's save. Saved fields keep their key, type and scope.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateConfig"}}}},"responses":{"200":{"description":"Saved.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateConfig"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"The schema changed since `expectedConfigVersion`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Invalid schema — `error.details.problems` lists every reason.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/config/validate":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}}],"post":{"tags":["Tracked details"],"operationId":"validateStateConfig","summary":"Check a schema without saving it","description":"Requires `state:write`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateConfig"}}}},"responses":{"200":{"description":"`ok` and the reasons it would be refused.","content":{"application/json":{"schema":{"type":"object","properties":{"ok":{"type":"boolean"},"problems":{"type":"array","items":{"type":"string"}}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/records":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}}],"get":{"tags":["Tracked details"],"operationId":"listStateRecords","summary":"Recently changed records","parameters":[{"name":"scope","in":"query","required":false,"schema":{"type":"string","enum":["session","person","bot"]}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":25}}],"responses":{"200":{"description":"Newest first.","content":{"application/json":{"schema":{"type":"object","properties":{"records":{"type":"array","items":{"$ref":"#/components/schemas/StateRecord"}}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/records/{scope}/{subjectId}":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}},{"name":"scope","in":"path","required":true,"schema":{"type":"string","enum":["session","person","bot"]}},{"name":"subjectId","in":"path","required":true,"schema":{"type":"string"},"description":"A conversation id (`session`), your end-user id (`person`) or `shared` (`bot`)."}],"get":{"tags":["Tracked details"],"operationId":"getStateRecord","summary":"One record's values","parameters":[{"name":"reveal","in":"query","required":false,"schema":{"type":"boolean"},"description":"Return sensitive values in full."}],"responses":{"200":{"description":"Values (defaults filled in).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateRecord"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"patch":{"tags":["Tracked details"],"operationId":"patchStateRecord","summary":"Change values (atomic)","description":"All changes apply together or none do. Requires `state:write`; each field must allow writes from the API. Rate limited per API key (120/min by default).","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"schema":{"type":"string"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/StatePatchRequest"}}}},"responses":{"200":{"description":"The record after the change; `results` says what each op did.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateRecord"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Changed since `expectedRevision` — `error.details.currentRevision` is the latest.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"A value was refused — `error.details.errors` has a reason per field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"tags":["Tracked details"],"operationId":"deleteStateRecord","summary":"Delete a record and its history","description":"Requires `state:write`.","responses":{"200":{"description":"`deleted` is false when there was nothing to delete.","content":{"application/json":{"schema":{"type":"object","properties":{"deleted":{"type":"boolean"}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/records/{scope}/{subjectId}/revisions":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}},{"name":"scope","in":"path","required":true,"schema":{"type":"string","enum":["session","person","bot"]}},{"name":"subjectId","in":"path","required":true,"schema":{"type":"string"},"description":"A conversation id (`session`), your end-user id (`person`) or `shared` (`bot`)."}],"get":{"tags":["Tracked details"],"operationId":"listStateRevisions","summary":"History, newest first (the last 100 changes)","parameters":[{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"maximum":100,"default":50}}],"responses":{"200":{"description":"Each revision: who changed it (`source`), when (`atMs`), what moved (`changes`).","content":{"application/json":{"schema":{"type":"object","properties":{"revisions":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/api/v1/state/{botId}/records/{scope}/{subjectId}/restore":{"parameters":[{"name":"botId","in":"path","required":true,"schema":{"type":"string"}},{"name":"scope","in":"path","required":true,"schema":{"type":"string","enum":["session","person","bot"]}},{"name":"subjectId","in":"path","required":true,"schema":{"type":"string"},"description":"A conversation id (`session`), your end-user id (`person`) or `shared` (`bot`)."}],"post":{"tags":["Tracked details"],"operationId":"restoreStateRecord","summary":"Restore an earlier revision (saved as a new one)","description":"Requires `state:write`.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["revision"],"properties":{"revision":{"type":"integer","minimum":1},"expectedRevision":{"type":"integer"}}}}}},"responses":{"200":{"description":"The record after restoring.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StateRecord"}}}},"400":{"description":"Malformed JSON or an invalid field.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or unrecognized API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"Key revoked, out of scope, or the org is suspended.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"Changed since `expectedRevision`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit exceeded — see `Retry-After`.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}}}