Skip to content

Conversations API

The conversations API manages chat conversations, messages, attachments, presets, and stored memories. All endpoints require an authenticated admin session.

Conversations are user-scoped: a non-admin caller can only access conversations they own or that are shared with them through a project.

While impersonating ("View as User"), these endpoints are refused with 403 impersonation_forbidden — a user's private chats, messages, attachments, images, knowledge-file downloads, comments, live sessions and memories are not readable or writable act-as. See Admin impersonation.


Listing conversations

GET /admin/v1/conversations

Returns the conversations of the calling user.

Optional query parameters:

Parameter Description
limit Maximum rows. Default 50, capped at 200. Anything but a plain integer ≥ 1 (0, -1, 1e2, empty, repeated) is 400 {"code": "invalid_limit"}.
offset Paging offset. Default 0. Anything but a plain integer ≥ 0 is 400 {"code": "invalid_offset"}.
archived 1 or true to return archived conversations only, 0 or false for active ones (the default when absent). Any other value, or a repeated parameter, is refused with 400 invalid_archived (formerly archived_invalid).

Each row includes shared_in_project (0/1) — whether the conversation is shared into its project's feed (see Sharing a conversation with a project). It is 0 for conversations that are not in a project.


Searching conversations

POST /admin/v1/conversations/search?limit=<N> with the JSON body {"q": "<TERM>"}

Searches the titles of the calling user's own conversations (archived and deleted conversations are not included). The term is split into words at whitespace (spaces, tabs, line breaks and Unicode spaces such as the non-breaking space); a title matches when it contains every word, in any order (Berlin Mietvertrag finds "Mietvertrag Berlin"; a word may be part of a longer word). Each word matches as a literal piece of text, ignoring upper/lower case and accents (munchen finds "München"): % and _ have no special meaning. A word repeated in the term counts once (comparing A–Z case-insensitively); at most the first 8 different words are matched, and any further words are ignored. Rows carry the same fields as the list endpoint, including shared_in_project (0/1). The term travels in the body — never in the URL, because the web server writes request lines into its error log.

  • q (body, required): a non-empty string, valid UTF-8, at most 1024 characters. A term shorter than 2 characters after trimming leading/trailing whitespace returns [] (no search yet). Absent / empty → 400 q_required; not a string, invalid UTF-8 or over 1024 characters → 400 invalid_q; a body that is not a JSON object → 400 malformed_body; ?q= also in the query → 400 pii_in_query.
  • limit (query, optional): a plain positive integer, default 20, capped at 100; anything else (0, 0x1E, 1e2, empty, repeated) → 400 invalid_limit.
  • A database fault while searching — including reading one of the matching conversations — is 503 {"error": "temporarily unavailable; retry later"}, never a shorter or empty result.

Deprecated: GET /admin/v1/conversations/search?q=<TERM> answers the same way until 11 January 2027 with Deprecation / Sunset headers. Two behaviour changes apply to it as well: an absent q is now 400 q_required (it used to answer []), and a repeated or valueless ?q is 400 invalid_q (it used to fail with 500). See Search and lookup values travel in the request body.

Where the search term goes. By default the term is matched against conversation titles inside the deployment — it does not leave. (Meaning-based matching is currently switched off platform-wide, so every search is a title search today; the rules below apply when it is enabled.) A tenant that has configured a semantic-cache embedding endpoint on one of its own interfaces additionally gets meaning-based matching, which means the term is sent to that endpoint. Two rules bound that, and neither is configurable:

  • The endpoint is only ever one configured on your own tenant's interfaces. Another tenant's endpoint and API key are never used, even if yours has none configured (in that case you simply get title matching).
  • If any of your conversations belongs to a project on a restricted access tier (Local only or PII mandatory), the search term is not sent anywhere: the search falls back to title matching, which runs entirely inside the deployment. The same applies if that check cannot be completed — the term is withheld rather than sent on an unproven assumption.

The title of a conversation is treated the same way: a conversation in a Local only or PII mandatory project never has its title sent to an embedding endpoint, and a conversation whose project binding cannot be resolved is treated as restricted.


Creating a conversation

POST /admin/v1/conversations

The client posts routing hints, not a resolved gateway and model. The server is the sole authority on which gateway the conversation lands on.

A caller with the viewer role is refused before any work with 403 viewer_read_only (on every create path, share-continue included). A caller whose account belongs to no workspace (for example a platform administrator without a tenant of their own) cannot start a chat of their own: a fresh or ghost create is refused with 403 { "error": "forbidden", "code": "caller_has_no_tenant" } before anything is resolved or written (earlier releases answered 500 missing_tenant_id). Continuing a shared conversation as such a caller stays 403 gateway_outside_owner_tenant. A route-resolution refusal answers { "error": "<code>", "code": "<code>" } with status 400 (model_override_gateway_not_visible, project_gateway_not_visible, unknown_task), 403 (department_gateway_not_allowed, project_gateway_locked), 503 or 500 (gateway_config_unavailable, gateway_list_unavailable, tenant_ctx_unavailable: 503 with a Retry-After header only when the fault is a transient database fault, otherwise 500 with the same code) or 409 (every other code, for example no_runnable_route, no_local_route, pii_twin_unavailable, department_pii_twin_not_allowed, department_no_gateway). An explicit choice that names or lands on a gateway whose configuration could not be resolved (a model override, a project pin with or without a model, a department default, or a PII-twin redirect onto such a gateway) is refused with gateway_config_unavailable rather than routed; see error codes for when it is retryable.

Project binding stays in one workspace

A conversation can be bound only to a project of its own workspace — the workspace of the account that owns it — and a project-bound conversation must route through a gateway of that same workspace (the project's access tier is read in the gateway's workspace on every message). Every path that creates a binding or moves one — to another project or onto another gateway — enforces this, platform administrators included, and refuses with 403 project_tenant_mismatch (the code in both error and a sibling code, the prose in message):

  • creating a conversation with a project_id of another workspace, or with a hint_model_override that pins a gateway of another workspace while a project is bound;
  • moving a conversation (PATCH) into a project of another workspace, or moving a project-bound conversation onto a gateway of another workspace (a raw gateway_id or a hint_model_override — the model picker's route);
  • forking ("Continue in new chat") a conversation whose project — or whose gateway, when the conversation is project-bound — belongs to another workspace than yours.

Before this rule such a conversation was created and then refused on every message with conversation_project_unresolved ("this project no longer exists"), which was false and not actionable. Conversations created that way earlier keep their current behaviour: an edit that re-sends their committed project and gateway (a rename, a model switch on the same gateway) is not refused, and they can still move to a local model on a gateway of the owner's workspace. A platform administrator can still route a project-less conversation through another workspace's gateway (triage); the rule only applies once a project is bound. Continuing a shared conversation is stricter — the copy always stays in the caller's own workspace, administrators included (see Continuing a shared conversation stays in your workspace). A non-administrator who names a project of another workspace they cannot access answers the same audited 404 {"error":"not found"} as an unknown id (byte-identical; an access.denied audit row is written) — the response says nothing about other workspaces.

How the server picks a model for Auto

When no concrete model is pinned (hint_tier: "auto" and no hint_model_override), the server resolves the model itself, from the tenant's own catalogue. The rules, in order:

  1. Only production gateways are candidates. A gateway with purpose other than production never receives traffic.
  2. A cloud pick that needs protection picks a protecting gateway. When the resolved model is a cloud provider and the project's access tier is PII mandatory, the tenant enforces masking, or hint_pii_preference is on, the server restricts the candidate gateways to those that actually scrub personal data on the request — using the same test the inference pipeline enforces with, so it can never select a gateway the request would then be refused on. If none qualifies, it widens to gateways that have any personal-data protection active (for example a keyword list); only if neither exists does it fall back to the full set. When the pick comes from that narrowed set the usual PII-twin swap is skipped. A local first-party model (the usual Auto pick) is exempt: it stays on the non-masking gateway by default — even when it uses web search and even under a PII mandate or tenant enforcement — because masking a first-party leg only corrupts your own data. See Tenant-enforced mandatory masking.
  3. Local models are always available. The Myra-hosted local fleet needs no provider key and is routable from every gateway, so it is part of every gateway's catalogue even though it has no stored provider credential.
  4. Proven tool calling comes first. Chat has web search and file tools enabled by default, so a model that cannot call tools is not a usable default. The server therefore looks for a verified tool-capable model across the preferred providers — local fleet first, then Anthropic — before it considers a non-verified one. A tenant whose local fleet has no verified model but who also uses Anthropic will therefore get an Anthropic model: a working tool-capable default beats a local one that stalls mid-answer.
  5. Then provider preference, then cost. If no preferred provider offers a verified model, the server takes any chat model from a preferred provider, then a verified model from any provider, then any chat model at all. Gateways are always walked oldest first (by creation time, then by slug), and within one gateway the cheapest model wins; equal prices prefer the newer model of a family (so a new release is not silently undone by its predecessor once their prices converge), then break remaining ties by model name and then by provider name, so the same catalogue always yields the same choice.
  6. Plan limits apply. On a subscription plan with a model list, only models included in that plan can be chosen — both for Auto and for a project's preferred model.
  7. Non-chat models (embedding, reranking, image, speech) are never chosen, and a deprecated model is never chosen.

In the current fleet this resolves to the local Qwen 3.8 model. A project's preferred model (see Projects) overrides the choice when the pinned model is routable, including when it is a local model.

Access-tier enforcement during a database fault. The tier that governs a conversation is resolved server-side on every request. If that lookup fails transiently, the gateway fails closed — it applies the most restrictive treatment rather than serving the request unrestricted — but only for a conversation it cannot prove is project-free. A chat that is not in a project is not silently treated as Local only, so a database blip cannot turn ordinary chats into "this project only allows local models" refusals.

A Local only project constrains the choice. For a project on the Tier-1 Local only access tier the server considers only local models at every step above — it never proposes a cloud model that the inference guard would then refuse. A preferred model that is not local is ignored rather than adopted (the local choice stands). If the project is Local only and no local model is currently routable — none served, or all of them excluded by the gateway's residency/allowlist or by the subscription plan — the request fails with 409 no_local_route (the body carries the machine string in both error and a sibling code), a distinct code from no_runnable_route, so the client can say that this project only allows local models rather than reporting a missing gateway. The tier is read server-side from the project row and is never taken from the client; it binds a conversation even for a caller who is no longer a member of the project.

Field Type Required
hint_tier string no — routing tier; legacy fast/balanced/deep map to auto.
hint_task_slug string no — chip slug from the hero; steers the system prompt only, does not pick a model.
hint_model_override object no — { gateway_id, model } to pin a concrete model. The gateway must be one that routes (purpose: "production"): a caller who is not a platform administrator naming a test / benchmark / archived gateway is refused 400 model_override_gateway_not_visible and nothing is created — such a pin used to be accepted and produced a conversation that failed on every send. The same rule applies to the raw gateway_id on the conversation PATCH — but there only when the request MOVES the conversation to a different gateway, so a request naming the gateway it already sits on is never refused — and on a share-continue create (which has no committed gateway, so any supplied id is a move); both answer 403 gateway_not_allowed_for_project. A platform administrator may still pin a non-production gateway deliberately (triage), the same exemption that lets them pin across tenants.
hint_pii_preference boolean no — the user's Privacy preference. Accepted: absent or null (off, the default), true / 1 / "1" (on), false / 0 / "0" (off). Any other shape ("true", "yes", 2, an array, an object) is refused 400 invalid_hint_pii_preference before anything is routed or written, on both POST and PATCH — a malformed value never silently counts as off (unmasked). With it on and no mandate, a cloud model named by hint_model_override (or carried by a project's model and gateway pin) is no longer routed as-is on an unmasking gateway: it is re-homed onto a gateway of the workspace that scrubs personal data and serves the model (the masking twin of the named gateway first). If the workspace has no masked route for that model the create is refused 409 pii_twin_unavailable and nothing is created. A local first-party model and a gateway that already masks are not re-homed.
project_id string no — the project to bind the conversation to. Absent or null = no project. Any other non-string value or "" is malformed and is refused with 400 project_id must be a non-empty string or null (never treated as "no project"). A project you cannot see — another workspace's project, a same-workspace project with no role for you, or an id that names no project, including any well-formed string that names no project you can see (e.g. a random or garbage id) — answers the shared audited 404 { "error": "not found" }, byte-identical to an unknown id (see A project you cannot see answers 404); nothing is created. A project you can see but may not use keeps its 403. The project must belong to your own workspace, and so must the gateway the conversation resolves to — otherwise 403 project_tenant_mismatch (see Project binding stays in one workspace).
web_search integer 0/1 (or "0"/"1", boolean) no — the user's web-search choice for the conversation: 0 / "0" / false store off, 1 / "1" / true store on. An absent field stores null — never chosen, which means on (the default). Any other value — null, another number, another string, an object or array — is refused with 400 invalid_web_search (formerly web_search_invalid) and nothing is created. The conversation GET returns it as 0 or 1, and omits it when the user never chose; the chat interface restores the Web search switch (+ menu) from it whenever the conversation is opened or reloaded (omitted → on). Conversations created by continuing a share link, by a scheduled task or by a chat bridge store null. The value is a stored preference: each turn's search is still requested per message (x-aig-web-search) and gated by the gateway and project.
title string no — max 255 characters; a non-string or invalid UTF-8 → 400 invalid_title; longer → 400 title_too_long
ghost boolean no — true/1/"1" or false/0/"0" (absent = 0, persisted); any other value, null included, is refused with 400 invalid_ghost (formerly ghost_invalid) and nothing is created
memory_disabled boolean no — true/1/"1" or false/0/"0" (absent = 0, memories on); any other value, null included, is refused with 400 invalid_memory_disabled (formerly memory_disabled_invalid) and nothing is created
personal_style_disabled boolean no — true/1/"1" or false/0/"0" (absent = 0, personal style on); any other value, null included, is refused with 400 invalid_personal_style_disabled (formerly personal_style_disabled_invalid) and nothing is created
starter_suggestion string no — a write-only product-measurement tag recording which generic one-click starter-task card (shown on the empty new-chat screen to a brand-new trial user) the first message was started from; the reserved value none means the cards were shown but a blank message was sent instead. Accepted shape is a bounded lowercase token ^[a-z][a-z0-9_]*$ of at most 64 bytes. Unlike web_search, anything malformed is coerced to NULL and the request still succeeds — deliberately, so a telemetry tag can never block a first message; the value never affects routing or the system prompt, and the conversation GET never returns it (write-only). Absent → NULL.
source_share_token string no — when provided, the gateway forks from the referenced shared conversation; the response describes the new fork. Must be a non-empty string when present: any other value — a number, an object, true, false, null or "" — is rejected with 400 { "error": "source_share_token must be a string" }; only an absent key makes the request a normal create. An unknown or deleted share answers 404 { "error": "share not found" }; a database fault reading it answers 503.
gateway_id string conditional — required only on the fork path (when source_share_token is present). Absent or null → 400 gateway_id_required; not a string, "", longer than 36 bytes, invalid UTF-8 or containing a control, line-break or invisible formatting character (see refused characters) → 400 gateway_id_invalid. It must be a gateway of the caller's own workspace — for every caller, platform administrators included — else 403 gateway_outside_owner_tenant (an unknown id answers the same, so the route says nothing about other workspaces); a non-administrator's gateway must also route (purpose: "production", else 403 gateway_not_allowed_for_project). Nothing is written on a refusal. It is the preferred gateway: the continuation moves only when this gateway refuses the shared conversation's model (see below).
mcp_connectors null or array no — the connector selection the new conversation starts with, validated exactly like the PATCH field (see Per-conversation connector selection): null stores none-chosen and suppresses inheritance, [] stores explicit none, an array of at most 8 distinct visible connector ids stores that list in the order sent. Absent → the new conversation inherits as described there. A malformed or invisible value is refused with 400 invalid_mcp_connectors (formerly mcp_connectors_invalid) before anything is created, on every create path (fresh, ghost and share-continue). A ghost create echoes the validated value and persists nothing.

Previewing where Auto will route (GET /admin/v1/conversations/route-preview)

Answers where Auto would route a new conversation right now, without creating one. It runs the same resolution code as a fresh POST /admin/v1/conversations (project check, project access tier, department and project-lock scope, the Auto pick above, and the project's gateway-workspace check), so for the same inputs at the same moment the two pick the same route. The route can still change before the create: for example when a gateway or model becomes unavailable in between. The create also checks fields the preview does not take (for example hint_task_slug → 400 unknown_task). Nothing is written. The chat's new-chat screen uses it for the privacy badge before the first message (see Privacy mode).

Query parameters, both optional, each at most once and with a value:

Parameter Accepted shape
project_id The project the new conversation would be bound to. Absent = no project. An empty value → 400 invalid_project_id. A project you cannot see → the audited 404 { "error": "not found" }; another workspace's project → 403 project_tenant_mismatch.
hint_pii_preference Same values as on create: absent / 0 = off, 1 = on; anything else (true, yes, 2, empty) → 400 invalid_hint_pii_preference.

Rejected: any other parameter, including hint_model_override, hint_task_slug, hint_tier, ghost and title, and a parameter that is repeated or has no value (?hint_pii_preference), are refused with 400 invalid_route_preview_parameter before anything is routed. The preview covers Auto only: an explicit model pick is routed on the gateway it names, and the client already knows that route. More than 100 query parameters → 400 malformed_query. A viewer → 403 viewer_read_only. A caller with no workspace → 403 caller_has_no_tenant. A routing refusal answers exactly like the create, for example 409 no_runnable_route or 409 pii_twin_unavailable, and a transient configuration fault answers 503, otherwise 500 with the same code.

Response 200:

{ "gateway_id": "gw-…", "model": "qwen3-32b", "provider": "myra", "masks": false }

provider is null when the resolution did not name one. The client then cannot classify the route and shows the neutral badge.

masks is whether the resolved gateway masks personal data, as the server's own routing sees it: at least one enabled masking detector on the gateway or in the workspace's guardrail baseline. true or false; null when the resolved gateway is not among the gateways the resolution considered for you (the workspace's gateways, narrowed by your department and the project's gateway lock), so the server cannot say. The chat classifies the badge's mode from provider and masks (Protected for a Myra model, else Masked when masks is true, else Public), not from its own copy of the gateway list. With masks: null the badge stays neutral.

Binding the create to the previewed route (expected_route)

The preview and the create are two separate resolutions, so the route can move between them (an administrator disables a gateway, a model leaves the catalog, an access grant is revoked). To make sure a first message never goes where the badge did not say, the create can carry the route the client showed:

{ "hint_tier": "auto", "hint_pii_preference": 1, "expected_route": { "gateway_id": "gw-…", "model": "qwen3-32b", "masks": false } }
expected_route Result
absent No binding: the create takes whatever it resolves (the earlier behaviour).
{ "gateway_id", "model" } plus an optional "masks": both strings non-empty (gateway_id at most 36 bytes, model at most 128 bytes), masks true or false (the preview's masks), no other key The create resolves as usual, then compares. Same gateway and same model (exact, case-sensitive) and, when masks is sent, the same masking posture of the resolved gateway (for example an administrator switched that gateway's masker off since the preview) → created as usual. Different → 409 { "error": "the route changed since it was previewed", "code": "route_changed" } and nothing is created (no conversation row, no ghost conversation). A routing refusal (for example 409 no_runnable_route) still answers its own code first. Without masks the posture is not compared (a preview that answered masks: null binds none). When masks is sent and the server cannot name the resolved gateway's posture, the create is refused with 409 route_changed too.
anything else: null, a string, number, boolean or array, a missing, empty, non-string or oversized field, a field that is not valid UTF-8 or contains a control, line-break or invisible formatting character, a masks that is not true or false (null, "true", 1, an object), or an extra key (for example provider) 400 { "error": "expected_route must be an object {gateway_id, model} of non-empty strings, with an optional boolean masks", "code": "invalid_expected_route" } before anything is routed. A malformed value is never treated as absent.

On a share continuation (source_share_token) nothing is resolved to compare against, so expected_route there is refused with 400 invalid_expected_route ("expected_route applies to a new conversation only"). It works the same with ghost. An explicit model pick (hint_model_override) may carry it too; the chat's new-chat screen sends it only on Auto, and only when it has a preview. On 409 route_changed the chat asks the preview again, shows the new badge and keeps your message in the composer, so you send again knowing where it goes.

Continuing a shared conversation

POST /admin/v1/conversations with source_share_token creates a new conversation in the caller's account holding a copy of the shared transcript.

Unless the body carries its own valid mcp_connectors (which wins over the source copy, see the table above), the continuation starts with the share source's connector selection (not the recipient's last one), filtered to the connectors the recipient can see, so the owner's private connector ids never reach the recipient. The same rules as under Per-conversation connector selection below apply: a source [] stays [], nothing visible left gives null (unlike the GET projection for readers, which gives []), and a read fault gives null without failing the continue.

The same personal-data check as the public read applies before anything is copied. A snapshot that was not masked when the link was made ("pii_masked" is not true) can be continued only while no gateway of the source conversation masks personal data and no PII mandate applies. Otherwise the request answers 403 { "error": "share_needs_recreate", "code": "share_needs_recreate", "message": … } (permanent until the owner creates a new link), or 503 { "error": "temporarily unavailable" } (retryable) when the check cannot be decided. Nothing is written on either refusal: no conversation and no message is created. A masked snapshot ("pii_masked": true) is continued with the transcript text only: the text in the snapshot is already masked, so no files cross (no attachments, generated images, audio or videos, conversation files or project files), because the owner's files are unmasked. A snapshot whose pii_masked is present but not a boolean is treated the same way (no files); only a snapshot without the flag or with false carries files.

Continuing a shared conversation stays in your workspace

The copy is the caller's conversation, so it is stored in — and its usage billed to — the caller's own workspace, never another one, platform administrators included. Every gateway the continuation can end up on is checked against that rule: the posted gateway_id, the lock gateway a locked source project substitutes, and the gateway the server moves to when the posted one refuses the shared model; any of them outside the caller's workspace refuses the whole request with 403 gateway_outside_owner_tenant before anything is written. The app's Continue button picks only the caller's own workspace's established gateway; when that workspace has no usable gateway (none that routes, or none the caller's department allows) it says so and asks the user to have their workspace administrator set one up — it never falls back to another workspace. An account that belongs to no workspace cannot continue a shared conversation.

The continuation inherits the source conversation's project — or it is refused. A conversation that lives in a project carries that project's access tier, which is what guarantees where its data may go. Copying its transcript into an unbound conversation would strip that guarantee, so the server resolves the source's binding first and decides:

Source conversation Continuing user Result
not in a project anyone created, unbound
in a project of the user's own workspace (also the workspace of the gateway named in gateway_id), and the user is authorized on it (member, group grant, org share, or platform admin) created and bound to that project
in a Configurable (Tier‑3) project not authorized created, unbound — that tier imposes no residency or PII constraint
in a Local only (Tier‑1) or PII mandatory (Tier‑2) project not authorized 403 share_source_project_forbidden
binding cannot be confirmed — the project belongs to another workspace, was deleted, or its tier is unrecognized anyone 403 share_source_project_forbidden
owned by a suspended workspace anyone, platform administrators included 404 share_not_found — exactly the answer an unknown or revoked link gets, checked at the same point as an unknown link, before every other row and before the gateway checks, so the response does not reveal the suspension; the reason is in the server log only. If the suspension state cannot be read: 503 retryable. The viewer's own suspension is the session's tenant_suspended
in a project of another workspace than the user's (in practice a platform administrator — a non-administrator's gateway is always in their own workspace) anyone treated like "not authorized": a Configurable project continues unbound, a Local only / PII mandatory one is refused with 403 share_source_project_forbidden — a continuation is never bound across workspaces
the binding lookup fails transiently anyone 503 project_tier_unresolved — retryable, and deliberately not the permanent refusal
the access check fails transiently 503 project_access_unresolved — retryable; a database fault is never treated as a denial

The suspension check and the copy of the shared artifacts are not one transaction (the same fence-then-act window the public forms have): a share continued in the instant a workspace is suspended can still complete (the artifact carry re-reads the share inside its own transaction and does not re-check the suspension). The next continue is refused.

The refusal names no project, workspace, tier or owner, and "not authorized" and "could not confirm" share one code on purpose, so the response is not an oracle over a stranger's project. It does disclose one bit: that the source is in a project you are not authorized on.

The binding is read under the source conversation's own workspace, derived server‑side from the share record — never from anything the client sends — so two people holding the same link always get the same answer. A continuation is only bound when that workspace is also the workspace of the gateway it will run on, which is the workspace the inference path enforces the tier under; that keeps the decision made here and the decision made at send time identical by construction.

Also on this path:

  • The continuation is created on the validated gateway_id, never on the gateway recorded in the frozen snapshot (which belongs to the sharer and can be in another workspace). Exception: when that gateway refuses the shared conversation's model (for example a trial's Anthropic-only gateway and a Myra-hosted model — every send would answer 403 provider_not_allowed) while another production gateway of your workspace that you may use serves it, the continuation is placed the way a new chat with that model as your default model would be (the same rules for local-only projects and department scope, with the masking preference of the gateway you supplied; a project's own default model or gateway does not apply — the shared conversation's model is the preference), and the response's gateway_id / model show where it landed (a retired model lands on its successor; in a local-only project an external shared model gives way to the default local model). The supplied gateway is kept when no gateway of yours serves the model (its first send may then be refused — pick another model; the picker is unlocked), when the model is one no gateway of yours knows, when a platform administrator chose a non-production gateway, and when the move would send an external-provider model through a gateway without the PII masking the supplied gateway applies (request-side scrubbing first, then any masking) — except that when your department's scope excludes the masking twin, the continue answers 409 department_pii_twin_not_allowed (as a new chat would) and nothing is created (a Myra-hosted model needs no masking and moves freely). A project lock always decides the gateway. If the gateway cannot be chosen because the workspace's routing cannot be read or resolved, the same responses as a normal create apply — 409 / 403 / 503 with a code from the route resolver, or 500 / 503 { "error": … } when the workspace's gateways cannot be read — and nothing is created.
  • Imported messages carry no gateway_id (the sharer's gateway is never copied into your workspace).
  • It carries the snapshot's last assistant model and sets model_unlocked = 1, the same one-shot picker waiver the in-account fork uses — the copied messages would otherwise freeze the picker on a model the recipient never chose. The first real turn clears it.
  • A project_id in the request body is ignored; the binding is the server's answer about the source.
  • The imported messages are a frozen copy. The binding governs the conversation's future turns; the original project of the copied text is not recorded. Project files are carried only when the continuation is bound to that very project (an authorized continuer regains access to project knowledge through the binding); on an unbound continuation they are not carried.
  • A continuation is all or nothing: if any message of the snapshot fails to import, the partially-built conversation is removed and the request returns the sanitised 500 ({ "error": "internal error", "request_id": "…" }) rather than handing the recipient a transcript with holes it is told is complete.
  • Conversation-owned files cross with their messages, as they were when the link was created. This does not apply to a masked snapshot ("pii_masked": true, or a malformed value of that field): such a Continue brings the transcript text only and no files at all. The files attached to the imported messages that belong to the shared conversation itself — its own knowledge files (including .md documents the assistant wrote), attachments, generated images and audio, and generated videos that are ready — are duplicated under the new conversation with their own ids, exactly as in the fork below, so the recipient can read and edit them without touching the owner's originals.

    • Frozen versions. The share link freezes which knowledge files each message showed and their version when it is created (the list is stored with the snapshot and never shown on the public /share/{token} read). A file edited or replaced after the link was created is not carried. A conversation has one link at a time, so to refresh the versions, revoke the link and create a new one. A link created before this behaviour carries no knowledge files (attachments, images, audio and ready videos are immutable and still cross). If the file versions cannot be read when the link is created, the link is created without frozen files, and Continue then carries no conversation-owned files. Only files of messages that are in the frozen snapshot are considered; the snapshot ids are re-validated against the server-derived source conversation, so a forged id carries nothing. Not carried: MCP-app rows, videos still pending, and files of messages outside the snapshot.
    • In-transaction copy and outcomes. The message rows, attachments, image/audio rows and project links are copied in one transaction: if they cannot be read at that moment the call fails (404 {"error":"share not found"} when the source is gone, otherwise 503/500) and no half-built continuation is left behind.
    • Best-effort post-commit copies. The knowledge-file and video copies run after that transaction commits and are best effort: a file whose bytes cannot be copied is left out (its copy is removed and no card is linked — never a card that opens empty), so in a rare fault some files may be missing from an otherwise complete continuation. This adds no new rate limit or quota: it is part of the existing create call.
    • Provenance. Copies made across tenants are marked as coming from outside the tenant; same-tenant copies keep the source's provenance.

    The continuation is flagged share_forked: 1 in the conversation object (server-derived, read-only, never accepted from a request body) — set to 1 only when the frozen snapshot actually imported at least one user/assistant message; an empty or system-only snapshot stays 0 and gets no notice. The model is told in its instructions that some files the transcript refers to may not have come across (files that were edited since the link was created, or that could not be copied, are missing), and that it must not restate the contents of a file it cannot find or present a reconstruction as the original; a file that is listed in its file list or returned by its file tools is available and is read normally. The flag rides along when the recipient forks the continuation ("Continue in new chat"), because the fork copies the same messages and the notice stays accurate for files that never came across.

  • Retention: a bound continuation in the same workspace inherits the project's deletion period. An unbound continuation does not — it falls back to the user/workspace period.

Limits of this control. It guards the in-product continue path against accidental egress; it is not a data-loss-prevention wall.

Two of the ways around it are now closed. Minting a link for a conversation in such a project is refused, and the public read is refused as well — so links that already exist, and links whose project is tightened after the link was sent, stop resolving. And releasing the conversation from the project — detaching it, or moving it elsewhere — requires owner rank on that project, so the person who published the link cannot simply detach the source and let every outstanding link continue unbound.

What remains, deliberately: deleting the project does detach every conversation that belonged to it, after which those conversations carry no restriction. Deleting requires owner rank — the same rank that could set the project's tier to user configurable and release everything anyway — so this is an authorised act, not a bypass; it is recorded in the audit log (project.conversations_released) and the delete dialog states the consequence. A transcript's text can also always be copied out by anyone who can read it; the tier is a guardrail against accidental egress, not a wall against a determined reader.


Prompt-example chips

GET /admin/v1/easy/chips

Returns the suggestion chips shown on the /easy hero. Each entry carries a slug, a label, an icon, and one or more example prompts; the response is scoped to the caller's tenant, with any per-persona overrides applied. Only enabled chips are returned, and the server-side steering system prompt attached to a chip is never included in the response. A tenant with no configured examples receives the curated defaults.

The chip a user picks is sent back on conversation creation as hint_task_slug, which steers the system prompt only — it does not select a model.


A link can open the chat with text already in the message box — the prompt library's Use in chat, the "a minute for a first try?" e-mail. The text travels in the URL fragment, which a browser never sends to a server:

https://<your-host>/easy#text=<percent-encoded text>
https://<your-host>/easy/c/<conversation-id>#text=<percent-encoded text>

The text only ever pre-fills the message box — of a new chat (/easy) or of that conversation (/easy/c/<id>). Nothing is ever sent automatically, on any route: the reader sees the text, can edit it, and presses send. It replaces an unsent draft.

The application reads the text once, when the page loads, and takes it out of the address bar at once, before any application code reads the address: a reload does not apply it again, and no address the application reports or redirects to contains it (a link opened in an already-open page without a page load — only its fragment changes — is not read at all: its text is only removed from the address at once, and nothing is placed in the message box). If the reader has to sign in first, the text survives a sign-in where the e-mail code is typed into that same page (the page stays loaded). Every sign-in that loads a new page — the sign-in link in the code e-mail, single sign-on, Google/Microsoft — loses the text: the reader lands in an empty chat. That is accepted: the link only saves typing. A text on a link to any other page is removed and ignored.

Accepted: exactly one text entry, percent-encoded UTF-8, at most 65 535 UTF-16 code units once decoded (a character outside the Basic Multilingual Plane, such as most emoji, counts as two). Other fragment or query entries are left alone.

What arrives What happens
No text entry, text= with an empty value, or only whitespace Nothing (an empty value never clears a draft).
text more than once, text without =, a value that is not valid percent-encoded UTF-8, or one longer than 65 535 code units The text is not used, the message box is left as it was, and the chat shows The text in this link could not be read, so nothing was added to your message.
A valid text Placed in the message box, never sent.

In every case the text entry is removed from the address bar.

Older ?text= links (in mails sent before the fragment form) are still read the same way and removed from the address bar at once. That only limits further spread: the browser already sent that one request — the server saw the text in its request line, and wrote it into its error log if that request logged an error. New links always use the fragment, and this compatibility read stays (links already sent cannot be recalled).

Because nothing is sent, a link that some other page or document opens can at most put a draft in front of the user. The same holds for such links inside chat answers or documents (opened in a new tab, dragged, or copied). A mail-security service that rewrites links (Microsoft Safe Links, Proofpoint and similar) receives the whole link, fragment included, in its own address; that is outside this application's control.


Getting a conversation

GET /admin/v1/conversations/<ID>

Returns the conversation with its messages (always a JSON array). Read access is the owner or a member of the project the conversation is shared into.

Status Body Meaning
200 the conversation object —
404 { "error": "not_found", "code": "conversation_not_found" } The conversation does not exist, was deleted (in another tab, on another device, or by retention), or is not visible to the caller. One answer for all three — no existence oracle.
503 { "error": "temporarily unavailable; retry later" } A database fault reading the conversation; retryable. Never folded into the 404, and never the database's own text.

Per-answer cost (cost_usd on a message). An assistant message carries cost_usd — the answer's charged cost in US dollars (see Cost of each answer) — only when the caller may see it: the caller holds the per-user cost permission, or the tenant setting show_cost_to_members is on. For every other caller the server removes the field from every message, here and on the fork response. A conversation continued from a share link starts without any costs (the copied answers carry none). Answers saved before the feature existed carry no cost. A cost_usd sent by the client on POST /admin/v1/conversations/<CID>/messages is ignored: the server is the only source of the amount.

Cost notice (cost_warning on a message). An assistant message carries cost_warning: true when its cost_usd is present, the answer came from an external (non-Myra) model, and the cost is at or above the tenant's cost_warning_threshold_usd (see Cost warning for external models). cost_usd is the charged cost, so an answer on the customer's own provider key (charged 0) never carries it. Whether the model counts as external is decided by the gateway the answer was routed through; an answer that cannot be identified as external never carries it. Otherwise the field is absent, never false. Wherever cost_usd is removed for the caller, cost_warning is removed with it. The fork response follows the same rule.

The object also carries html_convert_available (boolean): true when the caller owns the conversation and HTML conversion would run for it (the code-interpreter gates of its gateway and project). A shared reader and a viewer-role account always get false. The same field is returned when a conversation is created, forked or continued from a share link (the app binds those without a further read); the list endpoint never carries it.

For the owner, the object also carries the conversation's tool-confirmation state (see Chat tool confirmation): untrusted_since (unix seconds of the first untrusted content in the conversation, null when none) and untrusted_source (upload, tool_result or untrusted_origin), both server-derived and read-only; tool_grants (the active "Allow for this conversation" grants, [{connector_id, tool}], empty while the conversation contains untrusted content); tool_grants_ended (present only when the first untrusted content ended some grants: {reason, grants, omitted?}, see Which grants ended); fetch_domain_grants (the approved fetch domains, an array of domain keys, see Approving web domains); and on the assistant message of a turn that asked for a confirmation, tool_confirm ({confirm_id, status, calls, allowed, decided_at, resumed, domains_offered, domains_approved}); and on the assistant message of a turn that asked for an approval by someone else, tool_approvals (a list of requests, see Approval by someone else). A shared reader's view carries none of them.

On a shared reader's view, each message attachment also carries can_download (boolean): whether this reader may download that file — true only for a file they added themselves (see Attachments). The owner's view carries no can_download.

code: "conversation_not_found" is the typed signal the app keys on: a conversation it still has open that answers this way was deleted elsewhere, so the app clears the thread, drops it from the list, shows a non-error "deleted in another tab" notice and returns to the start page — the same path a send, a regenerate, an edit or the post-turn reconcile takes when their own writes answer with the same code (see Messages). The read first waits (up to a few seconds) for any turn that is still being committed for this conversation so it never races ahead of the gateway's persist; a conversation that was deleted while a turn was streaming does not wait — its orphaned claim row is ignored and the 404 is immediate.

The conversation address in the app (/easy/c/<ID>, and the legacy /chat?conv=<ID>). The <ID> in the browser address is validated in the app before anything is fetched. Accepted shape: exactly one path segment that percent-decodes to a conversation id the server mints — 8-4-4-4-12 hexadecimal characters (0f8fad5b-d9cb-469f-a165-70867728950e, any case, no version/variant check: older stored ids carry a non-standard variant digit), optionally prefixed with ghost- for a private conversation; one trailing / is tolerated. Rejected (the app shows This conversation link is not valid and returns to the start page, and no request is made): an empty segment, more than one segment (/easy/c/<ID>/x), a malformed percent sequence (%E0, %, %ZZ), and anything that decodes to another shape. A rejected address is never read as "no conversation" (which would start a new chat under it). /chat?conv=<value> forwards the value percent-encoded as one segment of /easy/c/, so a /, .., ? or # in it cannot change the destination; the same check then applies. A well-formed id that the server answers with 404 conversation_not_found takes the "deleted" path above; a 5xx or network failure while opening a conversation shows This conversation failed to load with Retry in the message input and is not retried automatically.


Updating a conversation

PATCH /admin/v1/conversations/<ID>

Patchable fields (title at most 255 characters → 400 title_too_long; system_prompt at most 65 535 bytes → 400 system_prompt_too_long; max_tokens a whole number 0–2147483647 (0, -0 and null mean not set and leave the stored value unchanged; a stored max_tokens cannot be cleared via PATCH) → otherwise 400 invalid_max_tokens; a wrong type → 400 invalid_title / invalid_system_prompt; a rejected patch applies nothing): title, model, system_prompt, max_tokens, gateway_id, starred, memory_disabled, personal_style_disabled (each accepts true/1/"1" or false/0/"0"; absent = unchanged; any other value, null included, is refused with 400 invalid_<field> (formerly <field>_invalid) and nothing in the patch is applied), web_search (0/1, also "0"/"1"/false/true; any other value, null included, is refused with 400 invalid_web_search and nothing in the patch is applied), picked_tier (or null to clear an explicit mid-chat model pick), archived_at (a whole number of seconds from 1 to 253402300799, or null to un-archive; anything else → 400 invalid_archived_at), project_id, the routing hints hint_tier, hint_task_slug, hint_model_override and hint_pii_preference (same shapes as on create; see Route policy validation), and mcp_connectors (see Per-conversation connector selection).

Database faults on the chat PATCH routes are opaque. On this route, the message edit / correction PATCH /admin/v1/conversations/<CID>/messages/<MID>, the comment resolve PATCH /admin/v1/conversations/<CID>/comments/<ID>, PATCH /admin/v1/memories/<ID>, PATCH /admin/v1/chat-commands/<ID> and PATCH /admin/v1/feedback/<ID>, a failed write — and, on the comment resolve, its re-read after the write — answers the sanitised 500 { "error": "internal error", "request_id": "…" }: no code, never the database's own error text, which names tables, columns and stored values (it goes to the server log under the same request_id). A chat-commands write whose bounded retry was exhausted on a transient conflict, and a message edit (content / content_text) or display correction (corrected_content) that hit a transient conflict and wrote nothing, answer 503 { "error": "temporarily unavailable; retry later" } instead — send it again. A failed read before the write (the comment resolve's comment lookup, the conversation and project lookups) answers the same 503. The other lookups of the conversation PATCH keep their own fixed answers (the 503 project_tier_unresolved / project_access_unresolved / temporarily unavailable; retry later above), as do the fixed client answers (400 validation, 404, 413 row_too_large).

Patching project_id moves the conversation to another project (or detaches it with null). The conversation's own files move with it into the project's file space; a file whose name is already taken in the project (including by a file you cannot see) is renamed to the next free name (report.md → report-2.md, …) — never deleted — and the move, the renames and the re-pointing happen together or not at all. project_id must be a non-empty string or null — any other type (a number, an object, "") is rejected with 400, on the platform-admin path too. A move or detach also ends the conversation's persistent code-interpreter kernel, if it has one: the next code run starts with a fresh kernel (variables from earlier turns are gone).

Attaching requires membership: a non-admin caller must already be a member of the destination project. The destination must also belong to the conversation owner's workspace — platform administrators included — otherwise 403 project_tenant_mismatch; and moving a project-bound conversation onto a gateway of another workspace is refused the same way (see Project binding stays in one workspace). A destination the caller cannot see (it does not exist, was deleted, belongs to another workspace, or the caller holds no role on it) answers the shared audited 404 { "error": "not found" } to a non-admin, byte-identical to an unknown id; a destination the caller can see through a group grant, organisation share or department access but is not a direct member of answers 403 { "error": "not a member of destination project", "code": "not_project_member" }; branch on code, the error text is informational. The membership check runs first, so a non-admin who lost access and re-sends the committed project_id gets the 404; a re-send is exempt only from the workspace / tier checks. A platform administrator naming a destination that does not exist gets the same 404. A storage fault is 503.

Releasing — detaching the conversation, or moving it to a different project — is gated when the conversation's current project restricts data residency (Local only or PII mandatory). Attaching is gated because the conversation would gain the project's knowledge; releasing is the direction that drops a residency guarantee, so it requires owner rank on that project (platform admins bypass, as everywhere). A project member who is not an owner gets 403 project_release_forbidden and the committed binding is unchanged. An unrestricted project detaches freely, exactly as before.

If the conversation's current project cannot be confirmed at all (it was deleted, or it belongs to another workspace), every project_id change is refused with the same 403 for non-admins: nobody holds owner rank on a project that no longer resolves, and moving the conversation anywhere would drop the restriction that project carried. If any of the three authoritative reads in that chain — the conversation's gateway, its project's tier, or your access to that project — fails transiently, the request returns 503 (project_tier_unresolved / project_access_unresolved) — never a silent detach.

Re-sending the project the conversation is already in is not a release and is never gated: the gate keys on an actual change, not on the field being present.

An authorised release is written to the audit log as conversation.residency_released, with the project it left and that project's tier. The change and its audit entry are committed in one database transaction: a request that changes nothing (not your conversation, an empty patch) writes no entry, and a failed audit write rolls the change back. If nothing was stored the answer is a retryable 503 { "error": "temporarily unavailable; retry later" }; any other failure is the sanitised 500 with the request id.

temperature is no longer accepted and is silently ignored.

Per-conversation connector selection (mcp_connectors)

mcp_connectors stores which MCP connectors the user chose for this conversation. The web app sends it with each message: the request names the connectors of the selection that the sender has connected, in the stored order (ids the sender no longer has connected are dropped). null (never chosen) keeps the default, the first 8 connected connectors; [] sends none. A stored value that is present but not a list of strings is never read as "default": the web app treats it as [] (sends none) and reports it. The gateway still re-checks every named connector against the sender.

A new conversation inherits the selection. A conversation created with POST /admin/v1/conversations that does not carry an mcp_connectors field starts with the caller's most recent selection: the one stored on their most recently updated non-deleted conversation whose mcp_connectors is not null. Only connectors the caller can see now are kept, in the stored order. Rules:

  • Nothing chosen yet (every conversation is null): the new conversation has none (null, the GET omits the field).
  • A stored [] (explicitly none) is inherited as [], so "none" is sticky. Setting a conversation back to null makes the next new chat fall back to the previous non-null choice.
  • If every stored id has since been deleted or is no longer visible, the result is null, not [].
  • Only the latest non-null row is consulted; an unreadable (corrupt) stored value yields null and is not replaced by an older row.
  • Inheritance is a convenience and never blocks a create: if the selection or the connector list cannot be read, the conversation is created without a selection and the fault is logged.
  • A scheduled-task or bridge "ghost" conversation does no inheritance read.

On create. POST /admin/v1/conversations accepts mcp_connectors with the same shape rules and the same 400 invalid_mcp_connectors as the PATCH below:

Sent value on create Stored Meaning
field absent the inherited selection above inheritance (for a share-continue: the source's selection, filtered)
null null never chosen; no inheritance
[] [] explicitly no connectors
["id", ...] the list, in the order sent the selection; wins over inheritance and over the share source's copy
any malformed or invisible value nothing 400 invalid_mcp_connectors; no conversation is created
a session without a user identity (field present) nothing 401; no conversation is created
a fault while reading the connector list (field present) nothing 503, retry; no conversation is created

A ghost create returns the validated value in its response and persists nothing. A caller with an empty workspace and a non-empty list is refused 403 like GET /admin/v1/mcp.

Sent value Stored Meaning
field absent unchanged the selection is left alone
null cleared never chosen; the client falls back to its default behaviour. The GET then omits the field
[] [] explicitly no connectors; the GET returns [] (an array)
["id", ...] the list, in the order sent the selection

The one-hop connect endpoint (GET /admin/v1/mcp/connect, see MCP connectors API) may append the connected connector to an explicit selection: never to a null selection, and never past 8 ids.

Accepted shape: an array of at most 8 distinct connector ids, each a non-empty string of at most 64 bytes (UTF-8). Anything else is refused with 400 and the fixed body {"error": "mcp_connectors must be null or an array of at most 8 distinct connector ids", "code": "invalid_mcp_connectors"}, and nothing in the patch is applied (a body that also carries a title does not write the title):

Refused input Status
an object ({}, {"a":1}), a string, a number, a boolean 400 invalid_mcp_connectors
an element that is not a string, is empty, or is longer than 64 bytes (UTF-8) 400 invalid_mcp_connectors
a duplicate id, or more than 8 ids 400 invalid_mcp_connectors
an id that is not a connector the caller can see: unknown, belonging to another tenant, or another user's private connector 400 invalid_mcp_connectors (the same body, so the response does not reveal whether the id exists elsewhere)
a session without a user identity (non-empty list only) 401, nothing written
a session without a tenant (non-empty list only) 403, nothing written
a fault while reading the connector list 503, nothing written

Visibility is the same rule as GET /admin/v1/mcp, the chat's connector catalog (tenant-wide connectors, admin-provisioned ones and the caller's own private ones; GET /admin/v1/mcp/mine is the narrower private-only subset). It is decided from the session, never from the body.

Owner only. Like every other field of this route, the write is scoped to the conversation's owner: a project co-driver or editor who sends mcp_connectors writes nothing (the owner-scoped no-op described above); it is not a 403.

The GET field. GET /admin/v1/conversations/<ID> returns mcp_connectors to the owner in full. A non-owner reading the conversation (a project member, or a live-room co-driver) receives the owner's selection filtered to the connectors that reader can see, in the owner's order, so another user's private connector id is never disclosed. Nothing visible left gives [] (an array, never absent): the owner chose, so the reader's turns name no connector rather than falling back to the default of the first 8. A selection read that fails also gives [] and is logged; the request still succeeds. The field is absent when the owner never chose, and when the stored value cannot be read back as a valid selection (a hand-edited or corrupt row; logged), the same as on the owner's own GET. This differs from the inheritance paths above, where nothing visible left gives null. A co-driver picks up an owner's change after the next message committed while the member's page is not streaming its own turn, or on reload. The conversation list never carries the field.

Default selection read

GET /admin/v1/me/mcp-connectors-default returns the selection a new conversation would start with, so a client can show it before the first message:

{ "mcp_connectors": ["connector-id"] }

mcp_connectors is an array, or null when nothing is chosen yet. [] means an explicit none. The value is exactly what the next POST /admin/v1/conversations without an mcp_connectors field would store for this caller (the same inheritance rules as above). A fault reading the selection gives null and is logged. Without a session the answer is 401.

Stored ids can go stale. The PATCH check is a visibility check at that moment, not a guarantee that the connector can be invoked and not lasting authorization. A connector deleted or made private afterwards, or one an admin later re-scoped, still appears in the stored list; the GET returns the ids as stored and the use-time check (which resolves the connector for the calling user) is what decides whether a connector is actually used.

Route policy validation

A patch that changes the conversation's route target — model, gateway_id, a routing hint_* field, or project_id — is validated server-side against the post-patch project and gateway before it is persisted. The client picker is a convenience, never the authorization boundary: the server evaluates the resulting (model, gateway_id) with the same tier/PII predicates the inference path enforces one step later, so a pin can never be saved that would make every subsequent message fail. Validation covers a project-move-plus-model in a single request (the post-patch project is used), and runs on the resolved values (a routing hint is re-resolved first, then the result is validated).

Rejected (the patch is refused and the committed route is left unchanged):

  • 400 model must be a string — a present model (top‑level, or inside hint_model_override) that is not a string and not JSON null is malformed and is rejected at the boundary, before routing or persistence, on any tier. A string pins; null or an absent model is a no‑op (the pin is left unchanged — null (not an empty string) is the deferral signal, and it does not clear the pin). An empty string resolves to no provider: on a local_only project it is refused (403, below); on other tiers it defers to Auto.
  • 400 invalid_model_id — a present model string longer than 128 characters (or not valid UTF-8) is refused at the same boundary (the column holds 128 characters); nothing is written.
  • 403 model_not_allowed_for_project — the resulting model resolves to a non-local provider on a local_only (Tier‑1) project. Only locally‑hosted models are permitted; pick a local model. A first‑party (Myra/local) pick is always permitted here.
  • 403 gateway_not_allowed_for_project — the resulting gateway cannot satisfy the conversation's PII policy (a pii_mandatory project, or a tenant with mandatory PII masking, pinned to a gateway that does not scrub request‑phase PII), or the gateway_id is unknown (any caller), or — for a non-admin caller — the request MOVES the conversation to a gateway that does not route (purpose other than production; the conversation's already-committed gateway is never re-refused, so an unrelated edit of an existing conversation is unaffected), or belongs to another tenant (non‑admin callers only — platform admins may route through another tenant's gateway).
  • 400 gateway_id_invalid — a present gateway_id that is not a string, is "", longer than 36 bytes, invalid UTF-8 or contains a control, line-break or invisible formatting character (see refused characters); rejected before any lookup (null is a no-op, as before).
  • 403 caller_has_no_tenant — the caller's account belongs to no workspace and the patch changes routing hints (hint_*): the route cannot be re-resolved, so nothing is written (earlier releases answered 500 missing_tenant_id). A patch without routing hints, such as a rename, is unaffected, and an id the caller does not own (unknown or foreign) is answered like any owner-scoped miss, 200 {"ok": true} with nothing written — the ownership check comes first, so there is no existence oracle.
  • 403 department_gateway_not_allowed — the caller's department does not allow the resulting gateway (checked on every route-changing patch, also for the committed gateway — a user moved into a department re-pins to an allowed gateway).
  • 403 project_gateway_locked — the post-patch project is locked to another gateway: moving a conversation into a locked project requires its gateway in the same patch, switching a locked project's conversation to another gateway is refused, and moving a conversation out of a locked project (move or detach) requires department administration (DEPARTMENTS_MANAGE + tenant admin) or the project's owner (not in an impersonation session). If the caller's project role cannot be read, the move is refused with project_tier_unresolved (retryable).
  • 503 { "error": "temporarily unavailable; retry later" } — a database/config read the check depends on failed (including the model catalogue, the gateway's routing rules or provider opt-in set that decide which provider the model resolves to); retryable, nothing written. The patch fails closed rather than skipping the check, and a provider resolved from a failed read is never judged as local or non-local.

On create and on a routing-hint re-resolve, route selection only considers the gateways the caller's department allows and, inside a locked project, the locked gateway; the refusals are 403 department_gateway_not_allowed / 403 project_gateway_locked for an explicit pick outside that set, 409 department_pii_twin_not_allowed when the request needs PII masking but the masking twin of the chosen gateway is not allowed, and 409 department_no_gateway when the department allows no usable gateway. Create-from-share checks the same: a conversation continued from a locked project's share never comes out unbound (403 share_source_project_forbidden for a non-member) and a bound continuation must use the lock gateway.

A PATCH carrying only routing hints (for example hint_pii_preference alone, without hint_model_override) re-resolves the route as Auto: it does not keep an earlier explicit model pick. Send hint_model_override together with the preference to re-resolve the pick itself.

Not validated (unaffected): a title/starred/web_search/memory_disabled/personal_style_disabled/archived_at-only patch (it does not change the route target), and a non-owner patch (owner-scoped no-op). A patch that does not pin a concrete gateway defers the check to send time.


Deleting a conversation

DELETE /admin/v1/conversations/<ID>

Soft-deletes the conversation (owner-scoped) and best-effort reaps its file space (a reap failure is logged, and the deleted-state filter keeps orphans unreadable) and any persistent code-interpreter kernel. The <ID> path segment is untrusted input; ownership is enforced server-side in the delete itself — the client is never the authz boundary.

  • 200 {ok:true} — idempotent: returned for an actual delete AND for any owner-scoped miss (a foreign user's id, an unknown id, or an already-deleted id). A non-owner calling this endpoint gets the same 200 shape while the row — and the owner's live code-interpreter kernel — is untouched; there is deliberately no existence oracle.
  • 500 { "error": "internal error", "request_id": "…" } — a storage fault. The delete may not have happened; retrying is safe (a delete of an already-deleted conversation answers the same 200). (Previously a fault was swallowed as a dishonest 200 {ok:true}.)

Deleting only an empty conversation (?if_empty=1)

DELETE /admin/v1/conversations/<ID>?if_empty=1 deletes the conversation only while it has no message — no message row at all, a soft-deleted one included (a conversation that ever held a message is not empty). The check is part of the delete itself (one statement). A message that lands in a conversation deleted meanwhile is removed again and refused with 404 conversation_not_found (the app then gives the message back) — so a message sent from another tab or device at the same moment either lands first (the delete is then refused) or is refused itself; it is not kept inside a deleted conversation. A conditional delete that removes nothing also runs no clean-up (unlike a repeated plain DELETE, which retries a failed file / tool-result clean-up). The app uses it to discard the empty conversation a first message leaves behind when it is stopped before it was saved; the client's own belief that the conversation is empty is never the authority.

The if_empty query parameter is untrusted input, validated before anything is deleted (there is no cap on the number of query parameters it is read from; a near-miss key such as IF_EMPTY or if_empty[] is rejected like a malformed value, never read as absent):

if_empty Behaviour
absent the unconditional delete above (unchanged)
exactly 1 the conditional delete
anything else — another value (0, true, 11), empty (?if_empty=), a bare flag (?if_empty), repeated (?if_empty=1&if_empty=1) 400 {error, code: "invalid_if_empty"}, nothing deleted (never read as absent)
  • 200 {ok:true} — deleted, or the same idempotent owner-scoped miss as above (a foreign, unknown or already-deleted id — still no existence oracle).
  • 409 {error, code: "conversation_not_empty"} — the caller's live conversation has messages: nothing is deleted, nothing is reaped (its files, tool results and code-interpreter kernel stay).
  • 500 { "error": "internal error", "request_id": "…" } — a storage fault; the delete may or may not have landed — re-read before repeating it (a repeat of a landed delete answers the same idempotent 200).

Forking a conversation ("Continue in new chat")

POST /admin/v1/conversations/<ID>/fork

Creates a new conversation that copies every committed message of <ID> up to and including a chosen branch-point message, re-references the files those messages carry, and continues in the same project with the source's model preserved. This backs the "Continue in new chat" action on an assistant reply: the user branches the thread and keeps the full prior context and the uploaded files.

Request body:

{ "branch_message_id": "<message id in this conversation>" }
  • branch_message_id — required, non-empty string. The id of the message (the clicked assistant reply) that is the last message copied into the fork.

Behaviour:

  • Copies the messages ≤ the branch point (in conversation read order), the source's project_id, model, gateway_id, picked_tier and system/toggle settings.
  • Sets model_unlocked = 1 on the new conversation: the model picker is unlocked for the fork even though it carries messages (the normal mid-thread model freeze is waived), so the user can switch models. This is one-shot — the first real turn persisted afterwards clears it and the fork re-freezes like any other conversation.
  • Project-owned files are re-referenced (the same file rows — no byte copy), so they stay authorized in the same project. Conversation-owned files (a project-less chat's own attachments / generated files / write_file artifacts) are duplicated under the new conversation so the copied messages keep valid, authorized, downloadable, inference-visible file links.
  • Copies the source's connector selection (mcp_connectors), filtered to the connectors the caller can see and in the source's order ([] stays []; nothing visible left, or a source that never chose, leaves the fork without a selection (null), unlike the GET projection for readers, which gives []). This is best effort: if the selection cannot be read or written the fork still succeeds, without it.
  • Returns 201 with the new conversation (same shape as create/get, messages included).

Authorization and validation (the client is never the authz boundary):

  • The caller may fork a conversation they own, or a conversation shared into a project's feed that they have access to (the same access that lets them view it — owner ∪ (shared_in_project ∧ project-access)). Project access is resolved through the one project-access resolver, so it counts a direct member, a member of a group granted on the project, and — while the tenant's org-wide sharing is on — any user reached by the project's organisation share (the same three channels that let them open the project and read its files). The fork is always a private copy owned by the caller (not shared into any feed). A conversation that is not owned by the caller and not a feed conversation of a project they can access — or an unknown <ID> — returns 404 not_found (no existence leak). The fork is bound to the source's project, so — like a create — the project (and, for a project-bound source, the copied gateway) must belong to the caller's own workspace: otherwise 403 project_tenant_mismatch and nothing is created. Project access alone is not workspace-bound (a platform administrator sees projects of every workspace), so this is checked inside the fork's own transaction. This also applies to forking a conversation that was bound across workspaces before that rule existed. A source still pointing at a project that has since been deleted answers 403 project not accessible and nothing is created. This stays a 403 (not the audited 404 of a project you cannot see) because the project is the source conversation's own committed project, read after the fork's access check passed (the owner, or a member of the project's feed for a conversation shared to it): the caller already sees the conversation and its project binding, and no caller-chosen project id is involved.
  • branch_message_id is validated to be a committed message of <ID>. A missing or empty value returns 400; an unknown, foreign, deleted, or still-streaming id returns 404.
  • The copy runs in one transaction that takes the source conversation's row lock first — the same order every message writer (edit, correction set and clear, delete) uses — and copies each message's large text columns on the database side, so a message the gateway could store can always be forked. A transient serialization conflict (a deadlock or lock wait against a concurrent write) is retried transparently; if it persists, the fork answers 503 (retry later) rather than a 500.

Sharing a conversation publicly

POST /admin/v1/conversations/<ID>/share

Generates a public read-only token and returns 201 { "token": "<TOKEN>", "url": "<URL>" }. The url is the absolute link a recipient opens: /shared/<TOKEN> on this deployment's own app host (the same origin every other product link uses), so a link minted on one environment always resolves against that environment's data. A conversation has at most one link.

Optional body field if_absent (JSON boolean):

  • true — mint only if the conversation has no link yet. If it already has one, the answer is 409 { "error": "already_shared" } and the existing link is left untouched; read it with GET …/share. The web app always mints this way, so a link created meanwhile in another tab or on another device — and possibly already sent — is never silently replaced.
  • absent or false — replace: the existing link (if any) stops working and a new one is minted. A concurrent mint that wins the race answers 409 already_shared as well.
  • any other value (a string such as "true", a number, null, an object) — 400 { "error": "invalid_if_absent" }, nothing written. A malformed flag is never read as "absent", because absent means replace.

The body itself is optional: no body (or only whitespace) is the same as {}. A body that is valid JSON but not an object (null, true, 42, "x", an array) is 400 invalid_if_absent as well, and a body that is not valid JSON, not valid UTF-8, or carries a non-finite number (NaN, Infinity, 1e999) is 400 malformed_body — none of them is read as "no flag". A field other than if_absent is ignored (a misspelled ifAbsent therefore means replace).

Every answer of POST, GET and DELETE …/share carries Cache-Control: no-store: they hand out or withdraw a public read credential, so no cache may replay them.

Masked at creation. When any gateway the conversation used masks personal data (a PII-protecting guardrail), or the project requires PII masking, the snapshot is masked by the server before it is stored, with the same kind of placeholder the model sees, and carries "pii_masked": true. Nothing is written when masking cannot be done. The mint answers instead:

Status Body Meaning
503 { "error": "share_pii_masking_unavailable", "code": "share_pii_masking_unavailable", "message": … } The privacy check is temporarily unavailable. Nothing was stored. Retry.
422 { "error": "share_pii_unmaskable", "code": "share_pii_unmaskable", "message": … } A gateway requires masking, but cannot mask for a public link. Permanent until the gateway changes.
422 { "error": "share_too_large_to_mask", "code": "share_too_large_to_mask", "message": … } The conversation is too large to mask. Permanent for this conversation.

Refused for a restricted project. A share link is a persistent, unauthenticated read credential. Minting one for a conversation whose project restricts data residency (Local only or PII mandatory) — or whose project cannot be confirmed — returns 403 share_restricted_project and writes no share row; a transient failure to read the project's settings returns 503 project_tier_unresolved. A conversation the caller does not own, or an unknown id, is 404 { "error": "not_found" }. Unlike the release gate on PATCH, this has no owner-rank exception: an owner who genuinely wants a public link can move the conversation out of the project first, which is gated and audited, whereas a mint that succeeded from inside the project would be indistinguishable from an accidental one.

GET /admin/v1/conversations/<ID>/share — returns the active share link as { "token": "<TOKEN>", "url": "<URL>" }. The web app calls it every time the Share conversation dialog opens, so an existing link is shown with Revoke link instead of being replaced by a new one. It applies the same residency check as the mint and the same personal-data read check as the public read, so a token minted before the project was tightened, or before masking applied, is not handed back as a live-looking URL for a link the public read now refuses.

  • Who may read it: only the conversation's owner — the only principal who can mint a link (the mint is owner-gated and refused while impersonating). The read is scoped to the share row the caller created; no tenant, admin or platform-admin role widens it.
  • Accepted input: <ID> is one non-empty path segment, bound as a query parameter (never interpolated). An empty segment (/conversations//share) is not routed.
  • Rejected:
Status When Body
404 No link, an unknown or malformed id, a conversation that belongs to someone else (same or another tenant), or a deleted conversation — deliberately one answer, so the read reveals nothing about other users' conversations { "error": "not_shared" }
403 A link exists, but the conversation's project restricts data residency, so the public read refuses it (it is served again if the restriction is lifted, so DELETE still revokes it) { "error": "share_restricted_project", … }
403 A link exists, but it was created unmasked and a gateway of the conversation now masks personal data, or a PII mandate is in force — the same check as the public read; no token or URL is returned. Permanent until the owner revokes it or creates a new link { "error": "share_needs_recreate", "code": "share_needs_recreate", "message": … }
500 A link exists, but its stored snapshot cannot be decoded. Fails closed: no token or URL is returned. The web app offers Revoke link only (no Copy, no retry) { "error": "share_unreadable", "code": "share_unreadable", "message": … }
403 The session is impersonating a user { "error": "impersonation_forbidden", "code": "impersonation_forbidden" }
503 A database fault (sanitised error), the personal-data check could not be decided, or the project's residency settings could not be read (project_tier_unresolved) — retryable, never a 404 sanitised error / { "error": "project_tier_unresolved", … }

A client MUST treat only 404 not_shared as "no link". Any other failure is "unknown": the web app then offers a retry, never Create link, because it cannot tell whether a link already exists (a mint without if_absent would replace it; the web app mints with if_absent: true, except Create new link for a share_needs_recreate link, which deliberately replaces it). The web app also rejects a 200 whose token is not 64 lowercase hex characters or whose url is not an absolute http(s) URL whose path ends in /shared/<token> (no query, no fragment) — it then shows that it cannot display the link, and still offers Revoke link (a 200 proves a link exists, and revoking needs only the conversation id).

DELETE /admin/v1/conversations/<ID>/share — revokes the share. A database failure is the sanitised 500 { "error": "internal error", "request_id": "…" } — the link may still be live, so revoke again (never a 200 while the link survives).

Reading a shared snapshot (public, unauthenticated)

GET /share/<TOKEN> — the public read-only snapshot the /shared/<TOKEN> page renders. No authentication. Served same-origin on the app host (the SPA fetches it relative, so a recipient's browser never needs a second origin), with permissive CORS (Access-Control-Allow-Origin: *) so it is also readable cross-origin.

The page that renders this snapshot loads no Markdown image from any message (user or assistant), whatever its address (same-origin, external or data:); it shows inert alt text instead.

The token is the only input; it is matched exactly (a 256-bit random hex string — not enumerable) and resolved fail-closed through the owning tenant's live state, so a revoked share or a decommissioned tenant is indistinguishable from an unknown token.

Responses:

Status Meaning Body
200 Snapshot found { "title": string, "messages": [ { id, role, content, created_at, … } ] } — messages never carry the sharer's internal gateway_id; messages is always a JSON array (an empty conversation returns [], never {}); system turns are excluded. An assistant message that carried the No file was created note when the link was made has "file_claim_badge": "no_file" (absent otherwise).
404 Unknown / revoked / expired token, the conversation was deleted, the owning tenant is decommissioned, or the owning workspace is suspended (one answer for all of them, byte for byte, so a link holder cannot tell a suspension from a dead link; the reason is in the server log only) { "error": "not found" }
403 The conversation's project restricts data residency, or its binding cannot be confirmed — permanent { "error": "share_source_project_forbidden", "message": … } (the machine code, unlike the human string the other error bodies carry)
503 Service starting (schema migration in progress) — retryable { "error": { "code": "service_starting", "message": … }, "code": "service_starting" } with Retry-After and X-AIG-Error: service_starting (CORS included)
503 A database fault reading the share, a failed project-tier read, or an unreadable suspension state — retryable { "error": "temporarily unavailable" } (carries CORS)
403 The snapshot is not masked (created before masking applied) and a gateway of the conversation now masks personal data, or a PII mandate is in force — permanent until the owner creates a new link { "error": "share_needs_recreate", "code": "share_needs_recreate", "message": … }
400 Missing token { "error": "missing token" }
500 Corrupt stored snapshot (permanent) { "error": "invalid snapshot" }
204 OPTIONS preflight empty

A masked snapshot ("pii_masked": true) is served as stored; the public read never masks. The masking reflects the gateway configuration in force when the link was made: after a gateway starts masking or gains a detector, an existing masked link keeps its earlier masking, so the owner creates a new link to apply the new rules. An unmasked snapshot is served only while no gateway of the conversation masks personal data and no PII mandate applies. "The gateways of the conversation" are the conversation's own gateway plus every gateway that produced a message in it (deleted messages included) and belongs to the same workspace as the conversation's gateway; the link creation and every read (the public page and the continue) use this one set. To decide this, each anonymous view of an unmasked snapshot performs extra database reads (the conversation's gateway set and each of those gateways' PII configuration); a masked snapshot needs none. When the check cannot be decided, the read answers 503 { "error": "temporarily unavailable" } (retryable).

The web page treats the body as untrusted: it accepts a snapshot only when title is a string and every entry of messages is an object whose id, role and content are strings. Any other shape (a non-string content, a non-object entry, a non-string role) shows the same retryable load-error panel as a body that is not a snapshot; nothing of it is rendered.

A recipient client MUST treat a 404 as a genuine "no longer shared", a 403 as a permanent policy refusal (never offer a retry), and any other non-200 (a 503, a 5xx, a non-JSON body, or a network error) as a transient, retryable failure — never as "not found".

The residency check runs on every read, not only at mint time: that is what closes links which were already sent, and links whose project is tightened afterwards. The refusal deliberately names no project, tier or owner — the reader here is unauthenticated, so a finer answer would be an oracle over a stranger's project — and it shares one code with "cannot confirm" for the same reason.

What a token holder can still infer, stated plainly. The body says nothing, but the status does: someone holding a valid token can tell 403 (restricted, or unconfirmable) from 404 (unknown / revoked / deleted) and from 200, and can poll it. So they can observe that a project was tightened, or that the conversation moved, without learning which project, which tier, or whose. That is an accepted trade: collapsing the refusal into 404 would tell a legitimate recipient that the owner revoked their link when they did not, and would deny the SPA the honest "not available" state. The token itself is a 256-bit random string, so none of this is reachable without one. Every response carries Cache-Control: no-store and X-Robots-Tag: noindex, nofollow, because the decision is taken per request and must never be replayed from a CDN.

Deleting the conversation now also takes its public link down; previously the snapshot stayed readable at /share/<TOKEN> after the owner deleted the thread. The same resolver backs continuing a shared conversation, so continuing a share whose source was deleted returns 404 as well.


Sharing a conversation with a project

POST /admin/v1/conversations/<ID>/share-project — shares a conversation the caller owns into its project's feed, so everyone with access to the project can read it. The conversation must already belong to a project; otherwise the request returns 400 { "error": "conversation is not in a project" }. A conversation the caller does not own, or an unknown id, is 404 { "error": "not_found" }. Success: 200 { "ok": true }.

Who may share. The caller must have access to the project through any channel — a direct invite, a group grant, or the organisation share — resolved by the one project-access resolver (the same access that lets them open the project and chat in it). A caller with no project access via any channel is refused 403 "not a project member"; a transient failure to resolve access returns 503 (retryable), never a silent 403. Because the conversation read above is owner-scoped, a caller can only share a conversation they own.

DELETE /admin/v1/conversations/<ID>/share-project — removes a conversation from the feed. This reverts it to private to its author (shared_in_project = 0); the conversation is not deleted, and any files it generated revert to Only you visibility (the generated-file share gate keys purely off the source conversation's shared state). Un-sharing is permitted for the conversation's author, any effective project owner (a direct owner or an owner-group grant), and platform admins — so the person responsible for a project can remove another member's conversation from the feed they own (for example after a name-invited member leaves). The refusal is deliberately split so it cannot become an existence oracle: a non-author who cannot see the conversation at all — it has no project, it is not on the feed (shared_in_project ≠ 1), or they have no access to its project via any channel — gets the same audited 404 { "error": "not found" } as an unknown id (see a project you cannot see): byte-identical for an unknown id, a soft-deleted conversation, a project-less conversation, a conversation not on the feed and a caller without access to its project (including another workspace's user), and each such request is recorded as one access.denied security event. A soft-deleted conversation answers this 404 for every caller, including its own author, who therefore also writes an access.denied row. Only a caller who can see it on the feed but is a plain editor/viewer (neither author nor owner) gets the explanatory 403; a transient failure to resolve access returns 503. Un-sharing a conversation that is already private is a graceful no-op.

Neither endpoint attaches the conversation to a project — patch project_id to move it.


Live shared session (room)

Turns a conversation that is shared into a project (see above) into a live room: project members with read access watch new messages appear in real time, see who else is present, and take turns writing through a single-driver write lock.

Only the current driver may write. Turn-taking is enforced server-side — the client is never the authorization boundary. The lock is user-keyed with a lease: a driver who disconnects without releasing is reclaimable once the lease lapses.

In the app, any participant who may drive (the owner, or a project member with the owner/editor role) can take the wheel when the seat is free and hand it over when done; the composer is enabled only for whoever currently holds the seat. Taking the wheel only succeeds when the seat is free or its lease has lapsed — it never forcibly steals an active driver's turn. A viewer-role member can watch but never drive.

Start / stop

POST /admin/v1/conversations/<ID>/live — start the session (owner only). The conversation must already be shared into a project; otherwise the request returns 409. The starter becomes the initial driver. Response: { session, roster }.

DELETE /admin/v1/conversations/<ID>/live — stop the session (owner only). Clears the roster and driver lock.

For both: an unknown conversation, or one the caller does not own, is 404 { "error": "not found" }; a database fault reading the conversation is 503 { "error": "temporarily unavailable; retry later" } (nothing written — retry). If the session was started but reading it (or its roster) back fails, POST answers the sanitised 500 { "error": "internal error", "request_id": "…" } — the session is live; re-read the snapshot.

Snapshot

GET /admin/v1/conversations/<ID>/live — current { session, roster, can_drive } for the caller. Read access required (owner or project member); a non-member receives 404 (no id-enumeration surface). can_drive is true for the owner or a project member whose effective role is owner/editor. A database fault reading the session, the roster or the caller's role is 503 { "error": "temporarily unavailable; retry later" } — never an empty roster.

Live stream (SSE)

GET /admin/v1/conversations/<ID>/live/stream — a long-lived text/event-stream. Read access required (non-member → 404, before any bytes stream). The hello snapshot (session, roster, the message-tail cursor) is read before the stream opens, so a database fault there is 503 { "error": "temporarily unavailable; retry later" } — never a hello with an empty roster. Each event is a JSON object with a type:

type payload
hello { you, can_drive, session, roster } — sent once on connect
presence { session, roster } — the current roster + driver, each tick (a tick whose roster read fails sends no presence event; the next tick does)
message { message } — a message committed after connect (history is loaded via the normal conversation GET)
session_ended the session was stopped

The stream DB-tails the conversation (poll interval ~2s); there is no cross-container push signal by design (the shared database is the source of truth across the split multi-container deployment). The subscriber's open connection is its presence — a dropped connection ages out of the roster within ~12s. A dropped or reloaded connection does not release the driver seat: the lock is a user-keyed lease (~15s), so a driver who reloads reconnects as the driver. A reconnecting stream only renews a still-live own lease; it never reclaims a lapsed or taken seat (use POST …/live/driver). The seat is released immediately only when the stream finds the caller's read access revoked. Drive permission is re-checked on every renewal: a member demoted to viewer mid-stream stops renewing and the lease lapses within ~15s; a transient project-read fault skips that renewal without ending the stream. Message delivery is message-level (a committed message appears within one poll); token-level streaming to watchers is not part of Phase 1.

Each connection re-seeds its message-tail cursor from the current maximum message on hello (it streams only messages committed after connect). Clients therefore reconcile on every (re)connect: a watcher whose stream drops (laptop sleep, network blip) and reconnects re-loads the conversation via the normal GET, so no message committed during the gap is lost. A watcher who is already viewing an inactive conversation re-polls the snapshot while no session is live, so it observes the owner starting a session without a manual reload. When the owner leaves (tab close / network drop) the session stays active until an explicit stop or the 30-minute cap, but the owner ages out of the roster; watchers surface an honest "owner away / paused" state rather than sitting on a stale "no one is driving" until the cap.

Driver (write) token

POST /admin/v1/conversations/<ID>/live/driver — request the turn. can_drive-gated (a viewer-role member receives 403 { "error": "forbidden" }). 200 { acquired: true } on success; 409 { acquired: false, driver_user_id } when another participant holds a live lease; 409 { "error": "no active session" } when no session is active.

DELETE /admin/v1/conversations/<ID>/live/driver — release the turn (only the current holder has effect; a stale caller is a harmless no-op → 200 { "released": true }).

Writing while a session is live

When a session is active, an inference turn on the conversation (/v1 chat path) and an appended message (POST /admin/v1/conversations/<ID>/messages) are rejected for anyone who is not the current driver — error code live_not_driver (403). A transient failure to resolve the session state also blocks the write (fail-closed). Content shown in the room is the stored conversation content already visible to project members via the conversation read path — the live room adds no new content exposure and honors the same PII masking and retention as the persisted conversation.

Accepted / rejected input: the conversation id and driver token are resolved server-side against the caller's session and project membership; a forged or borrowed id resolves to 404/403. A non-owner cannot start or stop a session; a viewer-role member cannot acquire the driver; a non-driver cannot write.


Submitting and reading conversation feedback

PUT /admin/v1/conversations/<ID>/feedback — submit a 1–5 rating (5 = best, 1 = worst) with an optional comment. The accepted and rejected input, the error codes and the response are specified once, in Feedback — conversation rating.

GET /admin/v1/conversations/<ID>/feedback — read the submitted feedback. 200 with the feedback object, or 200 null when the conversation has not been rated; 404 when the conversation does not exist. A failed read of the feedback answers 503 { "error": "temporarily unavailable; retry later" } — never the 200 null "not rated" answer.


Listing all chat feedback (admin)

GET /admin/v1/feedback

Required permission: FEEDBACK_TRIAGE (a platform-admin permission).

Optional query parameters: processed (true or false; any other value means no filter), project_id, and limit (default 100, capped at 500; anything but a plain integer ≥ 1 is 400 {"code": "invalid_limit"}). Each entry carries the fields listed in Feedback — listing, including client_context (object or null).

PATCH /admin/v1/feedback/<ID> — mark a feedback entry as processed (no request body is read). Returns 200 { "ok": true }. Required permission: FEEDBACK_TRIAGE (a platform-admin permission).


Conversation summaries

Stored text is the model's text. Assistant messages, share snapshots and summaries no longer carry the gateway's "[In this reply you …]" / "[System note: this reply produced …]" notes about produced outputs: migration 0454 removed them from existing rows, and the gateway tells the model about earlier outputs in the system prompt instead (Conversation record).

GET /admin/v1/conversations/<ID>/summaries — list stored summaries. Readable by anyone who can view the conversation — the owner or a member of the project it is shared into (the same read access as GET /admin/v1/conversations/<ID>). Returns 404 not_found only when the conversation truly does not exist or the caller cannot see it, never a misleading 404 for a transient fault: a database error on the access check or reading the summaries list itself returns 503 { "error": "temporarily unavailable; retry later" } (retryable). Both fail closed rather than mislabelling an outage as not-found.

POST /admin/v1/conversations/<ID>/summaries — store a new summary entry. Owner only: an unknown conversation, or one the caller does not own, returns 404 { "error": "not_found", "code": "not_found" }; a failed lookup returns the retryable 503. On success: 201 with the stored summary row.

Accepted / rejected input: summary_text (up to 65535 bytes), first_message_id and last_message_id (up to 36 characters each) are required and must be non-empty strings. A missing field or an empty string, a wrong type (null, a number, a boolean, an object/array), or a value longer than its limit is refused with 400 before anything is written, and the code tells the three cases apart: an absent or empty value answers summary_text_required / first_message_id_required / last_message_id_required; a wrong type answers invalid_summary_text / invalid_first_message_id / invalid_last_message_id; an over-long value answers summary_text_too_long (over 65535 bytes) / first_message_id_too_long / last_message_id_too_long. first_message_id is checked before last_message_id; the error sentence names both ids. The two optional fields are coerced rather than rejected: message_count becomes a whole number in range (a non-numeric value, a negative, or one beyond the column's range becomes 0; a fraction is truncated; a NaN / Infinity / 1e999 literal is refused by the body parser, 400 malformed_body) and model_used becomes a string truncated to 128 characters (anything that is not a string becomes empty).

supersedes_ids is optional and, when present, must be an array of non-empty strings (an empty array is legal — it asserts "no active summaries"); anything else is refused with 400 invalid_supersedes_ids. Supplying it turns on the concurrent-write check: a stale view is answered with 409 conflict_supersedes_stale instead of silently superseding a summary another client wrote a moment earlier. Omitting it keeps the previous behaviour, in which this route supersedes every active summary unconditionally — prefer to send it.

The write is one database transaction that the gateway re-runs on a transient conflict (a deadlock with a concurrent summarisation). If every bounded attempt conflicts — or a row lock could not be obtained in time (not re-waited) — nothing is written and the route answers 503 (temporarily unavailable; retry later) — safe to retry. Any other database failure is the sanitised 500 { "error": "internal error", "request_id": "…" } (no code) and never carries the database's own error text.

POST /admin/v1/conversations/<ID>/summarize — request the gateway to produce a summary now. Owner only: an unknown or not-owned conversation returns 404 not_found; a failed lookup returns the retryable 503. The summary call resolves its target provider and model through the same authority as a normal inference dispatch: gateway-aware provider inference, then the gateway's routing rules (the inferred provider is seeded into rule evaluation, and rules are evaluated on the bare model), then the gateway's Azure OpenAI / Hugging Face endpoint (azure_endpoint, hf_endpoint — dialled through the same SSRF guard as inference). Per-gateway provider_base_urls overrides are applied to the summary call, exactly as for an inference turn (the override swaps the host, the provider's own path is kept, and the dial goes through the same SSRF guard: resolved once, pinned, private/internal addresses refused with 502; a malformed stored override is 502 configuration_error, never a silent fallback to the default host). Only the gateway's own key is ever sent to an override: Myra's key is never sent to a tenant-controlled endpoint (a Myra-keyed summary on a gateway with an override for that provider is refused rather than dialled, 500 configuration_error). A summary is therefore generated by the provider and model an inference turn on the same gateway and model would use — a routing rule that remaps the provider or model applies here too. The summary uses the same single key rule as inference: a self-serve gateway is served by Myra's key for Anthropic (the wallet is charged as Myra-keyed), a manual gateway by its own key; a summary on Myra's key for a model without a billable price is refused rather than dialled (500 configuration_error, "Managed model is not billable"). A summary against a provider whose per-request key is unavailable returns 422; a platform without a shared key configured at all is a 500 configuration_error, a configured shared key that cannot be found a 503 provider_quota_exhausted, a wallet or model price that cannot be read a 503 spend_unverified, and a failed read of the gateway's own key the retryable 503. A provider/upstream failure is surfaced with the provider's own error shape (never a bare 500).

The summary refuses exactly where a chat turn on the same gateway and model would, with the same error code: on a Tier-1 (local-only) project it answers 403 model_not_allowed_for_project for a non-local provider, and on a gateway with EU data residency enforced it answers 403 data_residency_blocked for a non-EU provider, both before any key is read or any byte is sent. A conversation whose project no longer exists answers the permanent 403 conversation_project_unresolved, and an undeterminable project tier the retryable 503 project_tier_unresolved, as for a chat turn. When several refusals apply, the order is: a model-pin refusal that precedes routing, then the Tier-1 refusal, then 409 model_pin_conflict, then any other block (such as the residency refusal).

Typed refusals of the summary call: 422 provider_key_unavailable (no API key for the gateway's provider), 422 provider_unsupported (the provider has no direct or streaming summarization call), 502 upstream_error (the provider call failed; the provider's detail is never echoed) and 500 invalid_gateway_config (formerly gateway_config_invalid; provider resolution returned no provider or model for the gateway). A stored gateway configuration that cannot be decoded is not invalid_gateway_config: it answers the retryable 503 ("temporarily unavailable; retry later") when the read itself failed, and otherwise a sanitised 500 { "error": "internal error", "request_id" } without a code. An unknown gateway answers 404 not_found.

The conversation's access tier and the privacy filters apply here too. A summary is generated from the conversation's own text, so it is treated as an outbound request like any other turn — this was not always true, and the gap is worth stating plainly because it was invisible: compaction runs automatically after every turn and can carry tens of thousands of tokens of verbatim conversation per call.

  • A Local only (Tier-1) project's conversation is never summarised by a non-local model. The attempt is refused with 403 model_not_allowed_for_project before anything is sent. In practice this changes nothing for a working conversation: such a project's ordinary turns are already restricted to local models, so the summary uses one too.
  • …and the summary must have been produced inside Myra's infrastructure. The gateway checks the server Myra's fleet reports for the reply (the same check as for a chat turn — see local_only_egress_blocked) before anything is streamed or stored; a summary that cannot be confirmed is refused with 403 local_only_egress_blocked (as an error frame when the stream had already started, i.e. on the truncation retry) and nothing is stored. The same post-reply check now also applies the gateway's EU-residency / provider-allowlist / subprocessor- objection rules to the host that served the summary (403 data_residency_blocked / provider_not_allowed / provider_objected); the summary call has no failover, so such a refusal is final for that call.
  • If the conversation's project binding cannot be confirmed, the summary is refused with a retryable 503 project_tier_unresolved rather than being sent unrestricted — and deliberately not with the permanent "only local models" message, which would be untrue for a project that may not be restricted at all.
  • The gateway's request-phase privacy filters run on the summary text. Personal data is masked before the text reaches the provider and restored afterwards, so the stored summary reads normally while the provider only ever saw the masked form. A scrub-style filter, which replaces a match with a fixed placeholder rather than a reversible token, is irreversible by design: the placeholder stays in the stored summary, because the model never saw anything else.
  • If the project mandates PII protection and the gateway has no filter configured, the summary is refused (403 gateway_not_allowed_for_project) rather than sent unprotected.
  • If a filter is temporarily unavailable and the gateway is set to refuse rather than skip it, the summary is refused with a retryable 503 guardrail_unavailable — distinct from a content block, because nothing about the content was wrong.
  • If a content filter blocks the text outright, the summary is refused with 400 guardrail_blocked, the same verdict the equivalent chat turn would get.

The stored summary matters more than a single request: it replaces the messages it covers and is sent as context on every later turn, so it is the conversation's only remaining record of that history.

Accepted / rejected input. The request body is validated at the trust boundary before any provider call, key fetch or database write. Every shape rejection below is a 400 with an explanatory error, never a 500 (authorization is separate: a gateway_id outside the caller's tenant is 403, an unknown one 404, and a database fault while resolving it 503):

Field Accepted Rejected
gateway_id non-empty string, and must belong to the caller's tenant missing or null (400 gateway_id_required); an empty string, number, boolean, object/array, a string longer than 36 bytes, invalid UTF-8, or one containing a control, line-break or invisible formatting character (400 gateway_id_invalid). These last three classes were answered 403 / 404 by the gateway lookup before; they are now refused up front with the 400.
model non-empty string (a provider prefix such as openai/ is stripped); stored truncated to 128 characters missing or empty string (400 model_required); null, number, boolean, object/array (400 invalid_model_id)
messages a non-empty array of objects (still required for back-compatibility) — but its content is no longer used: the text summarized is read from the stored transcript span (see below) missing (400 messages_required); null, number, string, boolean, [], or any entry that is not an object (all 400 invalid_messages)
first_message_id, last_message_id non-empty strings, at most 36 characters each, and must both resolve to messages in this conversation, in order missing or empty string (400 first_message_id_required / last_message_id_required); null, number, boolean, object/array (400 invalid_first_message_id / invalid_last_message_id); longer than 36 characters (400 first_message_id_too_long / last_message_id_too_long); an id not present in the conversation (404 span_not_found); first positioned after last (400 span_inverted)
supersedes_ids absent, or an array of non-empty strings (an empty array is legal — it asserts "no active summaries") a value with any non-sequential key (an object with keys, a sparse or mixed table), or any element that is not a non-empty string (including NaN, numbers, null, objects, ""); all 400 invalid_supersedes_ids. An empty JSON object {} is indistinguishable from [] here and is treated as an empty array
target_tokens any number; clamped to [100, 8000] — (a non-numeric value or null falls back to the default; a NaN / Infinity / 1e999 literal is refused by the body parser, 400 malformed_body)
previous_summary string — (any other type is treated as absent)

Because a stored summary supersedes the history it covers, these are fail-closed rejections rather than best-effort coercions: a body the gateway cannot interpret exactly must not produce a summary that silently omits part of the conversation.

The summarized text is read from the stored transcript, not from the request. The gateway resolves first_message_id..last_message_id to a contiguous span of the stored conversation and summarizes that — the messages array in the body is accepted for backward compatibility but its content is ignored. This removes an unbounded, untrusted input: the request body can no longer decide what text is sent to the provider. (A message whose stored content is not text is refused with 400 invalid_span_content (formerly span_content_invalid).)

The request is bounded, rate-limited and metered — before any provider call, key fetch, or privacy scan:

  • Size ceiling (413 corpus_too_large). The assembled corpus (the resolved transcript span plus any previous_summary) is refused if it exceeds either an absolute raw-byte cap (a worker-protection bound, independent of the model) or the resolved model's context window. This is a byte ceiling, not a message-count limit — a 500-message conversation whose text fits the window still summarizes.
  • Per-user rate limit (429 rate_limited, with Retry-After). Each user's summarize requests are charged in token-equivalents against a per-minute budget; a tight loop is throttled after a handful of full-size compactions while ordinary automatic compaction is unaffected.
  • Budget enforcement (429 quota_exceeded / 429 team_budget_exceeded, with Retry-After). A tenant or gateway at its budget_usd limit is refused before the provider is called — the route re-runs the same spend predicates the /v1 path uses: the workspace wallet must not be frozen or empty, then the workspace's own monthly spend cap, the gateway's budget_usd, the per-user budget and the caller's department (team) budget are checked. A team that is over its cap or frozen answers 429 team_budget_exceeded; a department binding that is malformed or points to a missing department answers 500 configuration_error; a caller who no longer exists answers 401 unauthorized. A free trial is bounded the same way (by the wallet and these caps). A spend read that fails for the workspace cap, the gateway cap or the per-user budget does not block (the request proceeds and is metered at the end); an unreadable wallet balance does (below). A partner-billed workspace is the exception: an unreadable workspace, gateway, per-user or team spend is refused with the retryable 503 spend_unverified (see Pool, fleet and summarize side calls).
  • Unreadable wallet (503 spend_unverified, retryable). If the workspace wallet's balance cannot be read (a database fault), the summarize is refused — never run on an unknown balance — with the same retryable 503 spend_unverified /v1 answers (not 429 quota_exceeded: nothing is used up). An unreadable department (team) binding is refused the same way.
  • Prepaid-wallet reservation (402 wallet_insufficient / 429 wallet_funds_reserved). On a self-serve workspace, each summary call — and its one automatic retry — first reserves its full maximum cost from the wallet's free balance, priced from the prompt that is actually sent (including previous_summary), exactly as every /v1 model call does (see Budgets — Wallet). It is all or nothing — a summary is never shortened (a retry whose reservation is refused is simply not made): when the free balance cannot pay the first call the request is refused before the provider is called and nothing is dialled — 402 wallet_insufficient (no Retry-After; on a free trial 402 trial_budget_exhausted, with the wallet top-up not offered 429 quota_exceeded), or 429 wallet_funds_reserved when the balance would pay but other running requests hold it (try again shortly). A request the wallet carried past the allowance whose reservation cannot be placed (the ledger is unreachable) answers 503 spend_unverified on every plan — it never runs unreserved on the prepaid balance.
  • Real cost. A successful summarize records its actual cost_usd (priced from the provider's reported usage) in request_log and debits the same wallet/quota scopes an inference turn does (settling its reservation; the unused part returns to the free balance). A provider call that returned no usable output (an empty completion, or a response that could not be parsed) is not billed — that cost is absorbed rather than charged as an estimate.

Because the summary is a real provider dispatch, it enforces the same fail-closed data-residency and provider-allowlist gates as an inference request, evaluated against the gateway's inheritance-folded configuration (the tenant-level EU-residency / allowlist floor applies even when the gateway itself does not set the flag). If the gateway requires EU model hosting and the model resolves to a non-EU-hosted provider, the request is refused with 403 data_residency_blocked; if the gateway enforces a provider allowlist and the model resolves to a provider not on the approved list, it is refused with 403 provider_not_allowed. Both gates run before any provider key is fetched or decrypted, so a blocked provider never touches a stored credential. If the provider the summary would dispatch to cannot be resolved because a read failed (the model catalogue, the gateway's routing rules or its provider opt-in set), the request answers 503 { "error": "temporarily unavailable; retry later" } — nothing is dispatched or written.

Streaming variant (Accept: text/event-stream)

By default summarize returns the finished summary as a buffered 201 JSON row. When the request carries Accept: text/event-stream, the gateway instead streams the summary as it is produced (Server-Sent Events), so a long compaction shows live progress instead of blocking. All of the gates above (residency, provider-allowlist, key availability) still run before the stream is opened — a blocked or misconfigured provider is returned as the same JSON error (403 / 422 / 404) with no stream opened, exactly like the buffered path. Absent the header, the buffered 201 is returned unchanged (old clients are unaffected).

Each event is a data: line whose JSON payload carries a type:

  • {"type":"delta","text":"…"} — an incremental fragment of the summary text.
  • {"type":"retry","reason":"stream_truncated"} — non-terminal: the gateway discarded the attempt streamed so far (see One automatic retry below) and is re-running the summarize call. Every delta sent before this frame is dead text; a client that reconstructs the summary from delta fragments MUST discard what it has accumulated and start again from the next delta. Only done.row is authoritative.
  • {"type":"done","row":{…}} — terminal success; row is the stored conversation_summary (same shape as the buffered 201 body).
  • {"type":"error","code":"…","message":"…"} — terminal failure. code is one of stream_incomplete (the upstream stream ended before a completion marker — e.g. a mid-stream reset), empty_summary (the model produced no content), sse_line_overflow (a single upstream line exceeded the 1 MiB cap), stream_error (an upstream read error), stream_truncated (the model hit an output cap and the summary was cut off mid-sentence), content_filtered (the model refused to summarise the segment), stream_aborted (the provider ended the stream on a terminal that is not a clean finish — e.g. a mid-stream provider error (an Anthropic error event or an OpenAI-shaped data: {"error":{…}} frame — neither is retried, the summary is not stored), or a reason the gateway does not recognise), summary_too_long (the summary exceeded the 65535-byte stored limit), conflict_supersedes_stale (a concurrent compaction won the supersede race — the client refetches /summaries and continues, not a hard failure), db_busy (the summary write hit a transient database conflict on every bounded attempt — nothing was stored; retrying the compaction is safe), or db_error.

The buffered variant returns the four terminal-reason codes — stream_truncated, content_filtered, stream_aborted, summary_too_long — as 502 {"error":"…","code":"…"}, so a failed compaction is classified identically in both shapes. Four buffered terminals differ by design: empty_summary is a 502 {"error":"…","code":"empty_summary"} (the same code as the streaming frame; a model response the gateway cannot parse is 502 { "error": "summarization response parse error", "code": "summary_parse_failed" }, with no parser detail), conflict_supersedes_stale is a 409 with the top-level code next to the nested {"error":{"code","message"}}, a transient database conflict (nothing stored, safe to retry) is the plain retry 503 { "error": "temporarily unavailable; retry later" } (no code), and any other storage failure is the sanitised 500 { "error": "internal error", "request_id": "…" } (no code). The three transport codes (stream_incomplete, stream_error, sse_line_overflow) exist only on the streaming variant.

Endpoint-configuration failures (both variants, before any upstream call): when the gateway's stored Azure / Hugging Face endpoint configuration is malformed (the provider cannot build a URL from it), or a tenant-configured azure_endpoint / hf_endpoint resolves to a private or internal address (the same SSRF guard inference applies), the call answers 502 {"error":"…","code":"configuration_error"} and nothing is sent upstream. A provider with no direct-call support at all still answers 422.

When a summary is stored

A stored summary supersedes every earlier summary for the conversation, and the client then sends only that summary plus the messages after its cut — so storing an incomplete one silently destroys the history behind it. The row is therefore persisted only when all of the following hold:

  1. the upstream stream reached a completion marker and no read error occurred (streaming variant only — a mid-stream reset looks like an ordinary end of body);
  2. the provider reported a clean terminal — an allowlist, not a denylist: stop, end_turn, pause_turn, tool_calls/tool_use, stop_sequence, or no terminal at all. A length cap (length / max_tokens), a content filter, a provider error event, and any unrecognised reason are all refused;
  3. the resulting text is non-empty after trimming;
  4. the text is at most 65535 bytes (the storage limit).

Anything else stores nothing and reports the matching code above; the conversation's existing summaries and full history are left exactly as they were, so the client shows a "could not compact" notice and retries later rather than losing context.

Drop a span from the assistant's context

POST /admin/v1/conversations/<ID>/context-drop — body { "first_message_id": "<ID>", "last_message_id": "<ID>" }.

Some spans can never be summarised: the model truncates every attempt, refuses the content, or produces more than the storage limit. Because the summary chain always starts at the oldest un-summarised message, one such span stops compaction for the whole conversation — the history then grows until the request hits the model's context limit. This route is the user's way out: it drops that span from what the assistant is SENT, without deleting anything.

Nothing is deleted. The messages stay in the conversation and stay visible; they simply stop being included in future requests, and the stored summary gains a server-authored note telling the model that a gap exists, so it cannot invent what was there.

The client names a span and nothing else. The stored summary text, the message counts and the note are all composed server-side — a caller cannot write summary text through this route (unlike POST /summaries, which exists for a client-authored summary and is kept separate for exactly that reason). supersedes_ids is likewise derived server-side from the same read used to compose the text, so the concurrent-write check cannot be disarmed by omitting it.

Input Rejected when Status
<ID> (conversation) not owned by the caller, or unknown 404
<ID> (conversation) the lookup itself failed (DB fault) 503 — retryable, never reported as "gone"
<ID> (conversation) the conversation has no messages 409 empty_conversation
first_message_id, last_message_id absent or empty / not a string / over 36 characters 400 first_message_id_required / invalid_first_message_id / first_message_id_too_long (and the last_ forms)
the span either id is not a message of THIS conversation 404 span_not_found
the span first_message_id comes after last_message_id 400 span_inverted
the span last_message_id is the newest message (would drop the entire conversation) 409 span_too_recent
the span it lies at or behind the active summary's cut (already summarised) 409 span_behind_cut
the composed summary would exceed 65535 bytes 409 summary_too_long
— a concurrent summarisation moved the active set 409 conflict_supersedes_stale — refetch /summaries and retry
— the write hit a database deadlock on every bounded server-side attempt, or a row lock could not be obtained in time (not re-waited); nothing was written 503 — retry the same request

On success: 201 with the new summary row. It supersedes the active summaries, keeps their text verbatim (the real memory is never discarded to make room for the note), records model_used: "context-drop" — no model produced it — and carries dropped_message_count, which accumulates across drops.

dropped_message_count is the durable record of the gap. The note itself cannot live in the summary text alone: every later compaction sends the current summary back to the model as previous_summary with an instruction to fold it into the new one, so an LLM would decide each pass whether the note survived. The gateway therefore re-renders the sentence from this counter after every summary write (stripping any copy the model echoed back), which is also what lets the UI say "N earlier messages are no longer available to the assistant" instead of claiming they were summarised.

Output-cap clamp

The first provider call's max_tokens (derived from target_tokens) is clamped to the model's own output ceiling before the request is sent — the value the catalog records for that model, or, for a self-hosted model, whatever leaves room for the prompt within the context window. Without the clamp an over-target request could ask for more output tokens than the provider's model allows, which a provider such as OpenAI rejects outright (a failure before any content), so the conversation would never compact. The retry below omits max_tokens entirely, so the clamp applies to the first attempt only.

One automatic retry on truncation

A cut-off summary is usually caused by the gateway's own output cap (max_tokens, derived from target_tokens), so stream_truncated on the first provider call triggers exactly one retry — the same request with max_tokens omitted entirely, so the model may use its full output budget. At most two provider calls are made per request; a second truncation is reported, never retried again. Both attempts are recorded in request_log (see below) and are distinguished by meta.attempt (1 or 2).

The retry covers Claude too: the gateway fills an omitted max_tokens with the model's real output ceiling before the request leaves the gateway, so a retry that drops the field still reaches Anthropic with a valid, full-budget value rather than its native max_tokens: Field required rejection.

The retry is skipped — and the failure reported immediately — when it could not help: when the client has already disconnected (streaming variant only, and only once the attempt has emitted visible text — the buffered variant cannot observe a departed client at all), or when the resolved provider substitutes a smaller default of its own so a no-cap retry would ask for less and truncate again (currently bedrock).

Upstream SSE bytes are treated as untrusted throughout: over-long lines are rejected (sse_line_overflow), a malformed frame is skipped rather than aborting the stream, and the terminal reason is validated against the clean-finish allowlist before it can allow a write (a non-string terminal such as JSON null is treated as "no terminal reported").

Provider coverage. The terminal-reason gate can only act on a reason the provider actually reports. The OpenAI-compatible family (including self-hosted models) and Anthropic report one; Gemini, Vertex, Cohere, and Bedrock currently do not, so a truncated summary from those providers is still treated as clean.

Logging (meta.kind = "compaction")

Every summarize call — buffered and streaming, success and failure — is now recorded in request_log via the same emitter the inference dispatch path uses, so compaction latency, token counts, and provider status are queryable. These rows are identified by meta.kind = "compaction" (with the conversation id under meta.conversation_id and the pre-compaction estimated input tokens under meta.tokens_before); they do not set the compaction_triggered / compaction_tokens_* columns, which remain reserved for a provider's native in-turn compaction. A logging failure never fails the summary.

A summary a Local only project refuses is recorded as a blocked request, exactly like the same refusal of a chat turn (request log blocked, the compliance report, a gateway's blocked webhook, your SIEM as POLICY_BLOCK): blocked_by local_model_required when the summary would use a non-local model (nothing is sent; one entry with no tokens or cost), and local_only_egress when the summary could not be kept inside Myra infrastructure (block_reason tenant_endpoint or fleet_not_in_estate: refused before anything is sent, one entry with no tokens or cost; not_in_estate: the reply was withheld and the attempt's own entry is marked). block_reason carries the same values as for a chat turn (see SIEM). A summary refused for another reason (EU residency, allowlist, objection) is not marked as blocked.


Viewers cannot spend credit or reshape a conversation

A user with the viewer role may read their own chat and do owner-housekeeping on it, but may not spend inference credit or reshape a conversation's content/context. Every route in the first category below is refused with a typed 403 { "error": <prose>, "code": "viewer_read_only" } on the admin session plane; the routes in the second category stay open. This is not a blanket "read-only" — a viewer can still rename, delete, rate and detach their own data (none of which spend credit or change what the model sees). The check runs before any conversation lookup or body validation, so a viewer is refused identically for a real and a non-existent id (no existence oracle), and the app disables the composer and hides the per-message mutate affordances for a viewer as a matter of UX — the server, not the client, is the boundary. (The viewer role is separately barred from all /v1 inference — see Inference is refused for viewers; this admin-plane gate closes the second door, the chat writes that reach a model through the session cookie.)

Gated (a viewer is refused viewer_read_only) — spends inference credit OR reshapes content/context:

Route Why it is refused
POST /admin/v1/conversations creates a conversation (a fresh chat, or a share-continue)
POST /admin/v1/conversations/<ID>/fork creates a conversation ("Continue in new chat")
POST /admin/v1/conversations/<CID>/messages appends a message and triggers inference
PATCH /admin/v1/conversations/<CID>/messages/<MID> edits a message or sets the display-only corrected_content overlay — no carve-out; a viewer writes nothing
DELETE /admin/v1/conversations/<CID>/messages/<MID> trims a message (regenerate)
POST /admin/v1/conversations/<CID>/attachments uploads a file, which runs image-analysis inference on an image
POST /admin/v1/conversations/<CID>/summarize makes a real provider call (inference credit) to compact the thread — fired automatically by the app on open
POST /admin/v1/conversations/<CID>/summaries persists a summary that supersedes memory (changes what the model sees on every later turn)
POST /admin/v1/conversations/<CID>/context-drop drops a message span from the model's context and writes a server-composed summary — a context reshape
PUT /admin/v1/conversations/<CID>/knowledge/<KID> rewrites a conversation artifact's extracted_text, which is re-sent to the model as knowledge
POST /admin/v1/chat/files uploads a chat file, which runs qwen OCR and a provider Files-API upload (inference credit)
POST /admin/v1/conversations/<CID>/videos/<VID>/cancel cancels a video generation job (a write on the conversation)
POST /admin/v1/chat/convert-html converts HTML or a conversation file into a new document for the conversation (see HTML conversion)
POST /admin/v1/chat/transcribe speech-to-text: a real provider (Whisper) inference call on the fleet from raw audio (inference credit)

Allowed (reads + owner-housekeeping — no chat inference, no context reshape): listing and searching conversations, getting a conversation, reading messages and generated files/images (GET/list/search); renaming a conversation (PATCH /admin/v1/conversations/<ID>); deleting a conversation (DELETE /admin/v1/conversations/<ID>); rating it (PUT /admin/v1/conversations/<ID>/feedback); Caveat: on a tenant with a semantic-cache embedding endpoint, search and rename currently trigger a small embedding call (a cheap provider cost, with a local keyword fallback when no endpoint is configured) — these are allowed to a viewer today; skipping the embedding for viewers is tracked as a follow-up. They do not run chat inference or reshape a conversation's content. deleting an attachment (DELETE /admin/v1/attachments/<AID>); minting and reading a public share link; and conversation comments. Read-aloud (text-to-speech) is also intentionally allowed (passive accessibility) — see Text-to-speech. A pure viewer never owns a conversation (they can no longer create or fork one), so the owner-scoped housekeeping routes are unreachable to them in practice; they stay ungated because the policy is content/credit, not a blanket write ban, and a member later downgraded to viewer must still tidy their own history.

Messages

POST /admin/v1/conversations/<CID>/messages — append a message and trigger inference.

Body validation. Every body check runs before the ownership/write gate, so the 400 depends on the body alone and a rejected request writes nothing. role must be user or assistant (invalid_role); content valid text within the size limit (invalid_content; "" stays accepted); optional model (invalid_model_id), curator_task (invalid_curator_task), parent_message_id (invalid_parent_message_id), gateway_id (gateway_id_invalid) and request_id (invalid_request_id) are validated when present. Absent or null optionals are stored as NULL. A model longer than 128 bytes is stored on the message but does not update the conversation's model. role and content are required; a body without either is 400 { "error": "role and content are required" }.

content is stored as given. When it is read back (bubble, edit, export, model history), a JSON array counts as content blocks only when every element has the exact shape the app writes:

  • text with a string text;
  • image_url with {"url": "data:…"} (the data: prefix in any letter case);
  • image with a string filename, a text that is a string or absent, and no source;
  • docx / md / pdf with a string filename and a text that is a string or absent;
  • document with a base64 source carrying string data (or the retired Files-API file source).

Any other array is read as plain text and shown, edited and sent to the model as that literal JSON, never as an image or document. That includes a pasted OpenAI or Anthropic content array with a remote image or a URL document, an unknown type, or a null / untyped element. This applies to messages stored earlier too. A pasted array that happens to match these shapes exactly still reads as blocks: a text-only array, or one whose images are all inline data: URLs.

Continue control turns (control)

The Continue button resumes a stopped answer with a fixed instruction. That instruction is stored as a control turn: a user message whose control is "continue". Clients show a marker instead of its text. The instruction text is owned by the server; no client keeps a copy.

GET /admin/v1/chat/control-turns/continue?lang=en|de returns { "kind": "continue", "content": "…" }. lang defaults to en; any other value is 400 invalid_lang.

POST /admin/v1/conversations/<CID>/messages accepts an optional control field:

  • absent: an ordinary message;
  • exactly "continue": the message is stored as a control turn. The request must be a plain user message, and content must equal one of the server's instruction texts (the current or an earlier wording);
  • anything else that is present (null, "", "Continue", a number, an object) is 400 invalid_control, never read as absent. A control on a non-user message, or on a message that carries an image, is 400 invalid_control. A content that is not the instruction text is 400 invalid_control_content.

Reading messages returns control: "continue" on a control turn and omits the field on every other message. The public share snapshot (GET /share/<TOKEN>), the share-continue import, forks and the user data export carry the same field. A control turn is not editable: PATCH on one returns 409 control_message_not_editable. It is never used as the conversation title, and the stored instruction is still sent to the model as part of the history.

Empty-answer notices (empty_answer_class)

When a turn ends without a usable answer, the gateway stores a short notice as the assistant message. The notice is written in the conversation language (German or English). Such a message carries empty_answer_class with one of zero_output, blank_turn, reasoning_only, context_exhausted, context_exhausted_first_turn, reasoning_runaway (the gateway stopped a model that kept reasoning without answering) or provider_content_filter (the model provider's content filter stopped the answer before any text was produced); for any other message the field is null. Clients should read this field rather than match the notice text. A value outside this list is treated as no marker.

A provider_content_filter notice is a real, stored answer. When you continue the conversation, the web app leaves this refused turn (the notice and the user message it refused) out of the history it sends to the model, so a single refusal does not block the chat. The stored conversation keeps both messages. A client that builds its own history should do the same.

HTML in rendered Markdown (<br>, alignment)

The app renders Markdown it receives from a model or a file. Only a small, fixed list of raw HTML tags is honoured there; every other tag is shown as typed text. This is the single rule; the chat, project, agent, Playground, Ask-docs and shared-page descriptions link here.

A single line break inside a paragraph (a newline without a blank line) is shown as a line break in the chat, the preview, the rich-text editor and every download (Word, PDF, OpenDocument, text, PowerPoint/Impress) and the Word add-in insert, so an address block or a signature keeps its lines. Known exceptions: in the rich-text editor a list item is a single line and a quote is shown as written, and in some downloads a list item's continuation line, or a list or table directly after a text line, is read differently from the screen.

  • Becomes layout (the complete list of raw tags): <br>, <hr>, <div>, <p>, <center>, <span>, <u>, <ins>, <del>, <sub>, <sup>, <small>, <kbd>, <mark>, <details>, <summary>, <b>, <i>, <s>, <em> and <strong>. Line breaks may be written <br>, <br/>, <br />, as an escaped \<br> or as the entity spelling &lt;br&gt; (any letter case; in running text and inside table cells, so a model can put several lines in one cell). The entity spelling is not a break inside an HTML block (a <div> on its own line, for example); there it shows as the text <br>. The only attribute honoured is align="left|right|center|justify" on div, p, td and th (exact lowercase values only; a malformed value is dropped, the block stays unaligned). Everything Markdown itself produces is unaffected (headings, lists, quotes, code, tables, links, images, task-list checkboxes as disabled boxes, footnotes). A tag is honoured only when it is balanced (it has its end tag in the same block of text; <br> and <hr> need none); an unclosed tag, a stray end tag and an unfinished tag are shown as typed text and never swallow the text after them. A tag with more than 64 attributes is shown as typed text, together with the tag that closes (or opens) it; other tags in the message keep their formatting. <details> is always shown closed. A block tag (<div>, <p>, <center>, <details>, <summary>, <hr>) written inside a Markdown paragraph ends that paragraph; its text stays, in order. Nesting is capped at 64 levels, measured on the parsed document (not on the tags as written): an element nested deeper loses its tag and its text stays. Markdown's own nesting (quotes, lists) counts the same way. Curated pages (release notes, the data-processing agreement) never use the HTML subset; a literal <Tag> there stays visible.
  • Where it applies: assistant replies, the Markdown artifact preview, the project file preview (.md), the shared-page assistant turns, the Ask-docs assistant, an agent run's Result, and the Playground. Your own (user) messages are always shown as typed, including on a shared page. The Word add-in honours only <br> and the align of a whole <div>/<p>/<center> block from this list; everything else is typed (see Direct document AI). The downloads Word (docx), PDF, OpenDocument Text (odt), plain text (txt), PowerPoint (pptx) and OpenDocument Presentation (odp) apply the same list and the same sanitising: the tags become layout (a right-aligned date line stays right-aligned, <br><br> is two line breaks) instead of being printed as text, and every other tag, attribute and script stays inert text. Known differences in those downloads: <small>, <kbd> and <mark> have no styling in Word and OpenDocument; <details> and <summary> are shown open as plain paragraphs; a block tag written inside a paragraph keeps its text but not its alignment, and an <hr> inside a paragraph or list item is left out (no rule is drawn); an aligned block inside a footnote keeps its text but not its alignment; inside an HTML block only a fixed set of character references is decoded. A tag whose end tag is in a different block of text (for example <span>a, a blank line, then b</span>) is shown as typed in the downloads, and a footnote or reference-link definition that lies outside an HTML block is not seen by the text inside it (it is shown as typed). A document whose HTML takes the converter unusually long to read (a hostile or machine-generated text, for example thousands of unfinished tags, a comment that never closes, or a > hidden inside a quoted attribute) is not refused at first: the export reads it with the HTML subset on for a limited time. If that is not enough, it is read again with all raw HTML switched off, so every tag is shown as typed (exactly as downloads looked before the HTML subset existed) and the text itself is never lost. The time kept for that second reading grows with the size of the document, so an ordinary document is never refused because of it; the reading as a whole is capped at 45 of the 60 seconds of the download, which leaves 15 seconds for writing the file. If even that does not finish, the download fails with the usual "generation failed" error (HTTP 500) and can be retried with a shorter text. Documents without tags are read in the same time as before, up to the size limit of an export. Reading a document that contains tags takes longer than before because the HTML subset is applied; a very large document (several MB) with tags throughout may therefore be exported with its tags shown as typed, as before, instead of as layout. The spreadsheet downloads (xlsx, ods, csv) read their table cells the same way (see the "Excel, Calc and CSV downloads" bullet below). In the PowerPoint and Impress downloads an aligned block (align="left|right|center|justify") sets the alignment of its paragraphs on the slide, <u>, <ins>, <del>, <s>, <sub>, <sup>, <small>, <kbd> and <mark> keep their text but have no styling, bold text inside a table cell is not styled, a footnote is shown in brackets right after its reference instead of at the foot of the slide, and an <hr> inside a paragraph is left out. Where a slide is read through the same converter as Word and PDF, Markdown that is escaped (\*) no longer prints the backslash, **bold** in a heading or table cell no longer prints the asterisks, a > quote shows the quote's text, a list written with 1) is a numbered list, and control characters that XML cannot carry are dropped. Quotes, list items and footnotes nested deeper than 64 levels are flattened into plain text on the slide, with all of their text kept. Reading a download is limited to 1,792 MB of working memory for every format (Word, PDF, OpenDocument, PowerPoint, Impress, Excel, Calc, CSV), a fixed limit that stays below the memory the converter is allowed to address, so the outcome does not depend on chance: a text nested up to about 5,000 levels deep (nested quotes or footnotes) downloads normally, and a text nested deeper (for example 10,000 nested quotes) is refused every time with the usual "generation failed" error (HTTP 500), in every one of those formats. The Excel, Calc and CSV downloads share the 45-of-60-seconds reading budget (reduced by the time their table-detection step used) and the fallback that shows tags as typed. The rich-text editor applies the same list to a block of raw HTML: a line that starts with a tag or an autolink such as <https://example.com> starts such a block, which runs to the next empty line (for example the right-aligned date <div align="right">…</div> of a letter). The block is shown formatted, as in the preview, instead of as source text. It is read-only and is saved exactly as written; while it is loading it appears as its source text, and if the formatted view cannot be loaded (for example after a network failure) a panel with a reload button is shown in its place. If the block cannot be rendered for any other reason, its source text is shown. Edit it in Source mode. Copying from the editor copies the visible text; Source mode shows the source. A block that contains only an HTML comment is shown as an empty box. Differences to the preview: a line starting with a tag directly after a line of a paragraph ends that paragraph in the editor (the preview keeps it inside the paragraph); a tag opened in one block and closed in another (for example <div align="center">, an empty line, **Title**, an empty line, </div>) is shown as typed in the editor, each block on its own, while the preview wraps the content in the opened tag; and the spacing between blocks can differ slightly.
  • Excel, Calc and CSV downloads: a table cell is read by the same rule as the other downloads, so the cell holds the text it shows on screen, not the markup. <br> becomes a line break inside the cell (a quoted field in CSV), the other tags in the list above are dropped and their text kept, a Markdown link becomes text (address), and every other tag (<script>, <img> ...) stays in the cell as typed text. A cell that begins with =, +, - or @ is never a formula, judged on the final text, so <b>=SUM(A1)</b> cannot become one: CSV prefixes it with an apostrophe, Excel and Calc store it as a text cell. If the reading falls back to all raw HTML off (see above), the tags in the cells are shown as typed. A table whose layout the converter reads differently from the table detection (for example a cell that spans columns) is refused with 500 rather than written with shifted columns. Number and date detection sees the text without the tags. A table-less message is still answered with no_table_found (422).
  • Shown as typed, never parsed: every raw tag that is not in the list above, start and end tag alike, and its text stays visible next to it. That covers <a>, <img>, tables (<table>, <tr>, <td> ...), lists (<ul>, <ol>, <li>), <input>, headings, <blockquote>, <pre>, <code>, <script>, <style>, <iframe>, <svg>, <math>, <form>, <font> and any unknown or custom tag. Nothing in it is run or loaded; write links, images, tables and lists in Markdown instead. A text that mentions a tag (for example "put it in the <select> element") shows that tag as typed and nothing after it is lost.
  • Dropped: HTML comments disappear. Doctypes, processing instructions and <!…> declarations, including CDATA, are dropped up to the first >; any text after that > is shown (<![CDATA[a>b]]> c leaves b]]> c visible). Character references: in an HTML block (a block whose first line starts with a tag, such as <div>) they follow HTML rules (&copy becomes ©, &amp; becomes &). Text between inline tags inside a Markdown paragraph is Markdown text: &copy; works there, &copy stays as typed, as in plain Markdown text, where a reference needs its closing ;. Text such as a lone <, <b or &am inside raw HTML is shown exactly as typed.
  • Attributes: only the ones on the allowlist survive. style, class, id (except footnote anchors), on*, srcset, formaction, target and rel are always removed.
  • Footnotes: footnote links keep resolving (href="#user-content-fn-1"). A footnote labelled 1-2 and the second reference to footnote 1 produce the same anchor id ([^1-2] vs the second use of [^1]); avoid mixing them in one text.
  • Nesting depth: every place that shows Markdown (chat, your own messages, the shared page, the artifact and project preview, Ask-docs, agent results, the Playground) honours at most 64 levels of quotes, list items and footnote definitions, so a pathological text (for example 20,000 > in a row) shows its text instead of breaking the page. The limits are the same on every one of those places: 64 nested bullets give 64 list levels and the 65th marker is shown as text; numbered lists stop at 43 levels and a footnote definition at about 22, because their markers are longer (a marker may not start at column 128 or later). On one line, the first 64 container markers (>, -, *, +, 1., [^a]:) work; the rest of that line is shown as text, and so is a marker that starts at column 128 or later. Structure deeper than 64 levels is flattened into the 64th level, with all of its text kept. Bold, italic, strikethrough and links nested deeper than 64 levels lose their formatting but keep their text. A footnote definition that is too deep shows its text in place and its reference is no longer a link. Raw HTML from the allowed list that is nested more than 64 levels deep, counted together with the quotes and list items around it (a quote, a list item or an HTML element is one level each; the list itself adds none), is shown as typed text instead of being parsed: only that outermost element (the block) is affected, and the rest of the message keeps its HTML when the HTML is properly nested. If tags are interleaved (misnested) so that the HTML parser repairs them into a structure too deep to build, all raw HTML in that message is shown as typed text instead; the message text always stays visible and the page never breaks. In a code block, a line that starts with more than 64 container markers, or whose marker starts at column 128 or later, shows one extra backslash before that marker. The stored text is never changed.
  • Very large or very complex Markdown: before rendering, every place that shows Markdown (the same list as for the nesting depth, and also while a reply is still streaming) estimates how long the text would take to format. Above the limit the whole message is shown as plain text, with its line breaks kept and long lines wrapped, instead of freezing the page; nothing is cut off and nothing is rendered halfway. The estimate looks at the shape of the text, not only its size. Measured with realistic content: ordinary prose with links and code spans stays formatted up to about 200 KB; a single list stays formatted up to about 1 900 items of 80 characters (about 2 400 items of 40 characters); a table up to about 1 400 rows of 120 characters; a single block of short lines without blank lines between them (a quoted or hard-wrapped paragraph) up to about 2 200 lines. A fenced code block gets no special treatment, because the formatter does not always see a fence the way a reader does (inside an HTML block or a comment, for example): ordinary source code stays formatted up to about 1 400 lines, and code that is dense in brackets falls back sooner (about 900 lines of heavily indexed code, about 600 lines of nested array literals). A table that is very wide counts its width times its rows, because every row is expanded to the full width. Lists separated by paragraphs, as in normal documents, are counted per list. The plain-text view is the only raw <div> that may carry a class or data attribute (class="markdown-plain-fallback" data-markdown-fallback="plain"). The exports are not affected.
  • Math formulas: the chat (replies and your own messages) renders $...$, $$...$$ and ```math formulas with KaTeX, within limits. A formula is shown as its TeX source (in code styling, inline or as a block) instead of being rendered when it is longer than 1 000 characters, is nested deeper than 12 levels of braces, environments and font or size switches, or uses \verb, \url, \href, \includegraphics or a macro definition (\def, \newcommand and similar). A formula whose typeset layout would nest too deeply (more than 175 levels of page elements, which a few accent or fraction constructs can reach even within the limits above) is also shown as source. Each message also has a total math budget of 8 000 characters (every formula counts its length plus 20, so a step-by-step answer with 60 formulas of a typical 20 to 60 characters fits with room to spare): the first formulas that fit are rendered and the rest of that message's formulas are shown as TeX source, while the surrounding text renders normally. Ordinary formulas are rendered exactly as before. Sizes written in a formula (\rule, \hspace, \kern) are limited to 20 em. Links and images inside a formula stay disabled. The shared page renders through the light Markdown renderer without KaTeX, so it shows formulas as written. The exports are not affected.
  • Stays literal text: a tag inside inline code or a code block; and all human-authored text (your own messages). In the rich-text editor, an HTML tag inside a paragraph is shown as typed; only a block of raw HTML is shown formatted (see above).
  • Rich-text editor: its formatted table view shows <br> in a table cell as a line break; its other text is editable and stays as typed, and its saved source always keeps the <br> unchanged. A backslash-escaped \<br> counts as a break there in table cells only; in running text the editor shows an escaped \<br> as typed and saves it unchanged, backslash included.

  • Nested lists in the rich-text editor: a list whose item has continuation lines (a nested item, fenced or indented code under an item, or unindented text that continues the item) is shown as a read-only nested list and saved byte-for-byte as written, so an unedited save never rewrites it into escaped paragraphs. A list nested deeper than 16 levels is shown as its source text. A heading, quote, code fence, rule, block-level HTML or an item of the other list kind on the next line still ends the list. Edit it in Source mode; plain lists without continuation lines (and without an empty item written as a bare marker, - or 1.) stay editable. An unedited save keeps each item's bullet marker (-, * or +), the whitespace after it and the numbers of a numbered list (1. 1. 1., 007.) exactly as written; an ordered marker has 1 to 9 digits, a new item you add takes the bullet of the item before it, and a new numbered item takes the next number (or repeats the number when the items around it all repeat the same number); a change of bullet character at the same level starts a new list in the preview and in the read-only nested list, while the editable formatted list shows one list and saves the source exactly as written. A list whose layout the read-only nested list cannot show faithfully (an item whose text starts five or more columns after the marker, or text after an empty line that is no longer part of any item) is shown as its source text and saved exactly as written. If you type text into an item that was empty but had five or more columns of spacing after its marker, the spacing is saved as one space, so the text does not become a code block. A list item indented one to three spaces (- a, 1. a) is a list too: it is shown as a read-only list and saved exactly as written; with four or more spaces it is not a list. After a paragraph, an indented bullet, or an indented numbered item that starts at 1 and has text, starts a list; an indented item with another number, or with no text, stays paragraph text. After a table, an indented item of any number starts the list. An item indented four or more columns past the start of the item above it is text of that item, not a new item.

  • Quotes and tables in the rich-text editor: a quote or table shown in the formatted view is always saved as a Markdown quote or pipe table, never as bare text, including one that reached the editor through a drag and drop (a drop inserts only its plain text, like a paste; a drop with no plain text does nothing; a drop onto a read-only block is placed after it). In a table cell a line break is saved as <br>, | as \|, and a block inside the cell is flattened to text; literal <br> text is saved as the code span `<br>` (shown in code styling) and a code span containing | stays a code span with the | saved as \|; only code text with a backslash directly before a | is saved as plain text without the code styling. A cell whose formatting cannot be saved so that it reads back as the same text (for example text split around a link without a safe address, or bold-italic text) is saved as its plain text, without the formatting.

  • Escapes in the rich-text editor: backslash escapes in link text, a backslash at the end of a line and a heading's escaped closing # (also foo#) are kept exactly as written when you save. A link inside link text is shown as plain text in the editor (the preview follows CommonMark and links the inner one). Rejected or normalised on save: a kept-escape marker that fails validation is saved as an escaped character, and a link whose label cannot be kept intact (unbalanced brackets) is saved as plain text. Outside a table, a line break inside link text is saved as a space. In a table cell it is saved as one link per line ([a](https://example.com)<br>[b](https://example.com)), so every line stays a link; in a cell link address a |, ( or ) is saved percent-encoded (%7C, %28, %29), so the editor and the preview open the same address. Code spans bind tighter than link brackets and bold or italic markers: [a `]`](https://example.com) stays a link and **a `**` b** stays bold, because a bracket or marker inside a code span is just code. A code span keeps the backtick fence you wrote (``a`` is saved as written) and closes only on a run of backticks of the same length. A backtick inside a link address never starts a code span, and the text between ]( and the next ) is treated as a link address even when it is not shown as a link (an unsafe address, for example), so a backtick there is saved escaped. A backslash followed by a space or tab, anywhere in a line, is saved as an escaped backslash (a\ b becomes a\\ b; at the end of a line a\ becomes a\\: the backslash is escaped and the whitespace kept). Spaces or a tab at the end of a line are kept exactly as written when you save (except at the end of a list item that ends in a line break), so a two-space hard line break (a then a new line) and a trailing tab survive an unedited save. Whitespace after a line-end backslash that you typed in the editor is dropped (it is saved as a line-end backslash). A heading's trailing whitespace is dropped, and its trailing # (also after a non-breaking space) is kept by escaping it. A line break inside pasted plain text is saved as a line break with its trailing spaces kept, and a line break inside an inline code span is saved as a space. A link nested inside another link is saved as plain text because Markdown cannot nest links. Two code spans next to each other with nothing between them are saved with ONE space between them (`a` `b`), because without it they would merge into one span; a backtick fence length that does not fit the code text (forged or far longer than the longest backtick run in it) is ignored and the shortest fence that works is used. A link text that holds an unescaped [x](…) pair is saved with its brackets escaped ([a \[b\](https://x.com)](https://example.com)), so it can never turn into a second link. Empty bold and italic markers are saved as written. Two backticks with nothing between them (``) are not a code span: they are saved escaped (\`\`), which reads the same, and an empty code element left by an edit is saved as nothing. Square brackets that were already in the loaded document are saved as they were, with no added backslash, only if the result reads the same as the escaped form and no kept ] is directly followed by (; brackets typed in the editor are saved escaped, and when an edit would form a link ([b](…)) all brackets of that paragraph, list item or heading are saved escaped. A ] directly followed by ( outside a code span is always saved escaped, even if it was not edited (for example [b](javascript:x) is saved as \[b\](javascript:x)), so brackets can never turn into a link on save. The single padding space of a code span (written when the content begins and ends with a space and is not all spaces, as in `` `a` ``) is stripped from the displayed text, as CommonMark does; the editor records it on the <code> node as data-pad="1" and re-writes it on save. Only the exact value 1 is accepted; any other value is ignored and the padding is recomputed from the content. The same holds for the list marker the editor records on each list item as data-mk (the source prefix, kept so an unedited save is byte-exact): it is accepted only in the shape of the list's own type — -, * or + followed by spaces or tabs for a bullet list; 1 to 9 digits, ., then spaces or tabs for a numbered list. Anything else (absent, malformed, or the other list type) is rejected and the item falls back to the canonical marker (- or the next number), and the rejected value is never written into the saved source. A line starting with three or more backticks (indented by at most three spaces) is a fenced code block only when no other backtick follows on that line, as in the preview; when such a line is not a code span, its backticks are saved with a backslash. A line break inside bold or italic text is saved by closing and reopening the markers around it (*a* new line *b*), so the text stays bold/italic. A heading and a list item are a single line: a line break inside one (including the Unicode line and paragraph separators) is saved as a space, so the text stays in the heading or item, and bold or italic across the break is saved as two spans (# *a* *b*). A Unicode line or paragraph separator inside a link address is saved percent-encoded. A line typed after a line break that would read as a horizontal rule (---, ___) or, directly under a paragraph's first line, as a heading underline (==, --) is saved with a backslash before its first character, so it stays text; the same holds for a list item whose text would make the line a rule (- \--). A rule line inside a bulleted list (- a then - --) ends the list and is shown as a rule, as in the preview. A numbered line typed after a line break (2. b) is saved without a backslash unless it is numbered 1 and has text, because only such a line would start a list; a bulleted line typed after a line break (- b) is always saved escaped.

The stored content is never rewritten; the rule applies only when the text is displayed.

Stopping a running turn (POST …/turns/<TURN_ID>/stop)

POST /admin/v1/conversations/<ID>/turns/<TURN_ID>/stop is an explicit, transport-independent Stop. The app sends it in addition to closing its own connection, because a closed connection does not always reach the server (browser, CDN and edge can lose it) and the server would then generate, and save, the whole answer. <TURN_ID> is the x-aig-turn-id the app sent on the streamed request. The request has no body.

The route only records the Stop on the turn's claim row; the request that is generating polls for it (about once a second) and then ends exactly as it does when the client disconnects: generation stops, the partial streamed so far is kept and saved as a stopped partial (stopped_partial = 1), the request log records aborted = 1, and nothing after the Stop is generated or saved. A turn that already ran a tool is not resumable after a Stop. While the gateway is still waiting for the provider's first byte (the header wait), the Stop is applied about one second after that first byte arrives, not at the moment it is recorded; the same applies to a Stop that lands during a tool call or between two model calls. During the tool loop and post-tool model calls a recorded Stop wins over a provider failure on the same turn: the turn ends as a Stop (no failure frame, no error record), and no further model call is made. A Stop that lands after a failed first model call ends the turn with that failure recorded, exactly like a disconnect, and no further call is made; a retry backoff wait ends as soon as the Stop is seen.

Status Body Meaning
202 {"stopping": true} A running turn was found and the Stop is recorded. It ends within about a second.
200 {"stopping": false} Nothing to stop: the turn already ended, was already stopped, never existed, or has not registered yet (the pre-stream phase). Never an error; a client that wants the Stop confirmed repeats it about once a second until it gets 202. The app does exactly that: before the first token it sends the Stop about once a second, up to 20 POSTs, until a 202 confirms it.
400 {"code": "invalid_turn_id"} <TURN_ID> is not 1-36 characters of A-Z a-z 0-9 . _ - : +. A malformed id is rejected, never read as "no such turn".
403 / 404 conversation_not_found etc. The caller may not write to this conversation (same gate as sending a message).
503 {"error": "temporarily unavailable", "code": "temporarily_unavailable"} The database could not be reached; the Stop was not recorded, retry. The app repeats a 503 about once a second, up to 20 POSTs, at any point of the turn.

Accepted / rejected input: the conversation id and the turn id are validated before anything is read or written; the turn id is only ever matched against turns of that conversation, so a Stop can never reach another conversation's turn. A running turn that cannot be polled (a database fault on the running request) keeps generating (fail-open); the Stop is then repeated by the client.

Stopped turn (stop_reason)

A turn that ended before it finished keeps everything it produced. This holds for a stream: false turn too: if the client leaves before the response is sent, the answer produced so far is saved as the same stopped partial, and a turn that was cut (the client stopped it or left before the provider finished, or the time budget ended it) after being billed, but produced no answer, keeps the note row "Stopped before an answer was produced." with its stop_reason. A turn that used no tokens leaves no row, and neither does a turn that ended empty after the provider had finished: it was not stopped and there is nothing to keep (its billing stays in the request log). This is the same for streamed and stream: false turns. If the provider's final body is not an answer (an error object, an unreadable body, or an empty reply) and the client has left, the text already produced is kept; it is never replaced by the note row. When no client cut caused it, that kept text carries the interrupted marker (interrupted_class provider_error) instead of reading as a complete answer; a turn the client cut stays a stopped partial without it. The request log records the same outcome: a kept text with the interrupted marker is logged with the provider failure's status (502 for a provider error), a turn the client cut stays 499, and a real answer that was saved stays 200. A stream: false turn whose client stays connected stores no answer: the JSON body is the delivery. Each of these turns releases its running-turn claim, so the next turn on the conversation is never refused because of it. A stream: false turn that is held for approval is the exception: it keeps its claim until it is resumed. Each assistant message of GET /admin/v1/conversations/<ID> (and the turn_committed frame of the stream) carries stop_reason:

Value Meaning
"client_gone" The client pressed Stop or left; the reply is a stopped partial.
"wall_clock_exceeded" The tool-loop time budget ended the turn.
absent The turn ran to its end. The key is omitted (never sent as null); a client should treat null the same as absent.

If both happened, client_gone is reported. The marker is derived from the saved turn; the stored flags (stopped_partial, wall_stopped) are not part of the API. A client should treat a value it does not know as a generic "stopped early" marker, never as an error, and must not show the raw value.

The saved content keeps all text the model streamed. A file the model was still writing (a write_file or edit_file call that the gateway runs, whose arguments had not completed) is never created or changed; its content (for edit_file, the new text) is kept in the reply as a block headed "Unfinished file <name> (not saved)" (write_file) or "Unfinished change to <name> (not saved)" (edit_file; German "Unvollständige Datei ..." / "Unvollständige Änderung an ..."), so the work is not lost. A Stop that lands before anything was billed leaves no reply row. A Stop that lands early in a turn that did bill tokens keeps the row and gets the same early-stop note as other stopped turns ("Stopped before an answer was produced.", German "Gestoppt, bevor eine Antwort entstanden ist.").

Reading the state of a turn (GET …/turns/<TURN_ID>)

GET /admin/v1/conversations/<ID>/turns/<TURN_ID> tells a client whether a turn it started is still running, so it can recover after its connection was lost (see x-aig-detach-on-drop under "Client disconnects" in the inference reference) without sending the message twice. <TURN_ID> is the x-aig-turn-id of the streamed request. Read access is the conversation read gate (owner or project member); the turn id is only matched against turns of that conversation.

Status Body Meaning
200 {"state": "running"} The turn's claim row is streaming and was refreshed within the last 60 seconds.
200 {"state": "committed"} The answer is saved. Read it with GET /admin/v1/conversations/<ID>.
200 {"state": "failed"} The turn ended with an error or a guardrail block; the saved row carries the error.
200 {"state": "stopped"} The turn ended as a Stop (a saved stopped partial).
200 {"state": "none"} No such turn, or a streaming row whose worker died (no refresh for 60 seconds).
400 {"code": "invalid_turn_id"} <TURN_ID> is not 1-36 characters of A-Z a-z 0-9 . _ - : +. A malformed id is never read as none.
404 {"code": "conversation_not_found"} The conversation does not exist or the caller cannot read it.
503 {"error": "temporarily unavailable", "code": "temporarily_unavailable"} The database could not be reached. Retry; this is never answered as none.

A turn that is still running blocks a second turn on the same parent message: that request is refused before any model call with 409 turn_in_progress and turn_id of the running turn (no row is written). The check and the claim are serialised on the conversation, so two simultaneous sends cannot both start.

Numeric fields (input_tokens, output_tokens, latency_ms, created_at)

POST /admin/v1/conversations/<CID>/messages accepts four optional numbers that are stored as integers. Absent or JSON null leaves the column at its default. A value that is present must be a JSON number (never a string) that is finite, not negative, a whole number and at most 9007199254740991 (2^53-1, the largest integer a JSON number carries exactly). Anything else is refused with 400 and { "error": "<field> must be …", "code": "invalid_<field>" } (invalid_input_tokens, invalid_output_tokens, invalid_latency_ms, invalid_created_at); nothing is written, and the value is never rounded, clamped or read as absent.

created_at is server-assigned: a well-formed number is accepted (201) and ignored, and the message's created_at and the conversation's updated_at (the time the retention purge reads) are always the server's clock at the moment of the write, so a client can neither keep a conversation past its retention window nor shorten it, and a co-driver cannot change the owner's updated_at by sending a value. Messages stored in the same second keep their order of arrival. A malformed created_at is still refused with 400 invalid_created_at.

The client message id (client_message_id)

A user message may carry the app's per-send id, so a save whose answer was lost (the connection dropped, the user pressed Stop while it was being saved, a phone ended the browser tab) is never stored twice and can be asked about afterwards.

Field Accepted Rejected (400, code: "invalid_client_message_id", nothing written)
client_message_id (optional) a string of 1–64 characters from A–Z a–z 0–9 _ - (the app sends a UUID), on a message with role: "user" JSON null, a number, boolean, array or object, an empty string, more than 64 characters, any other character (space, dot, slash, percent-escape, non-ASCII), or an id on any role other than user

Absent means a message without an id (unchanged behaviour). A present but malformed value is never treated as absent. The id is unique per conversation and compared exactly (case-sensitive):

  • First save with an id → 201 { "id": "<message id>" }.
  • The same id again in the same conversation → 200 { "id": "<the stored message's id>", "deduplicated": true } — no second message is written.
  • The same id again after that message was deleted, or with a different role or text → 409 { "code": "client_message_id_conflict" } (a deleted or different message is never reported as saved).
  • The same id again after the conversation was deleted → 404 conversation_not_found.

The confirmed image (image_source)

When an image tool offers the conversation's newest image ("Use this image?", see Image generation), the app's Use this image sends a user message that names the confirmed image and the tool it was confirmed for. The gateway stores it on that message and the tool reads it from there for this turn — and for a Regenerate of its answer or a Send again (the app names the message with x-aig-parent-msg-id on those too; a turn that does not is never bound to a guessed message) — so the image is the user's choice, never the model's.

Field Accepted Rejected
image_source (optional) "<code>:<image id>" on a message with role: "user": code is edit (generate_image), video (create_video) or bg (remove_background); the id is a lowercase UUID naming a live image of this conversation — a generated image of a live answer, or a live user message with a photo (then its last photo — an inline image with a base64 data: URL and without a document filename; a message whose only pixels are its uploaded file counts too). A message whose only images are a document's embedded figures names no photo (422). At most 64 characters. Only the conversation's owner may send it. A user message with several inline images is never offered (the tool asks the user to attach the one image instead); naming it here is an explicit choice of its last inline image (the image the app's Pick another list shows for it). 400 { "code": "invalid_image_source" }, nothing written: JSON null, a number, boolean, array or object, an empty string, more than 64 characters, an unknown or upper-case code, an id that is not a lowercase UUID (or has anything after it), or the field on any role other than user.
403 { "code": "image_source_forbidden" }: the caller writes to the conversation but does not own it (a live co-driver).
422 { "code": "image_source_not_found" }, nothing written: the id is not a live image of this conversation (another conversation's, unknown, a text-only message, a deleted message, an image of an answer that was replaced by a regenerate).
503: a database fault.

Absent means no confirmation (unchanged behaviour); a present but malformed value is never read as absent. The route checks only that the image exists; when the tool runs it loads the image again under the owner check and applies its own type and size limits. Editing a message (PATCH) clears its image_source — an edited request is a new request, and the image is offered again. A fork copies the confirmation pointing at the fork's copy of the image (or drops it when that image is not part of the copied prefix).

GET /admin/v1/conversations/<CID>/messages/by-client-id/<ID> — was the user message with this client id stored in that conversation? Read access is the conversation read access (owner, or a project member it is shared with); impersonation is refused like every personal-data route.

Status Body When
200 { "id": "<message id>" } A stored (not deleted) user message carries that id.
404 { "code": "message_not_found" } No stored user message carries it (never saved, or deleted).
404 { "code": "conversation_not_found" } The caller cannot see the conversation (unknown, deleted, someone else's) — the same answer whether or not the id exists.
400 { "code": "invalid_client_message_id" } The id is malformed (the rules above), checked before anything is read.
503 { "error": "temporarily unavailable; retry later" } A database fault — never a 404 that would read as "not stored".

An id containing an encoded slash (%2F) does not reach this route at all (it no longer matches the path) and gets the router's plain 404. Known limit: if the first save of an id fails on a database fault at the very moment a retry of the same id is answered deduplicated, that answer can name a row the failed first save then removes; the app treats a later lookup as the authority.

Messages kept in the browser (client-side)

The chat app keeps a message that is not in the message input yet — one still on its way to the server, or the text of a "was not sent" notice — in the browser's local storage until the server has saved it or the user acted on it, so a reload or a tab the operating system ends does not lose it. This is client-side state, not an API, but it is read back as untrusted input:

  • Key aig:kept:<user id>:<page id>:<id>; only the signed-in user's own keys are ever read (impersonation keeps nothing). Signing out removes every such key; signing in removes other users'.
  • Accepted record (v: 1): text (string), files (up to 20 {filename, mime_type} — names only, never file contents), home ({kind:"conv", id, title} or {kind:"newChat", projectId}), convId / cmid (null, or 1–64 characters of A–Z a–z 0–9 _ -), fresh (boolean), at (number).
  • Rejected and removed: anything else of version 1 (corrupt JSON, a wrong type, an id with other characters, no text and no files), and any record older than 30 days or dated more than a day in the future. A record of another version is left alone (a newer app version may own it) until it expires.
  • At most about 1 MB per record; a larger message is not kept.
  • Before a kept message that may have reached the server is given back, the app asks GET …/messages/by-client-id/<cmid>: a stored message is never given back.

The write gate (POST, PATCH, DELETE)

All three message writes run the same server-side gate before touching a row, and every refusal is a typed body the app acts on without reading prose. The <CID> / <MID> path segments are untrusted input; ownership, project membership and the live-session driver lock are all resolved server-side — the client is never the authz boundary.

Status Body When
403 { "error": "…", "code": "viewer_read_only" } The caller holds the viewer role — refused every chat write that spends credit or reshapes context. Decided first, before any conversation lookup, so a viewer is refused whether or not the id exists (no existence oracle). See Viewers cannot spend credit or reshape a conversation.
404 { "error": "conversation not found", "code": "conversation_not_found" } The caller cannot see the conversation at all: unknown id, deleted (another tab, another device, retention), or never shared with them. Returned only for a conversation the caller has no read access to — never for one they can still read — so the app may safely treat it as "this conversation no longer exists" (clear the thread, drop it from the list, non-error notice, back to the start page, draft kept).
403 { "error": "…", "code": "live_not_driver" } The caller can read the conversation, a live shared session is active, and they are not the current driver (or their lease lapsed). The owner is not exempt. A refusal, not an error — the app shows it as a notice and does not report it.
403 { "error": "…", "code": "forbidden" } The caller can read the conversation (a project member it is shared with) but no session is active — off-session only the owner writes.
503 { "error": "temporarily unavailable; retry later" } A database fault while deciding (a read — nothing written), or (DELETE) a transient conflict on the write.
500 { "error": "internal error", "request_id": "…" } Any other database fault while deleting (the delete may or may not have landed). Retryable; never disguised as a 403/404 that would make the app drop the user's message or treat a live conversation as deleted. The decision runs under one read retry on a fresh connection, so a pooled-connection blip does not surface.

A not_found is decided from visibility alone, before any session state is consulted, so an invisible caller gets the same answer whether or not a session is live (no oracle). The attachment and knowledge routes under a conversation keep their own owner-scoped "conversation not found" bodies without the code — there a miss can also mean "visible but not the owner", and the app must not read that as a deletion.

PATCH /admin/v1/conversations/<CID>/messages/<MID> — edit an existing message. The body carries one of three mutually distinct operations. All pass the write gate above first; the row update itself is the owner's, with one exception: a live co-driver holding the wheel may edit their own tail — a user message they wrote, where no later live user message was written by anyone else (or has no author). The wheel is re-checked inside the write itself, so a seat lost between the gate and the write refuses the edit. Anything else by a non-owner (the owner's message, a co-driver message with another author's message after it, or any write without the wheel) is refused with 403 { "code": "not_conversation_owner" } for content and content_text, nothing changed; content / content_text also require the target to be a user message. corrected_content by a non-owner is already 403 forbidden at the gate. The web app shows Edit to a co-driver only on their own tail. The corrected_content operation is gated on visibility only (it never reaches model history, so the driver lock does not apply — the owner can fix a typo while someone else drives); the content and content_text operations are driver-locked like POST, because the app trims and regenerates behind them.

Field Type Effect
content string Rewrites the FULL message body (the legacy full-replace form). This IS what the model sees as history on later turns.
content_text string Text-only edit (preferred for the user-message edit). Sends ONLY the edited text; the server splices it into the first text block of the STORED body and preserves every other block (an inline image / docx), so a large attachment is never re-uploaded nor re-gated as text. If the stored body has no text block it prepends one; a plain-text message is simply replaced. A stored body counts as a block list only in the exact shapes the app writes (see the note under POST …/messages); the auto-generated long-paste block (pasted-text-<timestamp>.md) is replaced by the edit. Any other body — including a message the user typed as JSON, e.g. [1,2,3], [], [{"type":"click"}] or a pasted content array — is plain text and is replaced. Blank text is refused (any role): an empty or whitespace-only content_text (whitespace = the JavaScript trim() set, e.g. spaces, tabs, newlines, U+00A0, U+3000, U+FEFF) is 400 {"code":"empty_message"} and nothing is written. User messages only: on any other role (an assistant answer, a system row) a non-blank request is a no-op — 200 {"ok":true}, nothing written, content and the image reference untouched — the same answer corrected_content gives for a non-assistant row.
corrected_content string | null A user's display-only correction of an assistant answer (fix a typo without re-prompting).

corrected_content semantics. It is a display OVERLAY, not a rewrite: the app renders / copies / exports / reads-aloud corrected_content when present, but the message's content (the model's original output) is never touched — and content, not the correction, is what is ever sent back to the model as conversation history. A correction can therefore never feed the model's context. Moderation (report-message) and FULLTEXT search likewise operate on the original content by design. Accepted: a string that is valid UTF-8 with no NUL bytes and within the shared text size ceiling (~7.5 MB, the same validate_client_text limit the knowledge upload uses). An empty/whitespace string or JSON null clears the correction (reverts the display to the model original). A workspace can switch corrections off (answer_corrections_enabled): setting a non-empty correction is then refused 403 {"code":"answer_corrections_disabled"} (the policy is checked before message ownership, so a non-owner in such a workspace also gets this code rather than not_owner; both are 403 and the refusal is the same for every caller), while clearing stays allowed and stored corrections stay displayed. Rejected with 400: a non-string value (number, boolean, object, array), invalid UTF-8, NUL bytes, or an over-ceiling value. Rejected with 413: a correction that, together with the message's other large columns (content, and the sources / search-steps lists a web-search turn stores), would make the row larger than the database can read back in one packet (~15.9 MB for all of them together — a correction on an answer that is itself near the commit ceiling); the row is left unchanged and the body carries code: "row_too_large" (see error codes). The same two rules apply to an edit of content (400 for invalid text, 413 for a row the edit would make unreadable) and the 413 to the legacy POST …/messages commit. A row the writers admit can always be forked (the fork copies the large columns server-side). content_text semantics. The edited text is validated as text (same validate_client_text rules — valid UTF-8, no NUL, ≤ ~7.5 MB; a non-string / invalid / over-size value → 400); the preserved blocks (the already-stored image/docx) are NOT re-sent and NOT re-validated, and the re-persisted row is still subject to the 413 row bound above. Precedence when more than one field is present: corrected_content > content_text > content. If none of the three is present → 400. A blank edit (content_text or content empty / whitespace-only) is refused with 400 {"error":"…must not be empty","code":"empty_message"} before anything is written (a caller the write gate refuses still gets its 403/404 first; a live co-driver's blank edit is rejected with 400 before the per-message ownership check); a JSON null or non-string stays the plain validation 400. For the legacy whole-content form only the raw string is checked: a JSON block-list string whose text is blank is not re-parsed and is stored as sent — use content_text. corrected_content: "" is not an edit: it still clears the correction. content_text applies to user messages only: on any other role a non-blank request answers 200 {"ok":true} and writes nothing (a model answer is never rewritten, even when its text looks like a block list). The whole-content form is not role-gated.

Known limitation: a correction is an in-place update with no new sequence number, so it is not broadcast to a live co-chat viewer in real time — it appears on their next conversation load. A public share link minted after a correction freezes the corrected text in its snapshot.

DELETE /admin/v1/conversations/<CID>/messages/<MID> — delete a message (the app's edit-and-resend trims the replies after the edited message with it; a regenerate deletes nothing — the gateway supersedes the prior answer atomically when the replacement commits, see x-aig-regen-of-turn in the inference reference). Passes the write gate above, then soft-deletes the row — the conversation's owner, or a live co-driver holding the wheel for a message in their own tail (same rule as the edit above); any other non-owner delete is 403 { "code": "not_conversation_owner" }, nothing deleted. A message id that does not exist (or is already deleted) inside a conversation the caller may write to is an idempotent 200 {ok:true} — the app relies on that after a turn that was never persisted. A conversation that no longer exists is the typed 404 conversation_not_found, so an edit-resend never streams a "ghost" answer onto a dead thread; an owner who is not the current driver is refused (403 live_not_driver) before the row is touched, so a reply is never deleted only for the follow-up turn to be blocked. A transient conflict on the delete that wrote nothing is 503 { "error": "temporarily unavailable; retry later" } (send it again); any other database error is the sanitised 500 { "error": "internal error", "request_id": "…" }, never a 200 that would let a second answer be generated on top of a still-live row.

Message size limit and error codes

A message write body (POST /admin/v1/conversations/<CID>/messages) may be at most 16 MiB on the wire, text and inline attachments together. The limit is published as limits.message_wire_bytes in GET /admin/auth/me. A larger body is refused at the edge with 413 {"error": "payload_too_large"}; nothing is stored. A client must not re-send the same body: it can never succeed. Shorten the message or remove attachments. The web app names the size and the limit and keeps your draft.

Every other refusal on the message, conversation-sharing, comment and file routes, apart from the uncoded answers listed below, carries a machine code at the top level, next to the English error text. Branch on code, never on the prose. Two answers are deliberately uncoded: the audited 404 {"error": "not found"} (byte-identical to a real miss, so a probe cannot tell an unknown id from another workspace's) and the one storage-fault answer 503 {"error": "temporarily unavailable; retry later"} (the same body on every route). The in-place save refusals that PUT …/conversations/<CID>/knowledge/<KID> shares with the project route carry a code too: extracted_text_required (400), invalid_content_type / invalid_extracted_text (400 — invalid content) and file_not_found (404); and the shared 400 {"error": "content type must be application/json"} answers code unsupported_content_type on every admin route that checks the Content-Type, the POST form of POST /admin/v1/conversations/search included. For the two uncoded answers, branch on the HTTP status and the route, not on code. Codes are listed per route group with their HTTP status; a few refusals pass a fixed code through from a shared layer (route resolution and policy, guardrail and upstream Files-API failures, extractor exit classes) and are documented with that layer.

Route group Codes (status)
Messages: POST …/messages, PATCH/DELETE …/messages/<MID>, attachments, media and MCP-app reads role_and_content_required, empty_message, content_required, invalid_body, invalid_content, invalid_content_text, invalid_corrected_content, invalid_client_message_id, invalid_input_tokens, invalid_output_tokens, invalid_latency_ms, invalid_created_at, invalid_image_source, attachment_fields_required, bad_base64, mime_type_too_long, type_malformed_declared (400); forbidden, not_conversation_owner, not_message_author, message_author_unknown, image_source_forbidden, app_not_available (403); conversation_not_found, message_not_found, file_not_found, image_not_found, audio_not_found, video_not_found, original_not_stored, no_preview, mcp_app_not_found, video_not_ready, not_found (404); client_message_id_conflict, video_not_pending, video_already_finished (409); attachment_too_large, row_too_large, body_too_complex (413); image_source_not_found (422); rate_limited (429); mcp_app_scope_unavailable, mcp_app_response_unavailable, token_mint_failed (500); viewer_resource_unavailable, invalid_preview (502); video_service_unavailable (503)
Conversations: create, update, list, search, sharing and branching invalid_project_id, invalid_source_share_token, invalid_hint_pii_preference, invalid_route_preview_parameter, invalid_expected_route, invalid_if_absent, invalid_if_empty, invalid_q, q_required, model_not_string, branch_message_id_required, not_in_project, invalid_web_search, invalid_mcp_connectors, invalid_archived, invalid_ghost, invalid_memory_disabled, invalid_personal_style_disabled, invalid_starred, gateway_id_required, gateway_id_invalid, invalid_<param> for a malformed numeric query parameter (400); unauthenticated (401); no_tenant, caller_has_no_tenant, not_project_member, project_not_accessible, share_not_project_member, unshare_forbidden (403); conversation_not_found, share_not_found, not_shared (404); already_shared, conversation_not_empty, route_changed (409); route_policy_unavailable (500)
Comments: …/comments, …/comments/<COMMENT_ID> comment_body_required (absent, null, "", blank or only invisible characters, see Conversation comments; the latter formerly comment_body_empty), invalid_comment_body, comment_body_too_long, invalid_message_id, anchor_requires_message_id, anchor_incomplete, invalid_anchor, invalid_mention_user_ids, too_many_mentions, invalid_resolved, mention_not_participant (400); comment_forbidden (403); conversation_not_found, comment_not_found (404)
Conversation files, staging uploads and exports: POST /chat/files, POST /chat/export-*, POST /chat/convert-html data_required, filename_required, gateway_id_required, invalid_body, bad_base64, type_malformed_declared, invalid_progress_id, progress_id_required, markdown_required (400); not_found (404); file_too_large, markdown_too_large, body_too_complex (413); convert_too_large (413 when the HTML file exceeds the size limit, 422 when the document is too large to convert); extract_failed, pdf_malformed, pdf_no_text, pdf_password_protected, docx_password_protected, pptx_no_text, unsupported_image_format, image_transcribe_failed, json_requires_extracted_text, text_requires_extracted_text, pii_masking_requires_extracted_text, not_utf8_text, no_table_found, no_content_found, convert_not_html, convert_no_file, convert_open_failed, convert_empty, convert_bad_input, convert_deck_unprintable (422); convert_not_ready (409); convert_rate_limited (429); export_failed (500); data_residency_blocked, model_not_allowed_for_project, conversation_project_unresolved (403, POST /chat/files raw provider upload only: EU data residency enforced, a Tier-1 project, or a conversation whose project no longer exists, the same refusal a chat turn gets; the Tier-1 codes are the same set a chat turn answers: model_not_allowed_for_project, conversation_project_unresolved, agent_area_unresolved and project_tier_unresolved, where agent_area_unresolved only arises for agent runs); project_tier_unresolved (503, POST /chat/files only: the project tier could not be read); configuration_error (500, POST /chat/files only: a Myra key would be sent to the gateway's provider_base_urls.anthropic override, refused before any byte is sent); convert_failed, files_api_bad_response (502); configuration_error (502, POST /chat/files only: the gateway's provider_base_urls.anthropic override is malformed or resolves to a private/internal address); extract_transient, ingest_busy, render_busy, convert_busy, convert_unavailable, files_api_key_missing (503); convert_timeout (504)

Images in a user message (how the app displays them)

A user message's content is stored as sent. It counts as content blocks only when every element has the exact shape the app writes (see the note under POST …/messages). Only a user message can be an attachment block list: an assistant answer whose text happens to look like one is shown, copied and sent back to the model as plain text. For an image_url block, that means the object form {"url": "data:…"}.

A message whose image_url is a remote URL, a scheme-relative //host/…, a relative path on the app's own origin, a bare string, a non-string or missing is therefore plain text: the whole JSON is shown as the message text, and no image is ever loaded.

Within a block list, the app shows an image inline only when its url is inline base64-style image data:

  • data:image/<type> followed by at most 8 ;param parts (letters, digits, =.+-);
  • the whole header is at most 256 characters;
  • then a comma, and a payload of only letters, digits, +/=%._- and ASCII whitespace (line-wrapped base64).

That is what a pasted or dropped screenshot, or an image extracted from a .docx or PDF, produces. Any other data: value is never loaded: a non-image data: payload, or a raw (non-base64) data:image/svg+xml,<svg…>. The bubble shows the inert text "[image not shown]" instead.

The message body does not repoint the conversation's gateway

The legacy POST …/messages commit body may carry gateway_id and model recording which gateway and model produced the reply. model is propagated to the conversation as live state (so a reload reflects the model the client last sent to, unless the conversation is on Auto, whose row model is the create-time resolution and is never overwritten by a per-turn upgrade). The conversation row records the client's route id verbatim (for example a pinned azure/gpt-4o); the per-turn transformations the gateway applies (provider-prefix stripping, retired-model successor remap, routing remap, failover) are not baked into it. The message row's model keeps the served id, which is what the response disclosed. The gateway_id is recorded on the message row only — it does not change the conversation's gateway. The conversation's gateway determines whether request-phase PII masking and per-gateway malware scanning apply, so it is a security setting. It is set at creation, and the only client-driven way to change it is the guarded PATCH /admin/v1/conversations/<ID> (see Route policy validation), which authorizes the target gateway (unknown / cross-tenant / non-production-on-move refused); the server additionally keeps it in sync as it records the gateway that produced each turn (always the caller's own tenant). A gateway_id in the message-append body — of any gateway, in any tenant, under any role — is ignored for the conversation's gateway and leaves it unchanged; an attachment uploaded afterward is still scanned according to the conversation's original gateway. This route is not a gateway-authorization boundary, so it accepts no gateway repoint at all.

Regenerate-reason provenance (regen_reason)

When a user regenerates an assistant answer with a steering nudge (for example "too long" or "too formal"), the client sends the chosen preset key and the gateway stores it on the assistant message as regen_reason, so the app can show a subtle "Adjusted · …" provenance chip that survives reload.

Accepted values — exactly one of the fixed set: tooLong, tooShort, tooFormal, tooCasual, offTopic, inaccurate, fileNotCreated. fileNotCreated is sent by the Create it now button of the No file was created note, not by the regenerate menu. Anything else (an unknown key, an oversize string, injection) is rejected at the trust boundary and stored as NULL (no chip) — the value is never echoed back or used unvalidated. A plain "try again" regenerate carries no value and resets the column to NULL (single-writer, last-nudge-wins).

Two ingress paths, one allowlist:

  • streaming inference — the x-aig-regen-reason request header (read per turn, never forwarded to the model provider);
  • the legacy POST …/messages body — an optional regen_reason field.

The value appears on each assistant message in the conversation-GET response; the field is omitted when unset (a plain turn), so the app treats absent and empty identically. It is enum-like text, capped at 32 characters on the wire as defense-in-depth; the app-side allowlist is the authoritative validator.

Web-search steps (search_steps)

When an answer used web search, the gateway records the per-query search process — each query plus its result list {title, url} — so the collapsed "Searched the web" disclosure rehydrates identically on reload. The server-owned commit stores this itself; on the legacy commit path (an older gateway that did not acknowledge server-side turn ownership, or the Playground) the client is the writer, so the optional search_steps field may accompany the assistant message on POST …/messages.

Accepted shape — an array of steps, each { "query": <string>, "results": [{ "title": <string>, "url": <string> }] }. Every field is re-validated at the trust boundary through the same sanitizer applied on read (it is untrusted at rest as well as on ingress): the list is capped (32 steps, 10 results per step), query/title are length-clamped, and a url must be http(s):// — a javascript:/data: or over-long url is dropped, a step whose query is missing or non-string is dropped, and a wholly unusable list stores NULL. Absent on a non-search turn → the column stays NULL.

The value appears as search_steps on each assistant message in the conversation-GET response and is omitted when unset; the raw stored blob is never echoed back.

One-click connector card (connector_setup)

When the built-in setup_connector tool offered a one-click "connect X" card in a turn (the live connector_setup SSE frame, sent only to clients that opt in with x-aig-connector-setup: 1), the server-owned commit stores that card with the assistant message so a reload shows the same card. Only a card that was actually delivered to the client is stored: a turn without the capability header, or one whose stream was buffered or refused, stores nothing. One card per turn; a second setup_connector call in the same turn is refused.

The value appears as connector_setup on the assistant message in the owner's conversation-GET response and is omitted when unset (legacy messages, turns without a card). Shape — exactly the live frame's payload minus the wire envelope key aig_status:

{ "slug": "todoist", "name": "Todoist", "description_key": "mcp.catalog.todoist.description",
  "example_actions": ["..."], "host": "ai.todoist.net", "connector_id": "<uuid, reconnect only>" }
  • Validated on read. The stored blob is untrusted at rest: it is re-validated on every read (known catalog slug, bounded text, only the keys above, connector_id absent/null or a canonical UUID, at most 4096 bytes). A corrupt blob is dropped with a server warning - the message text and its neighbours are unaffected and the request never fails. The raw column is never echoed.
  • The card carries no state. Whether the connector is connected comes from GET /admin/v1/mcp, never from this field.
  • Client handling. The web app renders the stored card on reload and derives its state (offered, connected) from GET /admin/v1/mcp. After the OAuth return (?connected=<id> or ?oauth_error=<code>) it updates the card in place and, on success, sends one follow-up message so the assistant continues. Connect is a plain navigation to GET /admin/v1/mcp/connect with return_to=chat:<conversation id>; the web app keeps nothing in browser storage across the sign-in. On ?oauth_error it marks the newest card of the failed connector (&connector=<id>); without a usable connector it shows the error as a conversation note. &selection=full is set by the server when the connected connector will not be among the chat's tools on the next turn (an explicit selection that is full or does not include it, or an implicit selection where it is beyond the first 8 connected connectors). The client then sends no continuation message and the card shows the matching hint (maximum of 8 connectors reached, or connector not selected for this chat); a malformed selection value also sends no continuation. The hint is not persisted; after a reload it is gone. A client that does not render the card ignores the field.
  • Owner only. Shared-conversation readers, project-feed readers, live-session (room) viewers and members who fork a shared conversation never receive or copy the card. The data export (conversation export) includes it for the owner's own conversations, as connector_setup on each message.

Guardrail-block class (guardrail_block_class)

When a request is blocked by a request-phase guardrail (content policy, mandatory PII protection, an unscannable attachment, or a fail-closed "guardrail temporarily unavailable"), the gateway persists a distinct policy-block turn and stamps the block class slug on that assistant message as guardrail_block_class. This lets a reloaded conversation rehydrate the distinct, localized policy-block bubble instead of reverting the block to a plain-looking assistant reply.

Accepted values — a fixed, gateway-authored class slug: guardrail_blocked, guardrail_pii_mandatory, guardrail_pii_media, guardrail_classified_media, guardrail_unavailable, guardrail_unconfigured (a guardrail the request needs is not set up; not retryable, an administrator has to set it up), guardrail_doc_too_large (the personal-data scan of a large document could not finish in time; retryable), guardrail_role_model. Only the gateway writes this field (there is no client ingress path); it never carries user or model text and never the tripped safety category (see guardrail_block_category below for the data category of a data-protection block). It is enum-like text, capped at 32 characters on the wire as defense-in-depth.

On load the value is untrusted (a DB value could be malformed by a future bug or manual edit): the app renders it only as a localized i18n key with a fail-closed fallback, so an unrecognized non-empty slug degrades to a generic "Request stopped" bubble (never a raw key, never markup, never a crash). The field is null/omitted on every normal (non-blocked) turn, which the app renders as an ordinary message.

Guardrail-block data category (guardrail_block_category)

When the block was caused by a built-in data-protection rule, the assistant message also carries guardrail_block_category, the kind of data that was detected, so a reloaded conversation names it the same way the live notice did.

Accepted values: credit_card, bank_account, id_number, tax_id, health_insurance, classified_marking (a classified-markings keyword rule; see Guardrails API). Only the gateway writes it; it never carries the matched text. The field is null/omitted for every other block (keyword rules, custom patterns, mandatory PII protection and so on) and on normal turns. An unrecognized value is ignored by the app, which then shows the general policy-block notice.

Guardrail refusal detail (guardrail_block_detail)

When a turn was refused with guardrail_unconfigured (a safety check the request needs is not available), the assistant message also carries guardrail_block_detail, so a reloaded conversation shows the same notice as the live refusal. It has the same shape as the live event's detail (see Error codes):

Key Value Who receives it
check prompt_injection or prompt_guard — the check that is not available every viewer
reason missing, credential_unreadable or invalid_endpoint — why the prompt-injection classifier could not be used at the time of the refusal platform admins, and organisation admins of the organisation the refusal happened in
scope baseline (the organisation's Guardrails page carries the rule) or gateway (the gateway's Guardrails & residency view does) platform admins, and organisation admins of the organisation the refusal happened in
tenant_id, gateway_id the ids that page needs (gateway_id only for gateway) platform admins, and organisation admins of the organisation the refusal happened in

The role split follows the viewer, not the sender. The gateway stores the full detail with the turn, whoever was refused, and every conversation read returns only the part the viewer's role may see: a member opening an admin's refused turn in a shared project conversation receives check only, and an admin opening a member's refused turn receives the reason and the page. An organisation admin receives the admin part only for a refusal in their own organisation; a refused turn from another organisation (for example a platform admin's turn there, later shared into a project of theirs) shows them check only. This applies to the conversation read (GET /admin/v1/conversations/{id}, owner and shared reader) and to the response of a fork. The stored value never contains the classifier endpoint, a credential, user text or model text.

Validation (untrusted at rest): the stored value is re-checked on every read. Only the keys and values in the table are returned; an unknown key, a value outside the listed sets, an id that is not 1–64 characters of A–Z a–z 0–9 _ . : -, or a value that is not a JSON object is dropped (a value that is not a JSON object is logged as a warning). When nothing is left the field is omitted, and the app shows the general "safety check not available" text. The field is omitted for every other block and on normal turns; a regenerate over a refused turn clears it. A fork copies it with the turn.

Hard-failure error class (error_class)

When a turn hard-fails — the request is too large / oversized attachments (413), the prompt exceeds the model's context window, every configured provider fails, a request times out, or a provider returns a client error the gateway could not recover, or — on a live (streamed) chat turn — the provider sends a mid-stream error event before any visible answer (provider_error), or a server-side tool loop's model call after a tool result fails before anything was shown (request_timeout for a first-byte timeout, model_capability_mismatch when the tool result carries a document the model cannot read, the gateway's own policy code when the gateway refused that call for a policy reason, otherwise provider_error) — the gateway now persists a distinct failure turn and stamps the gateway error code on that assistant message as error_class. This lets a reloaded conversation show an honest, assistant-visible failure bubble ("this turn failed: <reason>") instead of a dangling user message with no response. It is the sibling of guardrail_block_class above. The failure row is written even when the client disconnects while the turn is failing (tab close, navigation, network drop): the gateway finishes the failing turn server-side, so the reloaded conversation is always honest. A disconnect never fabricates a failure for work that did not fail: a disconnected turn whose dispatch succeeds simply ends as an empty turn (the same behavior as pressing Stop before the first token), and only a real failure persists.

Stopped replies. When a reply is cut short because the client left mid-answer (Stop, tab close, network drop), the saved partial message is marked internally as stopped (not part of the message JSON), and later turns are told in the conversation record that it is incomplete (see Conversation record). The mark is never set on a failure turn (that keeps its error_class), is copied when the conversation is forked, and is cleared when the turn is regenerated.

Accepted values — a fixed, gateway-authored, server-sanitized code: all_providers_failed, request_too_large, request_timeout, context_overflow, context_length_exceeded, model_capability_mismatch, provider_error, web_search_not_supported, provider_quota_exhausted, model_not_entitled, response_number_not_exact, response_number_invalid; and — only when the gateway itself refused the model call after a tool result for a policy reason — data_residency_blocked, provider_not_allowed, provider_objected, agent_protection_blocks_model, local_only_egress_blocked, configuration_error, model_not_found, model_disabled_on_gateway, model_pin_invalid, model_pin_conflict, role_model_not_allowed, inherent_search_blocked, inherent_search_rejected, native_grounding_blocked, native_grounding_rejected (a provider-authored code can never be stored as one of these). The gateway is the only writer (there is no client ingress path). Where the code originates in a provider's own 4xx error body, it is validated against this allowlist at the trust boundary and any other value — an arbitrary, oversized, or non-[a-z0-9_] string — is coerced to provider_error before it is stored, so the raw provider text never lands at rest. The accompanying message content is a gateway-authored sentence (never the raw provider prose), capped defensively; the field is enum-like text, capped at 48 characters on the wire.

On load the value is untrusted and rendered only as a localized i18n key with a fail-closed fallback (an unrecognized non-empty code degrades to a generic failure bubble — never a raw key, never markup, never a crash). The field is null/omitted on every normal (successful) turn.

A failure row of a turn whose server-side tools had already run keeps those tools' results for a Try again — see Saved tool results.

Interrupted answer (interrupted_class)

When a turn had already delivered visible text (or a file) and then its final model call failed with a provider error — typically a preamble, a tool round, then the model call after the tool failed — the partial answer is persisted as a normal answer with interrupted_class = the typed failure code (the same vocabulary and sanitization as error_class, e.g. provider_error, request_timeout, or a policy code). The web chat renders the received text plus a The answer stopped early notice with the failure's localized reason and, for a retryable code, a Continue button and a Start the answer again button — live and after a reload alike. It is a real answer, not a failure row: a later failed retry does not delete it, and a successful regenerate supersedes it like any answer. A forked conversation copies the field. A truncated or read-error partial keeps the in-text interrupted note instead and carries no interrupted_class. If the model call died (a provider error, a read error, or a cut-off stream) while a write_file or edit_file call that the gateway runs was still streaming its arguments, the unfinished file text is kept in the answer as a block headed "Unfinished file <name> (not saved)" (for edit_file: "Unfinished change to <name> (not saved)"), on the live stream and in the saved message alike. No file is created or changed. A request with stream: false is unchanged by this (except that a turn whose client already left still saves the block). A tool of the same name that your own client supplies is yours: the gateway writes no such block for it. A buffered attempt keeps the block too and is not retried automatically. The field is null/omitted on every clean answer and on a failure row (which carries error_class instead). One value is a notice, not a failure: wallet_shortened — the answer is complete as far as it goes but was cut at the output length the workspace's prepaid wallet could pay (see Budgets — Wallet). It is set on an otherwise clean turn (never over a failure, which always wins), also when the turn's own shortened answer is empty (an empty answer that merely followed a shortened delegated sub-agent saves no message); the web chat shows an Answer shortened notice instead of The answer stopped early, with no Start the answer again. A second notice value, wallet_shortened_reserved, means the same cut happened because other requests of the workspace that were still running held the balance (the balance itself would have paid): the remedy is to try again in a moment, not to top up.

Rejected-key provider (error_provider)

A failure row whose error_class is provider_key_rejected (the provider rejected the customer's own key, see Error codes) also carries error_provider: the provider id, a string matching ^[a-z0-9][a-z0-9_-]{0,31}$ (for example anthropic). The web chat uses it to name the provider ("Your Anthropic key was rejected ...") after a reload exactly as it does live. The field is null on every other row, on a row written before this field existed, and after a regenerate resets the row. A value that does not match the pattern is stored as null, and a client must ignore a non-matching value and show the sentence without a provider name. A forked conversation copies the field. The field is part of the message object in GET /admin/v1/conversations/{id}; a shared reader of the conversation sees it too, like error_class and model on the same row (it names only the provider, never the key).

No file was created (file_claim_badge)

When an answer says a file was created or changed in its turn but the turn produced none — the gateway's file-claim check decides, after its one automatic retry when the user had asked for a change — the answer is persisted with file_claim_badge: "no_file". The web chat shows No file was created. under the answer with a Create it now button (on the latest answer, for a user who can regenerate it). The same value is named on the turn's turn_committed frame, so the note looks the same live, after a reload, in a forked conversation (the field is copied) and in a shared link (the recipient sees the note without the button; continuing a shared conversation starts a new conversation without it). The field is null on every other answer — answers from before this check are never marked retroactively — and the only value ever written is "no_file"; the app ignores anything else.

Create it now regenerates the answer with x-aig-regen-reason: fileNotCreated (stored as regen_reason, shown as the chip "Adjusted · file requested"). The gateway acts on it only when the regenerated answer's stored file_claim_badge is "no_file" (read on the server, scoped to the conversation and its tenant): that turn is then offered only the file tools (write_file, edit_file, read_file) and, where the provider supports it, must call one — except when the badged answer was a "change this file and give it back" turn: then the click gets that turn's own offer back (edit_file and read_file only, not forced). Without a stored note (or when the turn offers no file tool) it is an ordinary regenerate with that steer. As with any regenerate, the new answer replaces the old one for the conversation owner; for another member of a shared project conversation it is appended. If the regenerated answer again produces no file, it carries the note again.

Image not produced (image_claim_badge)

When an answer says an image was generated, edited or is shown but the turn produced none, and the gateway's image-claim check judged that claim, the answer is persisted with image_claim_badge: "no_image". The same value is named on the turn's turn_committed frame. The web chat shows The assistant referred to an image, but none was produced. under the answer from this record alone, so the notice looks the same live, after a reload and in a forked conversation (the field is copied). A shared link does not carry it. The field is null on every other answer, answers from before this check are never marked retroactively, the only value ever written is "no_image", and the app ignores anything else. An answer carries at most one of file_claim_badge and image_claim_badge. Private (ghost) chats are not checked and show no notice. The notice has no button: ask again for the image.

Saved tool results (resume on Try again)

When a conversation turn fails or is interrupted after its server-side tools ran, the gateway saves what the failed model call was sent after the conversation prefix — the assistant tool-call turn(s) and the tool results (already PII-masked as the model saw them) plus only the PII token mappings those results need — encrypted at rest with the platform master key. A regenerate of that turn (Try again on the failure bubble, Start the answer again on the interrupted notice, or Regenerate without a steering reason) re-runs only the model call from these results, so no tool — e-mail, file writes, connector actions — executes twice. When they cannot be used, the turn re-runs its tools and says so explicitly. Wire contract (X-AIG-Tool-Resume, tool_results_resumed / tool_resume_unavailable): see Inference › Resuming from saved tool results.

Storage and retention:

  • One record per conversation (table chat_tool_resume); a newer failure replaces it.
  • Resumable for 24 h, enforced at read and by the hourly reaper; after that only a non-content tombstone remains (it lets a later regenerate warn that the tools run again), deleted after 30 days — a regenerate after that re-runs the tools without the warning.
  • Used once: when a regenerate answers from them, the saved content is removed at once and only the non-content tombstone remains, so a second Try again (for example in another tab) re-runs the tools with the warning.
  • Deleted with the conversation (delete or retention), the user (erasure) and the tenant; repeating a conversation delete retries a failed removal. Deleting any message of the conversation removes the saved content (a save racing that delete by milliseconds is bounded by the 24 h expiry).
  • Never copied to the public beta.
  • Only the user who ran the tools, in the same tenant and conversation, can resume them, and only under the same PII configuration (detectors, keywords, mandatory masking) the results were masked under — otherwise the tools run again, with the warning.

Attachments

POST /admin/v1/conversations/<CID>/attachments — upload a file. The body is JSON. Who may upload is the same as who may send the message it belongs to: the conversation's owner, or the live co-driver who holds the driver lease (404 conversation_not_found, 403 forbidden for a read-only member, 403 live_not_driver while someone else drives — the codes of POST …/messages). On top of that, a file is attached only to a message the caller wrote: every user message records who sent it (created_by, the session user of POST …/messages), and the attachment is stored only when that author is the caller — checked in the same database statement that stores it. Someone else's message — the owner's for a co-driver, a co-driver's for the owner — is 403 { "code": "not_message_author" } and nothing is stored. A message with no recorded author — written before authors were recorded, by a server-side path or a copied conversation, or whose author's account was erased — is attached to by nobody, the owner included: 403 { "code": "message_author_unknown" }, nothing stored (send the files with a new message). A co-driver may attach to any of their own messages, not only the newest. The refusal comes after the malware scan (one rule, in one place). Every attachment records who added it (created_by). created_by names who sent the message, not who last changed its text (the owner may edit or correct messages of their conversation). While author recording is rolled out, a message saved by a node from before it has no author, so an upload to it is refused — the web app says the file was not saved and asks to send it again with a new message, which stores both. The web app uploads a message's files right after saving the message and before the answer starts; the image tools read a saved turn's pictures from that message and these files (see Inference → The turn's images).

An image over 10 MB (a declared image/* type, or PNG / JPEG / GIF / WebP bytes under any declared type) is refused with 413 { "code": "image_too_large", "max_bytes": 10485760, "error": … } before the conversation lookup, the malware scan and the store (the same answer as the text extraction). Bodies over this route's request limit (140 MB on the wire, about 110 MB of file) are refused earlier by the ingress with 413 { "error": "payload_too_large" }. The web app stores the shrunken copy of a large photo (see Chat → Attachments).

A suspended tenant (tenancy switch on) is refused 403 tenant_suspended, for a platform administrator too, before any malware scan, OCR or Files-API upload. A present but malformed suspension marker is refused like a suspension. When the gateway configuration cannot be read, the state is read fresh from the gateway's workspace: suspended answers 403 tenant_suspended, a conversation whose gateway or workspace has since been deleted (also a soft delete) answers 404 tenant_gone (not retryable: sent with x-should-retry: false and no Retry-After), a read that fails answers 503 service_unavailable (retryable), and an active workspace proceeds. See Suspended tenants.

The JSON envelope of this upload route may hold at most 32,768 JSON values (structural elements); a denser body is refused 413 body_too_complex before it is parsed. The base64 file itself is one string and does not count against it.

Field Type Required Description
message_id string yes The message the attachment belongs to (a non-string is rejected 400, code: "invalid_body"). Must be a live user message of the conversation in the path; a message_id from another conversation, an assistant message or a deleted message returns 404.
filename string yes Original file name, at most 255 characters of valid UTF-8. A non-string or invalid UTF-8 value is rejected 400 code: "invalid_filename", a longer name filename_too_long — all before the conversation lookup.
mime_type string yes MIME type of the file, as a media type (type/subtype, optional parameters). It is stored and served back as the attachment's type. Absent or "" is rejected 400 (required); a value that is not a media type — a non-string such as a number, object or null, a control character, surrounding whitespace, a non-ASCII character, no /, a malformed parameter — is rejected 400, code: "type_malformed_declared", before the conversation lookup; an otherwise well-formed type of 129–1024 bytes is rejected 400 code: "mime_type_too_long" (longer is type_malformed_declared).
data string yes File bytes, base64-encoded (standard alphabet, no line breaks). Validated fail-closed before anything is read or stored: a non-string value (null, object, boolean, number) or an empty string is rejected 400, code: "invalid_body"; a string that does not decode as base64 (an embedded newline is enough) is rejected 400, code: "bad_base64". Nothing that fails to decode is ever persisted — there is no "opaque text" attachment (such a body used to skip the malware scan and be stored verbatim). Both rejections are answered before the conversation lookup.

Size — one limit of 110 MB, enforced here, never a 500. A file is at most 110 MB (110,000,000 raw bytes; the same limit as POST /chat/files, served to the web app as limits.chat_upload_max_bytes on GET /admin/auth/me). The base64 data is stored inline up to the database single-packet size and split across chat_attachment_chunk rows above it; downloads reassemble it and fail closed (500) if a chunk is missing, never serving truncated bytes. Three refusals, all 413, nothing persisted:

  • code: "attachment_too_large" with max_bytes: 110000000 — the decoded file is over the limit. Answered by the handler before the image check, the write gate and the malware scan.
  • code: "body_too_complex" — the JSON envelope holds more than 32,768 JSON values (structural elements); checked before the body is parsed, so it is answered ahead of malformed_body. Nothing is stored.
  • { "error": "payload_too_large" } (no code field) — the request body is over this route's edge cap (140 MB). Answered by nginx, before the handler runs.
  • code: "scan_limit_exceeded" — on a gateway with malware scanning, the scanner reported a size limit exceeded; the file is not treated as clean (see Malware scanning). Retrying cannot help, so there is no Retry-After.

A read-only viewer is refused first (403 viewer_read_only), and an impersonation session is refused. An absent or empty message_id, filename or mime_type is 400 message_id, filename, and mime_type are required. On a gateway with malware scanning enabled, an infected file is 422 malware_detected and an unreachable scanner 503 scan_unavailable; nothing is stored. A message_id that is not a live user message of this conversation is 404. Success is 201 { "id", "message_id", "filename", "mime_type", "size_bytes" } (size_bytes is the length of the base64 data).

A suspended tenant (tenancy switch on) is refused 403 tenant_suspended, for a platform administrator too, before any malware scan or storage; nothing is stored. A present but malformed suspension marker is refused like a suspension. When the gateway configuration cannot be read, the state is read fresh from the gateway's workspace: suspended answers 403 tenant_suspended, a conversation whose gateway or workspace has since been deleted (also a soft delete) answers 404 tenant_gone (not retryable: sent with x-should-retry: false and no Retry-After), a read that fails answers 503 service_unavailable (retryable), and an active workspace proceeds. See Suspended tenants.

This is a different endpoint from the /chat/files staging upload under File staging; both share the same 110 MB file limit.

GET /admin/v1/attachments/<AID> — download an attachment. Returns { "id", "message_id", "filename", "mime_type", "size_bytes", "data", "created_at" }, data base64-encoded. Who may download:

  • the conversation's owner — every attachment of their conversation;
  • the attachment's author (who added it, created_by — for example a live co-driver who attached a file to their own message in the owner's conversation), while the message is not deleted and they can still read the conversation (it is shared into a project they have access to — the same read access as GET /admin/v1/conversations/<ID>). An attachment with no recorded author (added before authors were recorded, copied by a fork, or whose author's account was erased) is downloadable by the owner only.

Anyone else, an unknown id, a co-driver who lost access to the project or whose message was trimmed, a conversation that is no longer shared, or a deleted conversation (for the author) → 404 { "error": "not_found" } (the same answer — no existence leak). A database error → 503 (retryable). The image tools and the "Use this image" card still read attachment files for the owner only.

In a project member's view of someone else's conversation (GET /admin/v1/conversations/<ID> as a shared reader), every attachment carries can_download (boolean): true for a file that member added themselves, false otherwise (the download above would answer 404). The web app shows a download action on the file chip (a PDF opens the preview, which carries the download) only where it is true or the field is absent (owner view); it saves the file under its filename as a generic binary (application/octet-stream), never as the uploader-declared mime_type. The owner's view carries no can_download (the owner downloads every file); the author's id is never included.

DELETE /admin/v1/attachments/<AID> — delete an attachment. Owner only (the author of an attachment in someone else's conversation cannot delete it); anyone else's request deletes nothing. The answer is 200 { "ok": true } in both cases; a database fault is 500 { "error": "internal error", "request_id": "…" } (the delete may or may not have landed; repeating it is harmless).

GET /admin/v1/conversations/<CID>/images/<IID> — fetch the bytes of a generated image in the conversation. Returns { "id", "mime_type", "size", "data", "seed", "source_sha256", "sent_sha256", "num_inference_steps", "guidance_scale" }, where data is the image bytes base64-encoded (the SPA builds a data: URL). The fields after data are the image's reproducibility record; each is null when not recorded. seed is the seed sent to the image service (an integer, 0 to 4294967295). source_sha256 and sent_sha256 are set for an edit only: the lowercase-hex SHA-256 of the source image as the gateway received it, and of the re-encoded bytes it sent to the image model (see Reproducible images). num_inference_steps (integer 1 to 50) and guidance_scale (number 0 to 20) are the settings sent to the image service; null means the assistant did not send that setting (the service default applied) or the image predates the record, and guidance_scale 0 is a real value. A shared reader already sees both images, so the hashes disclose nothing new. Readable by anyone who can view the conversation — the owner or a member of the project it is shared into (the same read access as GET /admin/v1/conversations/<ID>); a shared reader sees the image rendered inline and can fetch its bytes. The image id is still scoped to the conversation, so an image id that does not belong to the conversation returns 404. A conversation the caller cannot see also returns 404 (no existence leak); a database error on the access check returns 503 (retryable), never a misleading 404.

GET /admin/v1/conversations/<CID>/videos/<VID> — stream the bytes of a generated video in the conversation. Unlike the image endpoint, the bytes are not returned as base64 JSON: the response body is the raw video, served with HTTP Range support so a <video> element can seek. The Content-Type is the stored, server-pinned type (currently video/mp4 only; any other stored type is served as application/octet-stream) and the response always carries Accept-Ranges: bytes and X-Content-Type-Options: nosniff.

  • Authorization is identical to the image endpoint — readable by the conversation owner and by members of a project the conversation is shared into (project-feed shared readers); it scopes on both the conversation and the video id within it. The audio endpoint (/audio/<AID>) uses the same rule. A conversation the caller cannot see returns 404; a database error on the access check returns 503 (retryable); impersonation sessions are blocked. A video id that does not belong to the conversation, or a conversation the caller cannot see, returns 404 (no existence leak, no bare-id IDOR).
  • Not-ready / absent bytes: a video whose row is not yet ready (its asynchronous save has not completed or failed), or whose stored bytes are missing, returns 404.
  • Range handling (RFC 7233): a request with no Range header streams the whole video with 200. A valid single range (bytes=START-END, the open-ended bytes=START-, or the suffix bytes=-N) returns 206 Partial Content with Content-Range/Content-Length, with END clamped to the last byte. A malformed or unparsable Range (including a multi-range bytes=0-1,2-3 and a repeated Range header) is ignored and the full video is returned with 200 — a bad range never yields more than the full resource. A well-formed range wholly past the end of the file (START ≥ size, or a zero-length suffix bytes=-0) returns 416 Range Not Satisfiable with Content-Range: bytes */<size>.

  • Download (?download=1). With the query parameter download equal to exactly 1, the response also carries Content-Disposition: attachment; filename="video-<first 8 characters of the video id>.mp4" (.bin if the stored type is not an allowed video type), so the browser saves the file (the web app uses this; a cross-origin <a download> is ignored, and in production the API host is a different origin than the app). Any other value, a repeated parameter, a valueless ?download or no parameter → the video is served inline as before. The file name is built from the stored, server-minted id (hex digits and dashes), never from the URL.

Generated videos

Each message in a conversation response carries a videos array (empty when none), one entry per video the create_video tool started:

Field Type Notes
id string Video id, used in the routes below.
mime_type string video/mp4.
size_bytes number 0 while pending.
duration_ms number | null Requested length in milliseconds when known.
status string pending (job running, no bytes yet), ready, or failed.
params object | absent The stored generation settings (prompt, negative_prompt, model, seconds, size, fps, seed, audio, image, hd_size where known; start_image — the id of the chat image an animated clip started from, dropped in a forked conversation — and seq, the clip's position among its reply's clips), used by the one-click actions and the carousel order. Absent for clips created before the settings were recorded.

Generation is asynchronous, so a message first lists the video as pending; the gateway moves it to ready or failed in the background (see Video generation). A turn that produced only a video still persists as a message.

GET /admin/v1/conversations/<CID>/videos/<VID>/status -- cheap status poll, used by the web app every 5 seconds while a video is pending. Response 200: { "status": "pending" | "ready" | "failed", "size_bytes": <number>, "duration_ms": <number|null>, "params": {...} } (params for every row, as in the table above). For a pending row the gateway also asks the video backend live and adds progress (integer 0-100), queue_position (integer >= 0; 0 = running, N = jobs ahead), eta_seconds (integer >= 0) and phase (queued or in_progress). Each is omitted when the backend does not report it, reports a value that is not an in-range integer, or is unreachable (the response is still 200); nothing is stored. Authorization is the same as the serve route. A video id that is unknown or belongs to another conversation returns 404 (no existence leak); a database error returns 503 (retryable).

GET /admin/v1/conversations/<CID>/videos/<VID> (above) serves the bytes with Range support once the status is ready; before that (pending or failed) it returns 404.

GET /admin/v1/conversations/<CID>/videos/<VID>/poster -- the start image of a pending image-to-video clip, proxied from the video backend (which keeps it only while the job is active; the gateway never stores it). Same read authorization as the serve route. Response 200 with Content-Type: image/png, X-Content-Type-Options: nosniff and Cache-Control: private, max-age=60. Returns 404 when the clip is not pending, did not start from an image, or the backend has no preview (job finished or gone); 404 for an unknown or foreign id; 502 when the backend returns something that is not a PNG; 503 on a database error. The bytes are untrusted: they are capped at 10 MiB and checked for the PNG signature.

POST /admin/v1/conversations/<CID>/videos/<VID>/cancel -- cancel a pending video. No body. Only the conversation owner may cancel:

Caller Result
Shared reader 403
Non-member / unknown conversation or video 404
Read-only viewer, or an impersonation session blocked
Owner, video pending 200 { "status": "failed" }
Owner, video already ready or failed (including finishing while the request runs) 409
Video backend unreachable or erroring, or the video's row cannot be read 503; the row is left untouched, so the call can be retried
Marking the row failed hits a database fault 500 { "error": "internal error", "request_id": "…" } — the cancel may or may not have landed; a retry answers 409 if it did

A forked conversation can share one backend job with the original. Cancelling then fails only the caller's own row and leaves the backend job running for the other copy; the backend job is stopped only when no other pending row uses it.


Generated files (code interpreter)

When the code-interpreter tool produces a downloadable file, the gateway persists it into the conversation's (or project's) file space and the SPA renders it as a file card. Text files (csv/txt/json, and an HTML page or deck — html/htm) carry their content inline; a binary document — Excel .xlsx, Word .docx, PowerPoint .pptx, .pdf, or OpenDocument .odt/.ods/.odp — stores its bytes and is fetched from a dedicated download route. A text output that carries an aig-elided-… placeholder (the shortened form in which read_file shows a file's large embedded fonts and images) is not persisted and not delivered — the program is told which outputs were refused and why; see Embedded resources in HTML and SVG files.

GET /admin/v1/conversations/<CID>/knowledge/<KID>

Returns the artifact's stored row as JSON (the metadata the SPA renders as a file card — for a text file, the inline content). Authorization is scoped to the caller's own conversation: a <CID> the caller does not own returns 404, a storage fault returns 503 { "error": "temporarily unavailable; retry later" }, and a <KID> that does not belong to <CID> returns 404.

On a PII-masking gateway, a generated text file (csv/txt/json/html/htm) has its reversible masked values restored for the authorized reader on this metadata read — the restore is applied when the artifact is persisted, so this route returns the stored, already-unmasked text, matching the same unmask the gateway applies to a chat message it shows that user. Irreversible custom-keyword redactions ([MYRA-CUSTOM:…]) stay masked, and binary artifacts (.xlsx/.docx/.pptx/.pdf/.od*) are never rewritten — the /download route below serves their raw bytes unchanged (and a text-only entry, which has no stored blob, 404s there).

The row carries version (a number): the file's current version, which an in-place save sends back as base_version.

Saving a conversation file in place

PUT /admin/v1/conversations/<CID>/knowledge/<KID>

The artifact panel's save of a file it opened: rewrites the text of the existing file <KID> (never creates one). Authorization as for the GET (the caller's own conversation; a viewer is refused with viewer_read_only). Body: extracted_text (required — UTF-8, at most 7.5 MB, no NUL byte), content_type (absent / null keeps the file's own; otherwise at most 128 characters, no image/* other than image/svg+xml) and base_version (optional integer — the file version the edit was based on). Only a text file can be rewritten (a binary-backed one → 409 not_editable, checked first). The text is the user's own and is stored as sent: unlike a chat tool's store, this save is not checked for aig-elided-… placeholders (see Embedded resources in HTML and SVG files).

With base_version the write happens only while the file is still at that version; a file that changed meanwhile (for example a model edit_file in a later turn) answers 409 { "code": "version_conflict", "current_version": <n> } and nothing is written — saving again with base_version: <current_version> replaces that version deliberately. Without base_version the write is unconditional. A present base_version that is not a positive integer (string, fraction, 0, negative, null, boolean, object) is 400 invalid_base_version, never treated as absent. 200 answers the row as this write left it (its text, content_type and the version this write produced); an unknown <KID> is 404. A failed read before the write (the conversation or the file) is 503 { "error": "temporarily unavailable; retry later" }; a failed write is the sanitised 500 { "error": "internal error", "request_id": "…" } — it may have landed, so re-read the file before saving again.

GET /admin/v1/conversations/<CID>/knowledge/<KID>/download

Returns the raw bytes of a generated binary file (an .xlsx/.docx/.pptx/.pdf/ .odt/.ods/.odp produced by the code interpreter) with the gateway-pinned content_type as the Content-Type, falling back to application/octet-stream when the entry has none, a sanitized Content-Disposition attachment filename (quotes, semicolons, CR/LF, control and invisible format characters are removed, / and \ are replaced by _, an invalid UTF-8 byte becomes U+FFFD, a leading dot is kept; the header carries an ASCII filename="…" fallback and the exact name as filename*=UTF-8''…, RFC 6266 / RFC 5987; Unicode spaces inside the name (for example NBSP) become ASCII spaces; in the ASCII filename= fallback every non-ASCII character and every % becomes _; a name that is empty or made only of dots and spaces is replaced by the default name file, and so is a name longer than 255 bytes after cleaning), and X-Content-Type-Options: nosniff (the bytes are never MIME-sniffed). Authorization is scoped to the caller's own conversation: a <CID> the caller does not own returns 403/404, and a <KID> that does not belong to <CID> returns 404 (no cross-conversation or cross-tenant access). The gate is blob existence — an entry with no stored bytes returns 404; a storage fault returns 503 { "error": "temporarily unavailable; retry later" }.

?inline=1 returns a PDF entry for an in-page preview frame (Content-Disposition: inline, same filename form, Content-Type: application/pdf, nosniff) — exactly as on the project route: only bytes that are a PDF (415 inline_not_pdf otherwise), and any other inline value is 400 bad_param.

What is accepted as a generated file (untrusted runner output, validated fail-closed). The runner's artifacts[] are hostile until validated; the declared MIME is advisory and never trusted — the served MIME is pinned by the gateway from the validated kind/extension. An artifact is dropped (its bytes never surface, counted in artifacts_rejected) unless it is one of:

  • a real PNG (admitted by magic, filename-independent);
  • a valid text data file — csv/txt (valid UTF-8, no NUL) or json (parses);
  • an HTML page or deck — html/htm, when the code-execution runner returns one (valid UTF-8, no NUL; at most 8 MiB, the HTML converter's input limit — over it the file is not delivered; a stored file is measured once more after masked values are restored). It is stored as a text conversation file exactly like a write_file .html: the chat shows it only inside the sandboxed preview frame (opaque origin, the preview CSP — no network), it converts to PDF / PowerPoint / Word, and no route serves it as text/html in the gateway's origin. In a turn that stores nothing (private chat) it is delivered live as text/plain under its .html name (download only);
  • an OOXML document — .xlsx/.docx/.pptx — whose bytes are a ZIP (PK\x03\x04) with a [Content_Types].xml part and the extension's REQUIRED subtree (xl/ for xlsx, word/ for docx, ppt/ for pptx), keyed off the sanitized extension. It is then checked against the Office Open XML schema by a bounded checker that runs on the gateway host in a separate helper process (not inside the code sandbox): every XML part of the package (including .rels parts and parts of unknown namespaces) must be well-formed, and the parts with a known schema are validated. Withheld — not delivered, no file card and no download — are: any file with a part that is not well-formed XML or is not a readable package; any element that appears twice where the schema allows one; for .pptx, an element out of order or missing (except in charts); for .xlsx, an element out of order or missing in the workbook, styles, shared-strings, worksheet and table parts; for .docx, only the first two kinds (Word tolerates misordered children). The model receives a note naming the part so it can correct its generating code. Everything else (an unusual value, an attribute error, a fault already present in a document loaded into the run (or that cannot be told apart from one because the loaded document could not be checked in full), a file the checker cannot read or finish within its limits) delivers the file as before. This reduces the chance of Office's "repair" prompt; it does not rule it out;
  • a PDF (.pdf) whose bytes begin with %PDF- at offset 0;
  • an OpenDocument — .odt/.ods/.odp — whose bytes are a ZIP whose first member is mimetype (name at offset 30) and which carries META-INF/manifest.xml (the manifest excludes an EPUB, which also has mimetype@30); the gate is compression-independent and the served MIME is keyed off the extension.

The gateway worker itself never parses or inflates the bytes (no in-process XXE/zip-bomb; a generated blob skips async text extraction); the Office schema check above runs in a separate gateway-side python3 helper process with an address-space limit and time and size budgets, with parser entity expansion and network fetching disabled, and fails open. A wrong-magic file, a mislabeled container (e.g. a .docx zip named .xlsx, an OOXML zip named .odt, an EPUB named .odt), a %PDF- not at offset 0, an oversized file (over the per-artifact cap — 25 MiB, the default and the ceiling of code_interpreter_artifact_max_bytes, see tenants), an over-aggregate (25 MiB per run) or an over-count (> 4) set is rejected. Within the count and size budgets, files are admitted in a fixed order: every non-HTML file first (in the order the program wrote them), then HTML files — so side pages a program writes (charts, previews) never push out the data or office file it produced. Re-running the same generating turn (a new reply) creates a numbered copy (report-2.docx) rather than overwriting, and never fails with a duplicate-key error. Within ONE reply it is different: when a later code_interpreter call of the same reply delivers the same name, kind and type again (the assistant fixed and re-ran its program), the reply's own earlier file is replaced in place — same file row and id, latest content, still one card, and no extra file budget is spent. Only files this reply created are replaced; a file from an earlier reply or an upload keeps the numbered-copy rule, with one exception: a file the assistant generated earlier (text, or an office / PDF file whose output type equals the stored type) that the program loaded as an input is updated in place — same row and id, new version — when written back under its stored name. An upload is never overwritten. A concurrent change to the file during the replacement (or a deleted file) is not overwritten: the other write is kept intact and the new output is stored as a new numbered file (name-2.ext).


Chat commands

GET /admin/v1/chat-commands

POST /admin/v1/chat-commands

PATCH /admin/v1/chat-commands/<ID>

DELETE /admin/v1/chat-commands/<ID>

A chat command is a saved prompt template that the user can invoke from the Chat view with a slash command. Commands are per-user: every endpoint is scoped to the calling user, so one user can never read, edit, or search another user's commands.

Request body (JSON) for POST / PATCH:

Field Type Required Description
name string yes (POST) The slash-command name. Empty or blank is refused like "".
template string yes (POST) The prompt template; {{variable}} placeholders are substituted at invoke time. Empty or blank (nothing visible) is refused like "".
description string no Short description shown in the command picker.
category string | null no Optional user-chosen category for grouping/filtering. Accepted: a string of at most 64 characters (Unicode codepoints, not bytes — trimmed of surrounding whitespace). An empty/whitespace string or JSON null clears the category ("uncategorized"). Rejected with 400: a non-string value (number, boolean, object, array), a value longer than 64 characters, or malformed UTF-8. On PATCH, omitting category leaves it unchanged; sending null clears it.

Responses: POST → 201 { "id" }; PATCH and DELETE → 200 { "ok": true }. PATCH and DELETE are owner-only: a command that is not the caller's own (also one shared with them) or an unknown id is 404 command not found (code command_not_found). A category rejection is 400 with code invalid_category (non-string or malformed UTF-8) or category_too_long. The name, template and description rejections carry name_required / template_required (absent, empty or blank on create; description is optional and never _required), invalid_<field> (wrong type, null on create, "" or blank on an edit of name/template, or malformed UTF-8) or <field>_too_long. Every chat-command route refuses an impersonation session.

A failed write on PATCH answers the sanitised 500 { "error": "internal error", "request_id": "…" } — never the database's own error text; a transient conflict that outlasted the bounded retry is 503 (send it again), and a fault in the ownership check keeps its 503.

POST and PATCH retry the rare InnoDB full-text id ordering conflict (errno 182, "Invalid InnoDB FTS Doc ID", raised when two concurrent writers reach the full-text index out of order). The server re-runs the whole write, up to 4 attempts in all; if it still fails, the answer is 503 { "error": "temporarily unavailable; retry later" } with nothing written — send the same request again. A write is never silently dropped.

Full-text search — POST /admin/v1/chat-commands/search with the JSON body {"q": "<query>"}

Returns only the caller's own commands whose name, description, or template match the query (MariaDB InnoDB FULLTEXT, BOOLEAN mode). The query travels in the body — never in the URL, because the web server writes request lines into its error log. The query is escaped at the trust boundary: it is split into word tokens, each ≥ 3 bytes is quoted as a literal phrase (neutralizing every BOOLEAN-mode operator: + - * " ( ) ~ < > @), and at most 16 tokens are used. A non-empty query that tokenizes to nothing (only whitespace or sub-3-character tokens) or matches nothing returns an empty array [] (never an error). An absent or empty q → 400 q_required; a q that is not a string, not valid UTF-8 or longer than 1024 characters → 400 invalid_q; a body that is not a JSON object → 400 malformed_body.

Deprecated: GET /admin/v1/chat-commands?q=<query> runs the same search until 11 January 2027 with Deprecation / Sunset headers. Without q (or with ?q=) it is the plain list, unchanged and not deprecated. A repeated q param or a bare ?q (no value) is now 400 invalid_q — it used to return the full, unfiltered list. See Search and lookup values travel in the request body.

Version history and restore

GET /admin/v1/chat-commands/<ID>/versions

GET /admin/v1/chat-commands/<ID>/versions/<VERSION>

POST /admin/v1/chat-commands/<ID>/versions/<VERSION>/restore

Accepted / rejected input (validated before anything is written; each rejection is 400 with a machine-readable code):

Field POST PATCH Rejected
name required, non-empty optional; absent or null = unchanged absent/empty on create → name_required; null (create), not a string, "" (edit) or malformed UTF-8 → invalid_name; more than 64 characters (Unicode codepoints, not bytes) → name_too_long (the sentence for absent, null, "" is name is required throughout; branch on code)
template required, non-empty optional; absent or null = unchanged absent/empty on create → template_required; null (create), not a string, "" (edit) or malformed UTF-8 → invalid_template; more than 65535 bytes → template_too_long (the sentence for absent, null, "" is template is required throughout)
description optional; absent or null = "" optional; absent or null = unchanged; "" clears it not a string or malformed UTF-8 → invalid_description; more than 255 characters → description_too_long

Write failures. Create, edit, restore and share each run as one database transaction that the gateway re-runs on a transient conflict (a deadlock, or on a multi-site database a write conflict reported at commit); a re-run writes the change exactly once. If every bounded attempt conflicts — or a row lock could not be obtained in time — nothing is written and the route answers 503 (temporarily unavailable; retry later): retry the same request. Any other database failure is 500 {"error": "internal error", "request_id": "…"} — the database's own error text is logged, never returned. DELETE answers a database failure with the same sanitised 500.

Every create or edit stores an immutable snapshot (name, description, category, template) as a new version, and the command carries a monotonic version counter. The list endpoint returns the caller's own version snapshots newest-first; the single-version endpoint returns one snapshot. These endpoints are owner-only: a command that is not the caller's own reads as 404 (a 404, not a 403, so one user cannot probe another user's command ids), and an empty history likewise returns 404 (every command has at least one version).

The <VERSION> path segment is validated at the trust boundary: it must be a positive integer written canonically: decimal digits only, no leading zero, sign, whitespace, exponent, hex or fraction; at most 10 digits; 1..2147483647. Rejected with 400 invalid version (code invalid_version): anything else — 01, 0x1, 1e0, +1, 1.0, a padded or non-numeric value, NaN/±inf, zero/negative, or out-of-range (so a hostile value never reaches SQL). A well-formed version that does not exist for the command returns 404 version not found (code version_not_found). A transient database fault returns 503.

Restore is owner-only too (a command that is not the caller's own is 404 version not found, code version_not_found) and answers 200 { "ok": true }. Restore is non-destructive: it re-applies the chosen snapshot through the normal update path, minting a new version whose content equals the restored one — no history is overwritten. A null snapshot category is faithfully restored to SQL NULL (not left at the current value).

Sharing with selected users

PUT /admin/v1/chat-commands/<ID>/shares

GET /admin/v1/chat-commands/<ID>/shares

An owner can share a personal prompt with individually selected users and with user groups in their own tenant. A shared prompt appears in each target's GET /chat-commands (and search) list read-only: the response carries an owned field (1 = the caller's own → editable/restorable/shareable/deletable; 0 = shared with them → read-only). Sharing never grants edit, restore, delete, or re-share to the recipient.

Both endpoints are owner-only. GET .../shares returns { "users": [{ "id", "email", "name" }], "groups": [{ "group_id", "group_name" }] }; a command that is not the caller's own returns 404. PUT .../shares replaces the whole share set atomically.

Request body (JSON) for PUT:

Field Type Required Description
user_ids array of strings yes The users to share with. Rejected with 400: a non-array value or a JSON object (user_ids must be an array; code user_ids_required when the key is absent, invalid_user_ids otherwise), an element that is not an id string — a non-string, empty, whitespace-only or over-64-byte value (user_ids entries must be id strings, invalid_user_ids; empty, whitespace-only and over-long strings were previously silently dropped), or more than 200 entries (too many users (max 200), too_many_user_ids).
group_ids array of strings no The user groups to share with; every member sees the prompt read-only. Absent leaves the current group shares untouched; [] removes them all. Rejected with 400: null, a non-array value or JSON object (group_ids must be an array, invalid_group_ids), more than 200 entries (too many groups (max 200), too_many_group_ids), or an element that is not a string, is empty or whitespace-only, or exceeds 64 bytes (group_ids entries must be id strings, invalid_group_ids). Unknown or other-tenant group ids are silently dropped (200). Adding a group that is not already shared requires the GROUPS_MANAGE permission (403 permission_required otherwise); removing groups does not. If a group was deleted meanwhile, reload the share dialog and retry.

Targets are resolved server-side against the owner's own tenant: an id that is unknown, belongs to another tenant, is soft-deleted, or is the owner themselves is silently dropped (not an error), and duplicates are de-duplicated. An empty user_ids array removes the user shares only (group shares are untouched unless group_ids is sent); a full un-share is {"user_ids": [], "group_ids": []}. Success is 200 { "ok": true }. A non-owner (or unknown command id) is rejected with 403 { "error": "forbidden", "code": "command_not_accessible" }. A transient database conflict answers 503, any other database failure the sanitised 500 (see Write failures above). The client is never the authz boundary — the server derives the owner's tenant and pins every target to it.

Tenant shared commands

GET /admin/v1/me/shared-commands

Returns the slash commands that an administrator has configured for the calling user's tenant (see Shared commands) as a JSON array. These are read-only for the member and are separate from the user's own chat commands above. A caller with no tenant (absent or null), a deleted tenant, a tenant with no shared commands, or an empty configuration receives an empty array []. A session whose tenant value is malformed (an empty string, a number, an object) is refused with 401 unauthenticated. A failed tenant read is 503; a stored configuration that is not a JSON array is the sanitised 500. An entry's id is optional (an administrator may save a list without ids); the chat's / menu gives an entry whose id is missing, not a non-empty string, already used by an earlier entry, or starts with the reserved builtin: / shared: prefixes its own shared:<position> id, so such an entry is listed as the tenant's command and can never stand in for a built-in such as /compact.


File staging

POST /admin/v1/chat/files — stage an uploaded file before it is attached to a conversation. The body carries the raw bytes base64-encoded; the response is either the extracted text or an Anthropic Files API file id, depending on the MIME type.

The JSON envelope of this upload route may hold at most 32,768 JSON values (structural elements); a denser body is refused 413 body_too_complex before it is parsed. The base64 file itself is one string and does not count against it.

Request body (JSON):

Field Type Required Description
data string yes File bytes, base64-encoded (a non-string is rejected 400, code: "invalid_body"; a string that does not decode as base64 400, code: "bad_base64").
filename string yes Original file name (a non-string is rejected 400, code: "invalid_body").
mime_type string no A hint only — absent or "" is fine, but a value that is present and not a media type (a non-string such as a number, object or null, a control character, surrounding whitespace, a non-ASCII character, no /, a malformed parameter) is rejected 400, code: "type_malformed_declared"; it is never treated as absent. The server dispatches on the filename extension (and, for a name with no decisive extension, the file's magic bytes); a generic or wrong client MIME (application/octet-stream for a .xlsx, application/vnd.ms-excel for a .csv, text/plain for a .csv/.tsv — a common Linux browser labeling) is reconciled to the correct path, so a mislabeled CSV still gets the charset ladder and the data-file handling. A .eml is dispatched as message/rfc822 whatever the client labels it (text/plain, application/octet-stream, or the client-specific application/x-eml / text/x-eml).
model string no The model the message will be sent to. Used only to lower the PDF page-image cap (below) to the model's picture limit; omitted, null or an unknown model means the ceiling of 20. "", a non-string, more than 256 bytes, or a byte outside 0x21–0x7E is refused with 400 invalid_model_id before anything is extracted (on every file type).
extract_text boolean no Ask for server-side text extraction of images, PDFs, and plain text. It is a hint, not a control: the server may extract regardless (see the privacy gate below; a gateway carrying the classified-markings preset is treated like a privacy gateway here, so images are OCR'd and the text is scanned for markings), and can never be used to force a file upload. Images are OCR'd by the on-prem vision model (see Image OCR below), never a raster egress to the customer's provider.
user_prompt string no The user's turn text for this send (e.g. "traduci esto"). Used only to make image OCR request-aware — it is appended inside a delimited context block, explicitly marked as the reader's request and not an instruction to the model, so the model extracts what the user needs without ever dropping text. Untrusted: the server codepoint-bounds it to 2000 (an oversized value is truncated; a non-string is ignored), collapses whitespace, and neutralizes the block delimiter. Absent/empty ⇒ plain verbatim OCR. Ignored for non-image uploads.
progress_id string no A canonical lowercase UUID (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) the client mints for this upload. While a scanned PDF is read page by page, the server publishes the page it is on under this id; read it with GET /admin/v1/chat/files/progress. Absent or null means no progress is tracked (nothing else changes). Any other value is refused 400, code: "invalid_progress_id" before anything is extracted.
gateway_id string yes The gateway this upload is staged against (a non-string — a number, boolean, object or null — is rejected 400 code: "invalid_body" before any lookup). It must belong to the caller's tenant — a gateway_id owned by another tenant (or one that does not exist) is rejected with 404 (the same answer as an unknown id) before any extraction or the privacy gate runs, so the endpoint cannot be used to probe a foreign gateway's privacy state or existence. The privacy gate below is evaluated from this gateway, and the provider key is resolved from it.

Response: { "text": ... } on an extraction path (with an optional warning when an image yields little text, and — for a .docx or a text-extracted PDF on a non-privacy gateway — an images array of its embedded images, or for a PDF the renders of its chart, table and figure pages; see below), or { "file_id": ... } on the provider Files API upload path. A caller that omits extract_text for a spreadsheet must handle either shape: the request returns file_id on a normal gateway and text on a privacy-protected one (below). The in-app composer always sends extract_text: true and consumes only the text shape — Anthropic's document content blocks accept only PDF and plaintext files, so a spreadsheet file_id cannot be referenced from a chat message and would fail the turn with 400. The upload path remains available to API callers with their own consumer for the staged file.

Files API response id. The file_id returned on the provider upload path is validated, because a gateway's provider_base_urls.anthropic override makes the Files API response tenant-controlled. It is accepted only as a non-empty string of at most 256 bytes made of ASCII letters, digits, _, -, . and :. Anything else (a number, object, array, boolean, null, an empty or over-long string, or other characters, or a response body that is not a JSON object with such an id) is answered 502 with files_api_bad_response, and no file_id is returned.

Residency and Tier-1 on the provider upload. A raw upload that would go to Anthropic's Files API refuses exactly where a chat turn to Anthropic on the same gateway would, with the same error code, before the provider key is read, a name is resolved or a byte is sent: 403 data_residency_blocked on a gateway with EU data residency enforced (a provider_base_urls.anthropic override does not lift it), 403 model_not_allowed_for_project on a Tier-1 (local-only) project, and the permanent 403 conversation_project_unresolved when the named conversation belongs to a project that no longer exists. If the project tier cannot be determined the answer is the retryable 503 project_tier_unresolved. A Tier-1 refusal (every code above except data_residency_blocked) is recorded as a blocked request like the same refusal of a chat turn: one request-log entry (leg_kind files_upload, blocked_by local_model_required, block_reason local_only, indeterminate or conv_project_unresolved, no tokens or cost) that counts in the compliance report, fires a gateway's blocked webhook (with an empty model) and reaches your SIEM as POLICY_BLOCK. The residency refusal is not logged. A file the server extracts to text inline (any extract_text upload the server extracts, a privacy-protected gateway) sends nothing to a provider and is never refused by these checks, and the on-prem image OCR path needs no such gate.

When the inline text is a data file (.csv, .tsv, .xlsx, .xlsm, .ods — never .pptx/.docx/plain text), the text leads with an authoritative facts directive — the exact row/column/sheet counts computed by the extractor over the complete file (never estimated from the inline preview), framed as an instruction the model must narrate when asked about the file's structure. The example rows follow, explicitly labelled a partial sample. This lets a weak local, tool-incapable, or private-mode model answer "how many rows?" correctly without eyeballing a truncated preview.

Source-code and plain-text files are accepted by EXTENSION, not by content. Roughly 55 code/config extensions — .py, .pyw, .ts, .tsx, .jsx, .js, .go, .rs, .rb, .php, .c/.h/.cpp, .java, .cs, .sh, .sql, .toml, .ini, .conf, .env, .log, and the like — route to the text/plain inline branch regardless of the client MIME. That branch performs no binary/NUL/UTF-8 check, so a genuine binary given one of these names (or a .txt name) inlines as garbage rather than being rejected — the same long-standing risk profile as .txt; a content-sniff gate that fail-closes on binary bytes is tracked as future hardening. (The .json branch, by contrast, validates UTF-8, and project-knowledge ingestion byte-sniffs its input — those paths differ, so the same file can be accepted here yet rejected as project knowledge.) Files with a dedicated branch — .csv/.tsv/.json/.md/.html/.xml/.yaml/.docx/.xlsx/… — keep their own handling.

The web app reads small text files in the browser and sends only over-size ones here. The chat composer inlines a plain-text, Markdown, HTML or source-code attachment of up to 512 KB in the browser without calling /chat/files. A larger text or source-code attachment (Markdown, HTML, plain text, code) is sent to this endpoint instead, so the server cuts it at the inline cap and reports truncated; the composer never infers the cut itself. It classifies every advertised extension by the extension (the browser's MIME label is a hint only: a .js labelled application/javascript, a .ts labelled video/mp2t are text), decodes it as UTF-16 (byte-order mark) or UTF-8. A file without any NUL is accepted as before, with no content check; a file that contains a NUL (a NUL byte, or a NUL character in a UTF-16 file — typically a preallocated or rotated NUL-padded .log) has every U+0000 removed and is refused as binary (error banner "not a text file"; nothing is sent) only when what remains still holds a disallowed control character (0x01–0x06, 0x0E–0x19, 0x1C–0x1F, 0x7F) or no visible character at all; the inline-versus-server split uses the size after the NULs are removed, and the text sent is always NUL-free. A UTF-16 file sent here is sent as its UTF-8 decoding, while the stored attachment keeps the original bytes. U+0000 is stripped from a long paste before it becomes an attachment. An unknown extension is still accepted only by an advertised MIME label and is otherwise refused before sending. The API branch above keeps its documented extension-only behaviour.

A staged .py/.pyw is additionally a runnable input: when code interpreter is enabled, the model may execute the attached script in the sandbox (read /input, write /output), under the same sandbox limits as any code it writes itself.

A Word .docx upload is extracted to structure-preserving GitHub-Flavored Markdown (headings, bullet/numbered lists, tables as pipe tables, bold/italic, hyperlinks, footnotes) rather than flattened to one line per paragraph — so a model reading the file sees which cell belongs to which row and column. The docx bytes are untrusted (accepted shape: a valid Word OPC zip; rejected: anything the extractor cannot read). Extraction runs the bytes through pandoc under a network-disabled sandbox, an address-space (memory) limit, and a wall-clock timeout; an external XML entity is never fetched (no file read / SSRF) and an entity-expansion bomb is capped — a document that trips these fails the rich path. Dangerous link schemes are neutralized: only http, https, and mailto links survive as links (a javascript:/data:/file: target is reduced to plain text), matching the renderer's own allowlist. An enormous document (beyond a size/complexity threshold, or one that exhausts the memory/time limit) gracefully degrades to flat text — complete content, unstructured — instead of failing; the request only errors if the document is unreadable by both paths. (Project-knowledge ingestion of the same .docx uses a separate segmenting extractor for citations, so its stored/preview text may differ from this one-shot chat/workflow read.)

A .docx upload additionally surfaces its embedded images (word/media/*) so a multimodal model can see the letterhead logo, signature, or figures — not only the text. On a non-privacy gateway the response carries an images array; each entry is { "mime", "b64" }, and the in-app composer attaches them to the user turn as inline image_url blocks tagged with the file name (they reach the model like a pasted image — they then inherit request-phase PII blocking, the vision-degrade for a non-vision target, and the per-turn image cap). Two count fields accompany it:

Field Type Meaning
images array The embedded images surfaced, each { "mime": "image/png"\|"image/jpeg", "b64": <base64> }. Always present on a non-privacy gateway (an empty array [] when the doc carries no usable image), and absent on a privacy gateway (below).
images_total number How many embedded image parts the document carries.
images_shown number How many are in images (i.e. survived validation and the caps). When images_shown < images_total the composer shows a notice that names the file ("The model sees N of the M pictures in …").

The embedded images are untrusted attacker-controlled bytes (the docx is a ZIP), validated fail-closed: the ZIP is read under a bounded, streaming reader with a memory limit and timeout (never a naive unzip — zip-bomb safe); each part's magic bytes are re-sniffed server-side (never a filename or declared type) and only PNG and JPEG are kept — an oversize-dimension image (over the safe-decode pixel ceiling) or a part whose bytes are not really an image is rejected; a vector SVG logo is rasterized to PNG server-side (via resvg, at a bounded width) and then re-sniffed like any other image, but only when it is fully self-contained — an SVG that references an external resource (<image>/<use>/CSS url() pointing at a file path or URL) is dropped, so it can never make the renderer read a host file; vector metafiles (EMF/WMF) and every other raster kind (GIF, TIFF, BMP, WebP) are dropped. The count of surfaced images is capped, and the aggregate is bounded to the inference host's wire budget (oldest dropped first to fit) so the resulting chat turn never exceeds the edge. A dropped image is reflected in images_total > images_shown (the notice), never a failed upload — the text extraction is independent and unaffected. On a privacy (PII-masking) gateway no images are produced at all (the response is text-only, no images field): a raster image cannot be masked, so it must never egress; this is fail-closed (an unreadable gateway config is treated as PII-active). block-level image metadata (the source filename) is used only for de-duplication and chip display — and a figure's filename marks it as document context, so it is never shown or exported as a user image — it is stripped before the request reaches the provider. These figure blocks are model context: the user's message bubble shows only the document's file card, not the pictures.

The facts also carry a column dictionary (schema card): for each column, its 1-indexed position, the header name, and its inferred type (number, boolean, or text); low-cardinality text columns additionally list their distinct values exactly as stored in the file. Type inference matches default pandas.read_csv — so a column of German-decimal amounts (1.234,56) or grouped numbers is reported text, not number, and blank/NA cells do not demote an otherwise-numeric column; number/boolean columns carry no value list. This exists so a model writing code filters on the value as stored (e.g. "Maennlich") rather than the literal from the request (e.g. "Männlich") — a mismatch that silently matches nothing. Column names and values are untrusted file content: they are stripped of control characters and the summary's own structural markers, so a crafted header or cell cannot inject a second facts line, and they are bounded without ever being cut — a column name over 60 characters is shown as (column N), a column with a value over 40 characters lists no values, and the columns that do not fit the card's 4 KB are counted (N more columns not listed) instead of cut. The card covers .csv/.tsv/.ods and single-sheet .xlsx/.xlsm (multi-sheet workbooks keep counts only); .xlsx stores dates and booleans as numeric serials, so such columns report number.

The response additionally carries four honesty fields describing what a model will actually see:

Field Type Meaning
truncated boolean The extracted text was cut at the inline size cap — only the beginning of the file is in text. For a data file it is set only on the fallback path when no structural facts were available (a data file with facts is sampled instead); a PDF extraction whose inline text hit the 512 KB cap also sets it, and so does a plain-text (.txt, .md, .html) file over the cap.
sampled boolean The file exceeded the sample cap, so text carries the exact facts directive plus a bounded sample of head rows (not the whole file, and not cut mid-table). The counts are exact; answers about specific rows beyond the sample may be estimates. Mutually exclusive with truncated per file.
masked boolean The gateway is PII-active (a gateway that only has the classified-markings preset also extracts text but reports false: it scans, it does not mask), so the inline text will additionally pass request-phase masking before a model sees it.
gateway_compute_path boolean Some tool-capable model on this gateway could compute exactly over the raw file via the code interpreter's staged-input channel (sandbox configured, the gateway has not opted out of the code interpreter — it is on by default, only an explicit code_interpreter.enabled: false disables it — and, on a PII gateway, a fail-closed tool-result mask). This is a gateway-level fact: per-request gates (provider tool support, client-supplied tools, a restricted tool profile) can still deny a specific turn, so it is a "possible", never a "will run". A Local only project is not such a gate — the sandbox stays inside Myra infrastructure.

The inline cut is masked. Where the inline text is cut — at the 512 KB inline limit, or at the 64 KB data-file sample — the personal data or keyword that crosses the cut is masked at the upload, together with up to 256 bytes of the text that was cut off, using the gateway's request-phase detectors and the caller's own identity (personal keywords, role detectors) — the detectors the chat turn carrying the text will apply. Without this, an identifier split by the cut reached the provider as an unrecognisable fragment (the turn's own scan sees only the kept part). The cut is checked under the mandate of the turn's conversation / project: send the same policy reference the turn sends — x-aig-policy-conv-id: <conversation id> (a real conversation, not a ghost id) and/or x-project-id: <project id> — as request headers (the in-app composer does). Both are validated exactly as on the inference API: a repeated or empty header, or an x-aig-policy-conv-id that is not a valid id, does not reject the upload — it puts the cut under the strictest reading (a mandate is assumed, so an analyzer outage refuses the upload even for a fail_open detector); an id that names no conversation, or no project of your tenant, is ignored (the tenant-level mandate applies), while a conversation whose project cannot be resolved puts the cut under the strict reading. A caller that sends neither is checked under the tenant-level mandate only. x-aig-collect-log: false (the in-app composer sends it from a ghost conversation) tells the upload that the file belongs to a conversation that must not be kept: if the file cannot be read, it is not stored for diagnosis even when your organisation has enabled the opt-in capture of unreadable files (only a content-free failure count is recorded). true, 1, yes and on (or no header) keep the organisation's setting; any other value, an empty value or a repeated header is treated as false, so it never stores the file. A header set that cannot be read in full (the read fails, or the request carries more than 100 headers) also counts as false for this rule: the file is not stored. A token minted at the cut is not restorable (the upload has no request token map) — the model and the stored turn see a placeholder for that one value. If the cut cannot be masked, the upload is refused and nothing is returned: 503 {"code":"guardrail_unavailable"} when the analyzer is unavailable (or the gateway configuration cannot be read) — retry; 400 {"code":"guardrail_blocked"} when a block detector matches across the cut. A file whose text is not cut is unaffected, and a gateway without masking detectors does nothing extra.

All four are computed server-side, fail-closed: an unreadable gateway config yields masked: true and gateway_compute_path: false. The facts directive is built only from a real, non-empty extractor summary (an absent or malformed summary is ignored, never surfaced as a bogus count), and rides the inline text only — never the bytes uploaded on the PII-off code-execution path (that would make the CSV reader ingest the directive as a data row). The in-app composer uses these fields for a send-time notice; API callers may ignore them (additive fields, no shape change for non-data files).

PDF extraction — page bound and truncation honesty

A PDF on the extraction path (extract_text, or any upload on a privacy gateway) is read page by page until the extracted text reaches the 512 KB inline text limit, so a long document with little text per page is read completely and a text-dense one is cut on a page boundary (only whole pages are returned). A fixed 1000-page bound remains as a safety limit only. Pages with a real text layer are extracted deterministically; scanned pages are OCR'd by the on-prem vision model under a wall-clock budget that degrades gracefully — transcribed pages are kept and the cut is reported, never a whole-document failure. On a scanned page, a ```markdown or ```md code fence that the text recognition wraps around the whole page is removed; code blocks that are part of the page are kept.

When the extraction is incomplete, that fact is surfaced twice — to the model and to the caller:

  • The inline text ends with a model-visible marker (e.g. [... note: only the first 20 of 43 pages were extracted; content on the remaining pages is missing ...], or a "some pages were too dense to fully transcribe" variant), appended after the 512 KB inline cap so it is never cut off. This is what stops a model from asserting that dropped pages do not exist.
  • The response carries additive fields (absent on a complete extraction — same convention as images_shown/images_total):
Field Type Meaning
pdf_pages_shown number Pages actually extracted. Sent only when pages were dropped (pdf_pages_shown < pdf_pages_total).
pdf_pages_total number The document's true page count, recorded before the page bound.
pdf_transcription_truncated boolean Some transcribed pages were cut mid-transcription (a page too dense for the OCR output budget, or the OCR wall clock).

The page fields and the page-drop marker appear only when pages were dropped, because pdf_pages_shown is sent only when it is strictly below pdf_pages_total (never as "N of N"); a document whose whole text fits the budget is complete however many pages it has; the "too dense to fully transcribe" variant is independent of the page count. The shared truncated field (above) additionally reports the 512 KB inline byte cap on this path. The in-app composer localizes these into a send-time notice ("Only the first 200 of 640 pages of <file> could be read — …"); API callers may ignore them. A document larger than the text budget is still best added as project knowledge (chunk-stored, RAG-retrieved) rather than inlined into a single chat turn.

The extractor subprocess's control lines (usage/billing accounting interleaved with the extracted text) are authenticated with a per-invocation random nonce, so a crafted document whose text contains a forged accounting line cannot alter billing or forge/suppress the truncation report — the forged line is treated as ordinary document content. The subprocess also runs under the same memory ceiling and wall-clock timeout as the Office-document extractors (below); a decompression-bomb PDF is rejected 422, never a memory exhaustion.

A text-extracted PDF additionally surfaces the pages that carry charts, tables and figures, as page renders — a chart in a PowerPoint or Excel export is vector drawing, not an embedded picture, so the text/OCR extraction discards it entirely. The response gives a multimodal model an image of each such page, so it sees what the reader sees, not only the transcription. This is the PDF counterpart of the .docx embedded-image leg (above) and uses the same response fields, caps, validation and privacy gate:

Field Type Meaning
images array One render per visual page, in page order, each { "mime": "image/png"\|"image/jpeg", "b64": <base64> }. Present (an empty array [] when no page carries a chart, table or figure) on a non-privacy gateway whenever the PDF took the text-extraction path; absent on a privacy gateway, and on the native-inline path below.
images_total number How many visual pages the document has among the first 300 pages (pages that rendered blank are not counted). On this leg it counts pages, not embedded pictures. A page too heavy to render safely is counted here but never rendered.
images_shown number How many of them are in images (survived validation and the caps). When images_shown < images_total the composer shows a notice that names the file ("The model sees N pages with charts or pictures from …"); when none could be shown it says the model reads only the text.
images_unavailable boolean true when the page-image leg failed (worker error, timeout, no result), was skipped for the request's time budget, or returned an incomplete scan (the worker hit an internal error or ran out of time before it had looked at every page), so an empty or short images does not mean the document has no visual pages. Absent otherwise, and never sent on a privacy (PII-masking) gateway. Only the boolean true counts. The composer then tells the user that the model reads only the text.

A page is a visual page when drawing or a placed picture covers a noticeable part of it (a chart, a ruled table, a figure, a scan); a text page, and the recurring letterhead, header band or footer rule that repeats on most pages, do not make a page visual. Each visual page is rendered (PyMuPDF) onto a white background with its long side at about 1568 px, so a transparent logo never turns black, and a render that is a single flat colour is dropped. At most 20 pages per document are shown (the ceiling is per document, not per message; it is lowered to the optional request field model's picture limit when that model accepts fewer pictures per message, and the size budget shrinks each page's render so more pages fit), the most visual first and emitted in page order, and the aggregate is bounded to the inference host's wire budget (the least visual render is dropped first to fit); a page left out is reflected in images_total > images_shown, never a failed upload. The page scan and the rendering run under the same memory ceiling as the extraction and under their own deadline, which is shorter than the extraction timeout, so a pathological page cannot starve the text. The pages are handled by a supervised worker process that scores and renders each page under its own time cap (about 2 s to score, 4 s to render); a page that exceeds a cap, or crashes the worker, is skipped and the worker is restarted for the remaining pages, so one hostile page costs only itself. At most 500 drawing signatures are examined per page. The renders are untrusted bytes, validated fail-closed exactly like the docx leg: each image's magic bytes are re-sniffed server-side and only PNG and JPEG within the pixel ceiling are kept. A password-protected (encrypted) PDF yields no images. On a privacy (PII-masking) gateway no images are produced (text-only — a raster image cannot be masked, so it must never egress; fail-closed, an unreadable gateway config is treated as PII-active). The image leg is independent: if it degrades, the text extraction is unaffected (images are additive). It applies only to the text-extraction path — a document-capable model on a non-privacy gateway receives the PDF as a native inline document block and already sees the pages (figures and all), so no separate image leg runs there. These page images are model context: the user's message bubble shows only the document's file card, not the pages.

Spreadsheets are a code-execution data path

Analysing a spreadsheet ("how many rows…", "total revenue…") is a computation, not a text-extraction task. In chat, exact computation is provided by the gateway code interpreter (when enabled on the gateway): the staged data file is placed into the sandbox and the model runs read_excel()/read_csv() over the raw bytes for exact results. Without a code-execution path, the model answers from the bounded inline preview, whose leading facts directive carries the exact structure counts (below). The provider Files API upload (file_id shape, PII-off gateways only) stages the raw file — the .xlsx workbook, or a UTF-8-transcoded .csv/.ods — for callers with their own consumer; note that Anthropic chat document blocks accept only PDF and plaintext files, so a spreadsheet file_id is not usable there. A .pptx is not a data file and is always returned as extracted text, never uploaded.

Character sets are normalized to UTF-8 at the trust boundary via a fail-safe ladder (UTF-16 BOM → UTF-8 → Windows-1252 → Latin-1), so a German-Excel CSV export (CP1252/Latin-1) is read correctly instead of failing to decode or arriving as mojibake. Inline extracted text is capped, with an explicit truncation notice, so a very large file cannot overflow the model's context window.

When a data file is returned as inline text, the extracted text is returned as-is. (A computed [File structure] row/column/sheet-count prefix was previously prepended to help a model that cannot run code answer "how many rows…" without eyeball-counting; it is currently disabled — models are instead steered to run the data through the code interpreter and compute exact figures over the raw file, which supersedes the text summary. The extractor still computes the summary and the prepend code is retained (commented out), so it can be re-enabled if needed.)

Privacy gate (fail-closed)

The caller's ownership of gateway_id is verified first, before the privacy gate or any extraction, so the privacy state of a gateway is only ever evaluated for a gateway the caller's tenant owns.

When the target gateway has an active PII guardrail (a pii_protector, custom_pii, or Presidio detector whose action scrubs or blocks), attachment content is never uploaded to a provider Files API — it would bypass the request-phase masking that runs on the inference body. Instead the file is extracted to text server-side and returned inline, so it passes through masking before it can leave the gateway. This is enforced on the server, fail-closed: the decision is made from the gateway's guardrail config (not from any client field), an indeterminate config read is treated as PII-active, and a request that reaches the upload step on a PII-active gateway is rejected with 422. A client cannot cause a raw upload on a privacy-protected gateway by omitting or altering extract_text. A gateway carrying the classified-markings preset behaves the same way (forced extraction, upload refused with 422), even without a PII guardrail — so the extracted text is scanned for markings; it reports masked: false because nothing is masked.

Scope: this gate covers the spreadsheet / Files-API path. Native inline image and PDF blocks (sent in the inference body, where guardrails mask them) are a separate path.

Office-document extraction (.docx, .xlsx/.xlsm, .pptx) — and, PDF extraction too — runs in a subprocess bounded by a memory ceiling and a wall-clock timeout. A crafted file that inflates far beyond its on-disk size (for example a small archive whose many internal parts decompress to gigabytes of text, or a PDF whose compressed text layer does the same) is rejected with 422 when the subprocess hits the ceiling — it can no longer exhaust host memory. Legitimate documents are unaffected.

Image OCR

An uploaded image is turned into text by the gateway's on-prem vision model (an OCR/verbatim-transcription prompt — transcribe all text, never a UI/design description). The image bytes never leave the gateway trust domain for this: on a privacy (PII-masking) gateway the image cannot be sent to the model as pixels (a raster cannot be masked), so this on-prem OCR is the only way its content reaches a model — the transcription then passes request-phase masking before any customer-provider egress. Any Pillow-decodable format is normalized to PNG first, so JPEG/PNG/GIF/WebP/TIFF/BMP are all supported.

The OCR is request-aware: when the composer sends user_prompt (the user's turn), it is appended to the transcription prompt inside a delimited block explicitly marked as the reader's request (not a model instruction, with the delimiter neutralized and whitespace collapsed) so the model surfaces what the user needs (e.g. an emailed screenshot sent with "translate this" is transcribed so it can be translated). The turn is the user's own text and reaches the on-prem model before request-phase masking; this is an accepted, documented pre-mask exposure confined to on-prem infrastructure (the image bytes already go there), and the resulting text is still masked before it can leave the gateway.

Model transcription is untrusted output: a repetition-loop / degenerate transcription (the model looping on one token) is detected and retried once; if it persists it is dropped (never stored or shown) and the on-premises scene description still runs, so the image can still be delivered as a description. The no-text placeholder (image_notice: no_content, warning set) is returned only when both the transcription and the scene description are empty. A genuinely text-poor image whose scene description succeeds is a normal described result; a "limited text" warning is added only on description_unavailable (scene description missing and a short transcription).

Image description. On the same path (a privacy gateway, or a client that sends extract_text) the text the model receives is an on-premises description of the image, not OCR alone: the verbatim recognised text plus a visual description of the scene (people, objects, layout, colours). The two on-prem vision calls run one after the other (text recognition first, then the description) under one shared deadline; the description call is skipped when too little of that deadline is left. The returned text is laid out as a header line (On-premises description (the model receives this text, not the picture itself):), a Visible text: section and a Visual description: section; an empty section is omitted. For a very tall image (a long screenshot, read in strips for the text) the visual description covers only the first strip, so it stays one coherent description and costs one vision call. It is ordinary user-turn text, so request-phase PII masking covers it exactly like typed text, and the pixels never leave the estate.

The response carries an image_notice code so a client can tell the user what the model actually received: described (description delivered), description_unavailable (the description call failed, timed out, was skipped because the request deadline was nearly spent, or came back empty; the recognised text is delivered under the same header with only a Visible text: section), or no_content (neither text nor description could be produced, including a degenerate transcription with an empty description; only the no-text placeholder is delivered). The English warning stays aligned with the code for API callers; the web app localizes the code itself and ignores an unknown value. A refusal-like or "no text" reply from the recognition model counts as no text (it is never shown as a transcription). Model output and the filename are untrusted: any line that imitates an attachment marker ([Document:, [Image:, [File: and their [End of ... forms) or the description headers is defused before it is composed into the turn.

Large images. An image over 10 MB (the image upload limit — the strictest image-tool limit) is refused before any decode or recognition with 413 { "code": "image_too_large", "max_bytes": 10485760, "error": "The image is too large (max 10 MB). Please send a smaller image." }. "Image" means a declared image/* type or PNG / JPEG / GIF / WebP bytes under any declared type (a renamed photo is still a photo). The web app never sends one: it shrinks a large photo first (see Chat → Attachments); this answer is for API callers, old open tabs and modified clients. An absent data stays 400 invalid_body and malformed base64 400 bad_base64. For the text recognition itself the gateway normalises the image to a PNG; when that PNG is too large for the recognition model's request limit (typically a phone photo — a 12-megapixel photo is a 20–30 MB PNG), it sends a JPEG (quality 92) at most 2048 pixels wide instead (the height is kept — a tall screenshot is read in strips, so its text stays legible). A tall PNG (a long screenshot) whose strips each fit stays a lossless PNG. The decoder preflight emits this recognition source itself, and the gateway never holds more than 16 MiB of it (about 21 MB as base64): a lossless PNG over that size is sent as the JPEG instead (a change for a very tall screenshot, whose text stays legible at quality 92). An image whose source cannot be held within 16 MiB even as a JPEG is answered 413 { "code": "image_too_large", "reason": "decoded_size", "error": … } — without max_bytes and max_pixels, before any model call; inside a .pptx such a picture is skipped (logged at NOTICE level only). If the recognition model still refuses the size, the answer is 413 { "code": "image_too_large", "error": "The image is too large to be read. Please send a smaller image." } — without max_bytes, because no fixed byte limit applies there — never the generic "could not be transcribed". If the JPEG re-encode itself fails for a server reason (busy, timed out), the answer is the retryable 503 extract_transient; an image it cannot decode is 422 unsupported_image_format.

Undecodable / unsupported image. An image is accepted by MIME prefix (image/*), but the server decodes only an allow-list of formats, chosen by the file's content, not its name or declared type: JPEG, PNG, WebP, GIF, TIFF, BMP, HEIC/HEIF, AVIF, and DNG (Apple ProRAW and other camera raws — the server extracts the raw's embedded full-resolution JPEG preview; a raw with no embedded preview cannot be decoded). Every other format the image library can open (for example ICO, ICNS, JPEG 2000, TGA, PPM, PSD, EPS, DDS, PCX) is rejected, even when it is named x.png and declared image/png, as are a truncated / corrupt / zero-byte file. The rejection happens at the server (in a local decode preflight, before any model call) with 422 and a stable code: "unsupported_image_format" plus a short, safe message — never the raw decoder exception. The in-app composer maps this code to a localized "unsupported or damaged image" message; API callers can branch on the code.

Pixel cap (100 megapixels). Before the text recognition reads an image, the server checks its pixel count from the header. An image over 100 megapixels (width × height > 100,000,000) is not decoded and is answered 413 { "code": "image_too_large", "reason": "pixels", "max_pixels": 100000000, "error": … } (distinct from the byte-size 413 image_too_large with max_bytes above; the same cap the knowledge ingest uses). Nothing is stored and the file is not quarantined. The in-app composer shows "has too many pixels to be read (max 100 megapixels)". Inside a .pptx, a picture over the cap is skipped (logged at NOTICE level only) and is not counted among the described pictures; the other slides are still read.

Blank images. An image with no content (one flat colour) skips the text recognition and yields no text; the scene description, where requested, still runs. The 100-megapixel header check applies to every accepted format; the decode work of TIFF (pages, tiles), HEIF and AVIF (grids) is additionally backstopped by the decoder's memory limit (RLIMIT_AS).

When text recognition itself is unavailable — the on-prem OCR service stayed busy past the gateway's bounded retry (a 429/5xx/network blip; a 429's Retry-After is honoured between attempts and passed on), or the platform's OCR credential is not configured — the image is fine and the response is 503 code: "extract_transient" with Retry-After (the same answer a PDF gets, see the table below); an unconfigured credential is not retried, is logged for the operator and answers Retry-After: 60. Any other model failure (e.g. a malformed reply) keeps the generic 422 without a code.

E-mail files (.eml, message/rfc822). Accepted: an RFC 5322 message with at least two of the headers From, To, Cc, Subject, Date, Message-ID, MIME-Version. The response text is the header block (From, To, Cc, Date, Subject), a blank line, the main body, then Other text parts (N): when there are more text parts, then Attachments (N): giving each attachment's name, type and approximate size only (a nested multipart container shows size unknown) — attachment contents are never read. The main body is the plain-text version if the message has one (the stdlib's body search: it descends multipart/alternative, mixed and the like, and takes the start part of a multipart/related), otherwise the HTML version reduced to text; a candidate with no visible text is skipped for the next. Every other text part (any text/* subtype, text before or after the boundaries, the unclassified header lines of a multipart part, a multipart part without a usable boundary shown raw) is listed under Other text parts as --- <type> --- followed by its text, so no text of the mail is dropped; text/html is reduced to text and the others are read as plain text. A part is an attachment when a Content-Disposition header names attachment — on a leaf or on a multipart container (RFC 5322 comments are ignored, a repeated header cannot hide it) — or when it is neither text nor multipart (images, files, and so on). An attachment-disposition part is listed, not read, whatever name or filename it carries; a container marked as an attachment is listed with its multipart type and name and nothing inside it is read; a named inline part stays text, and a quoted value (Content-Disposition: "attachment", malformed per RFC 2183) is not an attachment disposition, so that part's text is shown. A nested message (message/*), including the children of a multipart/digest, is listed as a message/rfc822 attachment and not opened. Undecodable base64 and uuencoded content are shown as they are behind the marker (invalid base64, shown undecoded) or (uuencoded, shown undecoded). The text carries visible markers where the mail is unusual: (no text body) when the mail has no text part, (no visible text body) when its text parts hold only blanks or invisible characters, (no visible text) for a blank entry under Other text parts, [N From headers] (likewise for To, Cc, Date, Subject) when a header is repeated, (conflicting filenames: …) when an attachment declares several different names, (unnamed) for an attachment without a name, (unreadable header) for a header that cannot be decoded, a truncation marker ([… truncated, N characters omitted]) on an over-long header value, and <U+202E>-style markers for Unicode bidirectional control characters in headers and attachment names (they are shown, never silently dropped or acted on). A Content-Disposition on the uploaded mail itself is ignored; the mail is always read. A mail whose top-level type is neither text nor multipart is listed as an attachment (not read). Rejected, each as 422 extract_failed with the fixed message "Could not read this e-mail file (.eml).": an empty file; a file with no e-mail header block (fewer than two recognised headers); a header section over 256 KiB; more than 1000 MIME parts; MIME nesting deeper than 20 levels; a decoded body over 32 MiB; binary content (NUL bytes in a body part; a part whose Content-Type header is invalid and whose content has NUL bytes is listed as an application/octet-stream attachment instead); a malformed message (a closing boundary before the first opening one, so text would be unreachable, or a multipart part with no body parts); and an extraction that exceeds its memory limit.

Document extraction failure (PDF/DOCX/DOC/ODS/XLSX/PPTX/CSV/EML/image-normalize). When the extractor subprocess for one of these formats fails (a corrupt/unreadable file, a presentation whose slide list is broken (a slide named twice, an entry naming no slide or not typed as a slide, a missing/empty/duplicate relationship Id (also when the two Ids differ only by surrounding spaces), a presentation with no slides, a package relationships part that is present but does not name the presentation, a slide link pointing outside the file), an unsupported internal structure, the subprocess crashing or timing out), the response is 422 with a stable code: "extract_failed" and a short, filename-agnostic message naming only the failed format (e.g. "Could not extract text from this .docx file.") — never the extractor's raw diagnostic (a python traceback line, an OS exit code, a subprocess spawn-failure reason). That raw detail is written to the operator-facing server log only; a leak was fixed where it was previously concatenated into this same client-facing error field. The in-app composer maps extract_failed to a localized "couldn't be read, try attaching again or continue without it" message; the failed attachment is restored to the composer so the user can retry or remove it.

PDF extraction failures are classified. A PDF is parsed first (every page in the extraction window and its text layer), and a structural failure triggers one automatic repair pass before anything is rejected: a damaged page tree (a wrong page count, a missing or dangling page list) is rebuilt from the document's page objects, and bytes the primary PDF library cannot open are re-read through a second parser (qpdf). A PDF that a consumer viewer opens is therefore read, not rejected. What remains gets a specific, actionable code instead of the generic one:

Outcome Status / code Meaning
Password 422 pdf_password_protected Encrypted with a user password.
Password (.docx) 422 docx_password_protected A password-protected Word file (an encrypted Office container); recognised from the container's structure.
Damaged 422 pdf_malformed Structure unreadable even after the repair pass — re-export or "Print to PDF".
No text 422 pdf_no_text Read, but no page yielded text (a scan the OCR found nothing on). A blank page — one with no visible marks, such as an empty scan sheet (isolated scanner grain and dust do not count; visible marks at body size — including faint or coloured print — do; extremely faint fine print on a scan, or a light mark on an oversized (A2+) page that is downscaled for recognition, can fall below the threshold) — is never sent to text recognition (the model would invent text for it); a short text layer it carries is still used. A document of blank pages lands here. A page count in the file that is wrong in either direction is repaired, so no page is silently dropped.
OCR busy / unavailable 503 extract_transient + Retry-After (+ cause, page, total_pages) The OCR fleet stayed busy past the gateway's bounded retry, or the platform's OCR credential is not configured (not retried; logged for the operator) — the file is fine, retry shortly. Images answer the same way.
Page refused / time limit 422 extract_failed + cause page_rejected (+ page, total_pages) or time_limit A page's image was refused on its content, or the extraction exceeded its time limit. Sending the same file again will not help.
Other 422 extract_failed Anything else (an unreadable .eml among it, see above).

Failure cause (additive, cause / page / total_pages). For a PDF the 503 extract_transient and the 422 extract_failed answers can carry a closed-vocabulary cause so a client can say what actually went wrong; code stays the stable contract and a client that ignores cause behaves as before. 503 extract_transient carries ocr_unavailable (text recognition was not reachable or not configured) or ocr_too_slow (it did not finish a page in time); 422 extract_failed carries page_rejected (text recognition refused a page's image on its content, so sending the same file again cannot help) or time_limit (the whole extraction ran past its time limit). When the failing page is known the body also has page and total_pages (positive whole numbers, page <= total_pages). Accepted shape: the extractor's reason line is framed by the per-request nonce, parsed strictly, and its cause is accepted only when it is consistent with the exit status (a transient cause never turns a terminal failure into a retry, and a terminal one never the reverse); anything else - absent, unknown, out-of-range or garbled - is dropped and the answer is the plain code without cause. Page text cannot forge it. The English error text names the cause and the page and promises no retry timing. The web chat shows the file name, the page where known, and whose problem it is; only the ocr_too_slow message says to try again in a few minutes.

The code is decided from a stable, per-request-nonce-framed reason line the extractor emits; page text cannot forge it, and an absent or unrecognised reason falls back to extract_failed (never to a more specific class). Each terminal failure is also recorded server-side (a content-free /admin/extract/fail request-log row with its failure class — password, malformed, empty_text, transient, unconfigured (the OCR credential is not configured), timeout, extractor_error; a transient or unconfigured failure is never stored in the opt-in extraction-failure capture, since the file itself is fine), and the OCR billing row of a failed extraction is never stamped 200. Extracting a large scanned PDF can legitimately take minutes (one OCR call per scanned page); the web chat waits up to the server's own bound (about five minutes of processing, plus time for the upload itself) and shows its "Extracting text…" status meanwhile — it no longer gives up after 60 seconds and calls a still-running extraction unreadable. Project knowledge uploads use the same repair: the upload's page-count check counts a damaged PDF's reachable pages the way the extractor serves them. A document in which no page yields any text is empty on every path — the workflow and web-fetch extraction treat it as a failed extraction (and the async knowledge ingest stores its "no readable text" marker) instead of passing on the bare page separators a blank multi-page scan used to produce. The chat extraction's own time limit sits just under the edge's five-minute limit, so a document that runs out of time is reported as a failed extraction (extract_failed) rather than as a gateway timeout that would invite a pointless retry.

A presentation with no text. When a .pptx opens fine but no slide carries text — typically a deck whose slides are only pictures — the gateway reads the deck's pictures with the same on-prem text recognition it uses for image attachments (under the same rule: on a privacy-protected gateway, or when the client asks for extract_text, which the web chat always does). The pictures are taken in slide order (the pictures each slide shows; slide-master and layout pictures such as a logo are skipped — if the deck's slide structure cannot be read, they are taken in file order), at most 8 of them (PNG/JPEG, and SVG rendered to PNG; re-checked and size-capped like Word document images), and no text-recognition call may run past a budget of two minutes for the whole deck. The answer is the recognised text, labelled per picture and introduced by a note that the slides had no text of their own, with pictures_read (pictures that contained text), pictures_tried (pictures text recognition could read) and pictures_total (pictures on the slides) — the web chat shows "… its pictures were read with text recognition (N of K pictures contained text)", plus "K of its M pictures could be read" when not every picture could be (the 8-picture cap, an undecodable format such as EMF, or a failed recognition). Each picture is prepared exactly like an image attachment (orientation and colour format normalised) before text recognition, and the whole deck stays within the request's own time limit. When the text-recognition service itself is not available (not configured, busy past its retry, or the budget ran out) and nothing was recognised, the answer is the retryable 503 code: "extract_transient" — the file is fine; when the pictures could not be prepared or the service failed every call for another reason (for example an authentication fault or an unusable reply), it is 422 code: "extract_failed". When the pictures were read but none contains text — or none of its pictures could be read because of their format or size (for example only EMF/GIF pictures) — the deck is rejected with 422 code: "pptx_no_text" ("No readable text was found in this presentation. Its slides may contain only images."), not the generic extract_failed, which stays reserved for a file that could not be read. The distinction comes from the extractor's exit status, never from the slide text, so a slide that merely says "no extractable text" is ordinary content. The web chat shows "No readable text was found in …", does not send the message, and restores your input and attachments so you can adjust and resend.

Error codes: 411 (length_required — the request has no Content-Length; see error codes), 400 (missing or invalid data/filename, or missing gateway_id), 413 (image_too_large — an image over 10 MB, see Large images above, or over 100 megapixels with reason: "pixels", see Pixel cap below), 403/404 (gateway_id is not owned by the caller's tenant, or does not exist — returned before any extraction), 403 on the raw provider upload only (data_residency_blocked, model_not_allowed_for_project, conversation_project_unresolved — see Residency and Tier-1 on the provider upload above), 422 (extraction failed — code: "extract_failed" for a PDF/DOCX/DOC/ODS/XLSX/PPTX/CSV; for a PDF the specific pdf_password_protected, pdf_malformed or pdf_no_text; for a password-protected .docx the specific docx_password_protected; for a picture-only .pptx the specific pptx_no_text — an undecodable or unsupported image — code: "unsupported_image_format" — a document that exceeds the extraction memory/time limit, an attempted upload on a privacy-protected or classified-markings gateway, or — on a malware-scanning gateway — an infected file, code: "malware_detected"), 502 (provider Files API error, or code: "configuration_error" when the gateway's provider_base_urls.anthropic override is malformed or resolves to a private/internal address; the upload honours that override and sends only the gateway's own key to it; a Myra key bound for that override is refused with 500 code: "configuration_error" before anything is sent), 503 with one of these causes: (1) the provider key is not configured for the gateway, or any key-policy refusal on the upload — { "error": "Anthropic key not configured for this gateway", "code": "files_api_key_missing" }; on a self-serve gateway the upload uses the shared Myra key like every other call, so this answer means the shared key is not configured on the platform, not that you must add a key; (2) a failed read of the key — { "error": "temporarily unavailable; retry later" }; neither of these carries the cause; (3) a transient gateway lookup failure, or the shared upload pool saturated — code: "ingest_busy", with Retry-After; (4) the OCR fleet busy past the bounded retry, or its credential not configured, for a PDF or an image — code: "extract_transient", with Retry-After; (5) on a malware-scanning gateway, the scanner unreachable — code: "scan_unavailable", with Retry-After; (6) on the raw provider upload, the project tier could not be determined — code: "project_tier_unresolved" (retryable). A stored key that cannot be decrypted is not a 503 but the sanitised 500).

Client-side upload size limit

The in-app composer enforces a client-side per-file guard sized to this host's edge upload cap (140 MB, giving a raw-file limit of 110 MB, read from limits.chat_upload_max_bytes on /me) before it POSTs to this endpoint (raised from 56 MB so a ~100 MB Office document — the >100-page reference case — uploads). The composer's own attachment-staging cap is derived from that same budget (no second number). A file over the guard is rejected in the browser with a specific "…is too large to upload…" message and the request is never sent.

The client guard is not the trust boundary. The server independently rejects a decoded upload over the 110 MB limit with a 413 JSON error (attachment_too_large, with max_bytes) (a clear message, never a bare 413) before any extraction or provider upload, and admits a bounded number of concurrent uploads — an upload arriving while the file-processing pool is saturated gets a 503 with code: "ingest_busy" and a Retry-After header (a transient state — retry shortly) rather than exhausting worker memory (each large upload peaks at the base64 body plus the decoded bytes plus its extractor subprocess). This is the same shared upload-pool budget, and the same machine-readable code, as the project knowledge-upload endpoint. The web chat branches on the exact string code: "ingest_busy" (a 503 without exactly this code falls to the generic extraction-failure message): it shows a transient "busy — please try sending again" banner naming the file and keeps the attachment in the composer; it does not retry on its own. In a multi-attachment send the other files' finished extractions are kept with their composer chips (the failed file's chip is marked), so the next Send re-submits only the failed file — never the whole batch again into the pool that just refused one.

Malware scanning (fail-closed, opt-in per gateway). Malware scanning is enabled per gateway (av_scan.enabled in the gateway config) and is off by default — a gateway that has not opted in skips this step and the upload proceeds normally. When the target gateway has opted in: after the size/authorization checks and before any text extraction or provider Files-API upload, the decoded bytes are streamed to a self-hosted ClamAV daemon (clamd, INSTREAM). A scanner reply that the file exceeds its size limit is rejected with 413, code: "scan_limit_exceeded" (never accepted as clean). An infected verdict rejects the upload with 422 and code: "malware_detected" ("This file was blocked by malware scanning."); the ClamAV signature is logged operator-side only and never returned. If clamd is unreachable, times out, or returns an error, the upload is rejected — not accepted unscanned — with 503, code: "scan_unavailable" and a short Retry-After ("Malware scanning is temporarily unavailable. Please try again in a few moments."). The same opt-in scan, with the same codes, guards the conversation attachment endpoint (POST /conversations/{id}/attachments, gated on the conversation's gateway) — attachments are persisted and served back raw. The virus scanner is configured for your deployment by Myra and is consulted only for an opted-in gateway.

Note this is larger than the inline image/PDF limit on the inference host (~7.4 MB): the two travel to different hosts with different body limits (admin /chat/files at 140 MB; inference compat/chat/completions at 10 MB), so a document uploaded here for text extraction is bounded independently from a native-inline attachment. See the inference reference for the inline guard. (A document whose text exceeds the 512 KB inline context ceiling is best added as project knowledge, where it is chunk-stored and retrieved by RAG, rather than inlined into a single chat turn; an inline extraction past the page bound or the text budget says so explicitly, both to the model and in the response fields.)

This is a UX guard, not part of the endpoint contract — the server enforces the same 110 MB limit itself (413 attachment_too_large; an image over 10 MB is the typed 413 image_too_large above). The guard exists because a body over the host's limit is refused with a 413 — and a large upload can be cut off mid-transfer, or answered without CORS headers by the ingress, which the browser's fetch reports as an opaque network error indistinguishable from a genuine outage. Rejecting the oversized file up front turns that "the gateway is unreachable, keep retrying" dead end into a clear, actionable message. Direct API callers are not bound by this browser guard, but a body above the limit is still refused with 413 payload_too_large (see Request body size limits).


PDF reading progress

GET /admin/v1/chat/files/progress?id=<progress_id> — how far the server is in reading a scanned PDF that a POST /admin/v1/chat/files call is still processing. The web app polls it every few seconds and shows "Reading "x.pdf": page 2 of 4…" instead of a static message.

Response 200: { "progress": { "page": 2, "total": 4 } } while the extractor reports pages (1 <= page <= total), otherwise { "progress": null }. null is the normal answer for an id the server does not know, an id that belongs to another user, a finished or expired upload, a PDF with a text layer (nothing to read page by page), and a stored pair that does not satisfy 1 <= page <= total <= 1000000. It is a display hint only and never affects the extraction result.

  • The record is keyed by your authenticated user and the id, so another user's id always answers null.
  • It is held for at most 330 seconds and removed as soon as the upload finishes.
  • Every request returns the same answer, whichever server runs the upload. A database error while reading it is answered { "progress": null }.
  • The answer is sent with Cache-Control: no-store and does not use an upload slot.
  • Errors: 400 progress_id_required (no id), 400 invalid_progress_id (not a canonical lowercase UUID, or id given more than once).
  • 401 unauthenticated without a valid session. 403 impersonation_forbidden while an admin is viewing as another user ("View as User"): the progress record belongs to the target's personal data, so it is refused.

Conversation export

Render markdown content — one assistant message or a whole conversation — into a downloadable file. Nine formats share one request and response contract.

Endpoint Output
POST /admin/v1/chat/export-pdf PDF
POST /admin/v1/chat/export-docx Word document
POST /admin/v1/chat/export-odt OpenDocument Text
POST /admin/v1/chat/export-txt Plain text — the message rendered without markup
POST /admin/v1/chat/export-xlsx Excel — one sheet per markdown table
POST /admin/v1/chat/export-ods OpenDocument Spreadsheet
POST /admin/v1/chat/export-csv CSV — every markdown table, rows written consecutively (same table source as Excel)
POST /admin/v1/chat/export-pptx PowerPoint
POST /admin/v1/chat/export-odp OpenDocument Presentation

The CSV and spreadsheet (xlsx/ods) exporters share one table-extraction engine, so a CSV agrees cell-for-cell with the Excel file for the same content: every GFM pipe table in the markdown is exported, numbers are detected locale-free (both 1,234.56 and 1.234,56 become the value 1234.56), and identifier-like values (leading zeros, >15 digits) stay text. CSV is a flat format with no sheets or table-boundary concept, so when a message has more than one table their rows are written consecutively (each table keeps its own header row); no blank-line separator is inserted (a data format should not carry a non-data structural line). A CSV is UTF-8 with a byte-order mark (so umlauts render correctly in Excel on Windows). To defend against CSV formula injection, any text cell (including a header cell) that begins with =, +, - or @ is prefixed with an apostrophe so a spreadsheet cannot execute it as a formula or DDE command; a genuine negative number such as -5 is written as a number and is not prefixed.

The plain-text (txt) exporter renders the message with all markup removed (headings, emphasis and links flattened; tables laid out as aligned text). Unlike the spreadsheet formats it never returns 422, because any content — prose or tables — has a plain-text form.

Line breaks. A downloaded document keeps the line breaks you see on screen: a single newline inside a paragraph becomes a line break in Word (docx), OpenDocument Text (odt), PDF and plain text (txt), and in the paragraph text of PowerPoint (pptx) and OpenDocument Presentation (odp) slides, so an address block or a signature stays one line per line instead of running together. An explicit break (a backslash or two spaces at the end of a line) is still exactly one break. The spreadsheet and CSV exports are not affected. A few constructs where the screen and the file read the Markdown differently (for example a number followed by a full stop at the start of a continuation line) can still differ by a break; see HTML in rendered Markdown for the on-screen rule.

Emoji in the PDF. Emoji in the body, in table cells and in code (including sequences such as a person with a laptop and flags) are drawn as coloured pictures with the Noto Color Emoji font. Digits and text keep the document font. Earlier PDF downloads drew the emoji far too small, so table cells and lines with emoji looked blank; this is fixed.

Request body (JSON):

Field Type Required Description
markdown string yes Markdown source to render. Must be a JSON string (a number, boolean, object or array is 400 invalid_body); absent, null or whitespace-only is 400 markdown_required. Maximum 8 MiB.
filename string no Download base name. The format extension is appended. Defaults to conversation; absent or null uses the default. Any other non-string is 400 invalid_body. There is no length limit on the request: the name is cleaned first (/ and \ are replaced by _; a leading dot is kept (.bashrc becomes .bashrc.<ext>); double quotes ("), ; and control characters are removed; surrounding whitespace, including Unicode spaces such as NBSP, is trimmed, and interior Unicode spaces become ASCII spaces), and a cleaned name longer than 255 bytes is not used and the download is named conversation.<ext> instead (never cut). A name that is empty after cleaning, or made only of dots and spaces (for example ., .., . . .), also gets conversation.<ext>. Invalid UTF-8 is replaced by U+FFFD and invisible format characters are removed before that count. The response header carries an ASCII filename="…" fallback (non-ASCII characters and % become _) plus filename*=UTF-8''… with the exact name (RFC 6266 / RFC 5987).
reference_attachment_id string no export-docx only. The id of a .docx the caller previously uploaded in one of their own conversations, used as the Word letterhead template: the produced document carries that file's header/footer, embedded logo, brand colours and fonts while the body is the rendered markdown. The attachment must belong to a conversation the caller owns (foreign or unknown ids are not distinguished — both are treated as "no reference"); it must be a .docx under 25 MiB. It is sanitized at the trust boundary before use — external-target relationships (which would make the produced file fetch a remote URL when opened), OLE objects, macros/VBA and external-data (mail-merge) settings are stripped; the embedded logo (an internal relationship) is preserved. Absent, null or "" means no letterhead; any other non-string is 400 invalid_body. Ignored for every non-docx export.

Response: the rendered file is streamed back (HTTP 200, Content-Type per the table, Content-Disposition: attachment with filename and filename*, see the filename row). The body is the raw file bytes, not JSON. When reference_attachment_id was supplied, the response carries an X-Aig-Reference-Applied header (true/false, exposed cross-origin) so the client can tell the user whether the letterhead was actually applied: if the reference is missing, not owned, not a valid .docx, or fails to render, the document is produced without the letterhead (never a 500, never silently branded) and the header is false.

The whole body is validated before a render slot is taken or any subprocess is started, so a rejected request costs nothing. Malformed JSON and any non-object body (a JSON array, 42, true, "x", null) are 400 malformed_body; an absent body answers 400 markdown_required.

Error codes: 400 (markdown_required — markdown absent, null or whitespace-only; invalid_body — markdown, filename or reference_attachment_id of the wrong type; malformed_body — a body that is not a JSON object, or malformed JSON), 413 (markdown_too_large — markdown exceeds 8 MiB; checked before the whitespace test), 422 (there is nothing to export — a CSV, Excel or OpenDocument spreadsheet export of a message with no table is answered "No table found in this message to export." with code no_table_found; a PowerPoint or Impress export of a message with no text, for example only a rule or an empty aligned block, is answered "No content found in this message to export." with code no_content_found), 500 (renderer failed), 503 (at capacity, maximum four concurrent renders; Retry-After: 10). An impersonation session is refused.

The web chat waits for an export in two phases. Until the server answers, it waits up to seven minutes for the upload plus the processing — the platform's own five-minute limit on the server's answer, plus two minutes to upload the request (which can carry inlined images) — so a slow mobile connection no longer cancels a document the server is about to finish. Once the server has answered, the download of the file gets its own three minutes; a download that stalls shows "The file was ready, but its download stalled" rather than claiming the render took too long.

When every render slot is taken, an export route answers 503 with code render_busy and Retry-After: 10 (the same for POST /chat/convert-html: convert_busy). The web chat treats exactly these two codes as transient: it keeps the menu item pending, waits the Retry-After seconds (10 s when the header is absent or unreadable, at most 30 s) and asks again, three requests at most and each with its own timeout. If the last one is still busy, the menu shows "The service is busy right now. Please try again in a moment." (a conversion shows "The converter is busy. Please try again in a moment."). Every other 503 (for example convert_unavailable) is shown at once and not retried. API clients should do the same: honour Retry-After and retry a bounded number of times.

Images and untrusted media

The markdown is untrusted input handed to the renderers (pandoc / WeasyPrint), which would otherwise fetch any URL or read any local file a reference points at. It is sanitized at the trust boundary before rendering, fail-closed:

  • Kept: a self-contained inline image whose source is a data:image/png or data:image/jpeg URI. The payload is base64-decoded and validated by its real magic bytes (the declared MIME is not trusted), and rejected if its pixel dimensions exceed 25 megapixels. This is how embedded and server-generated images survive the export.
  • Rejected (the image is dropped, its alt text kept): any remote (http(s)://, protocol-relative //host), local or relative path, file: URL, data:image/svg+xml or any non-image data: URI, reference-style/shortcut image, and raw HTML other than the small list in HTML in rendered Markdown (<img>, <style>, a style attribute, etc. are shown as typed text). The Word, PDF, OpenDocument and text downloads turn only that list into layout, through a filter that builds the document from it and never passes raw HTML through; the pandoc reader is restricted to a safe set of markdown extensions, so no HTML/CSS/metadata construct can trigger a network fetch.

No image reference in the exported document can cause the server to make an outbound request or read a local file.

The PDF renderer enforces the same allowlist a second time, when it lays the page out: its resource fetcher is fail-closed and loads only data:image/png / data:image/jpeg URIs and the files the server hands it itself (the base stylesheet, the tenant stylesheet and the organization logo). Every other fetch — http(s), file: outside those files, SVG, other data: URIs, a CSS @import — is refused, so a reference that slipped past the sanitizer still reaches no network and no local file. The renderer runs under an address-space limit of 3072 MB; an export that exceeds it, or fails for any other reason, answers with a server error and no partial PDF. Wide tables are fitted by measuring the laid-out page (at most three layout passes). The renderer is given a layout budget of 45 seconds (the 60-second render timeout minus a 15-second headroom, one constant); the budget only decides whether another layout pass starts, it never interrupts the conversion of the markdown to HTML, which has its own fixed 45-second ceiling (exceeding it fails the export with a server error and no partial PDF). When a very large document exhausts the layout budget, the renderer stops fitting, writes the PDF as laid out so far and reports each table that still overflows on its standard error, which the server writes to its log as a warning — the export still succeeds. The budget check assumes the next layout pass costs about 1.65 times the last one (growth plus writing the PDF), so it stops before, not after, the budget would be exceeded. A table that is set in the smallest font additionally gets zero-width break points inside its long unbroken runs (a 10,000-character token costs time linear in its length, not quadratic); the characters themselves are unchanged and copy out of the PDF as they were.

Corporate-design branding (PDF, Word, PowerPoint)

The PDF, Word (docx) and PowerPoint (pptx) exports apply the caller's organization (tenant) corporate design when it is configured: brand_primary_color recolours headings (and, in the PDF, the top-heading rule and links); brand_font_family sets the document font; and the organization logo — one of the images uploaded for display in the app — is placed on the generated document. Branding is resolved server-side from the authenticated caller's tenant — it is never sent in the export request. When nothing is configured the platform default is used, and each element degrades independently.

How each element is applied per format:

PDF Word (docx) PowerPoint (pptx)
Color headings, heading rule, links headings + title (document theme) slide titles and section headings
Font body font document body + headings (theme) all text (code stays monospaced)
Logo top of the first page top of the first page top-right of every slide

The logo is one of the same assets uploaded for the in-app logo (no separate export-logo upload). Documents are white, so the light-theme logo is used; when the tenant has only the dark-theme logo (artwork for dark backgrounds), that one is placed on a dark-blue plaque so it stays legible (see Tenants → Fallback and plaque). It is size-normalized to a small PNG before embedding; transparency is composited onto white (light-theme logo) or onto the plaque (dark-theme logo). A missing, malformed or unreadable logo renders the document without a logo. The other export formats (odt, ods, odp, xlsx, csv, txt) use the platform default in this release.

The color/font are set on the tenant (see the tenant admin API) and are treated as untrusted at every boundary — validated on write, and re-validated where the stylesheet / Word theme / slide is generated (defense in depth) — so a stored value can never inject into the generated document. Accepted shapes:

  • brand_primary_color — exactly a #RRGGBB hex color (case-insensitive, stored lower-cased). Anything else (named colors, #RGB, values containing ;/}/quotes) is rejected. The exports always use the stored value exactly; only the app's dark theme renders an automatically lightened variant of it (to stay WCAG-AA readable on dark surfaces) — the stored value itself never changes.
  • brand_font_family — 1–120 characters of letters, digits, spaces and hyphens only. Quotes, semicolons, braces and angle brackets are rejected so the value cannot break out of the generated CSS/theme. (The font must also be installed on the server for the PDF to render in it; an unavailable font falls back to the default stack — the Word/PowerPoint files name the font regardless, and the viewer substitutes if absent.)

Every branding element is fail-closed: an invalid stored color/font is dropped per-field, and a missing or corrupt logo is omitted — the export still renders, unbranded for that element, never erroring.

An invalid value is a 400 on the tenant PATCH; a value that is somehow invalid at render time is dropped per-field (fail-closed to the default) rather than emitted.


Slide-deck preview (client-side input handling)

The web app decides in the browser, without a request, whether an HTML artifact is previewed as a slide deck. The HTML is model-authored and treated as untrusted: it is parsed with the browser's inert HTML parser (no script runs, nothing is loaded) and only a slide count is taken from it. Accepted: a document of at most 8,388,608 characters whose <style> declares the template marker --presentr-template inside a :root { … } rule (CSS comments ignored), with 1 to 200 <section> elements directly in <body> (the same 200-slide limit as the conversion below). Anything else — no marker, the marker only in a comment or another rule, no slides, nested slides only, more than 200 slides, a longer document — is previewed as ordinary HTML. A deck is rendered in the same sandboxed preview frame and under the same content security policy as every artifact, with no scripts.


HTML conversion

POST /admin/v1/chat/convert-html — turn an HTML document from the conversation into an editable PowerPoint (.pptx), OpenDocument presentation (.odp), PDF, Word (.docx) or OpenDocument text (.odt) file. The HTML is rendered exactly as a browser shows it and rebuilt as native slides, text boxes, tables and shapes (pictures only where the page itself is a picture: charts drawn with canvas, photos, complex SVG). An inline SVG is written as a sanitized vector copy with its captured PNG as the fallback, but only when the copy shows what the page showed; an SVG that loses visible content to the sanitizer (a JPEG or other non-PNG image inside it, a filter such as a drop shadow, HTML labels in foreignObject, a reference to another file, a reference to a symbol or gradient defined in another SVG of the page) or whose look depends on CSS the copy cannot carry (a transform, filter or blend mode set from a stylesheet) is written as the PNG capture alone. A background gradient becomes a native gradient fill when it covers its box as one layer; a gradient used as a pattern (sized, offset or layered) stays a picture. The same converter backs the chat tool convert_document, so a file the assistant converts and a file you convert with the menu are identical.

Word follows the page's layout. A letter or report keeps the structure the preview shows. Style declarations never appear as text in the document.

Kept (Word):

  • Text and structure: line breaks of white-space: pre-line / pre-wrap text (an address block stays one line per line), two <br> as one blank line, a flex or grid row (sender left, date right; label and value pairs) as a borderless table whose narrow cells keep a minimum width (a shrink-wrapped block such as a sender address keeps its longest line, a bordered inline box, an inline-block badge or tile, a floated box or a one-cell callout keeps the width it has on the page plus a little slack for Word's wider text, and a box with a fixed width such as 72mm or 240px keeps exactly that width, instead of a share of the wider preview page. This holds whenever the page itself is wider than an A4 page (the preview sheet, not the box's own parent, decides), so a 72mm rule inside a half-width flex, grid or table cell is still 72mm; a percentage width keeps its share, and boxes on one line stay left-aligned; a content-sized box is never narrower than its own text, so a name over a signature line stays on one line and a lone centred seal stays centred, and no box or table cell (the cells of a real <table>, such as a key and value block in an invoice header, included) is narrower than its longest word, even one set to width: 0 (a word that the page itself lets break, under word-break: break-all or overflow-wrap: anywhere, or one longer than about 30 em, does not count: it wraps instead of widening the column; overflow-wrap: break-word does not count either, as it never makes a column narrower; a hyphenated URL or path counts only with its widest piece between the break characters - / . ? & = _ (an e-mail address has no break and stays whole), a date or an amount stays whole; a column is never set narrower than that widest piece whenever the pieces of all columns fit the page together (a 40px or 110px label track, a 240px 1fr sidebar and a max-content 1fr definition grid, whose width comes from the longest key in any row, keep their words whole), and only when they cannot fit are the shares scaled down; and a borderless flex or grid row whose columns' words cannot fit side by side is written as stacked paragraphs instead of squeezed columns), and a flex or grid item that is, or wraps, a <table> (a key and value block in a header) stays a table at least as wide as that table's own columns; a narrowed box is never narrower than its longest word or, when its text sits on one line in the preview (a button, pill or badge), than that single line, so it does not wrap), and text after a nested list inside a list item as a continuation paragraph after the sub-items. A list item that holds only a sub-list keeps its own bullet. A nested ordered list keeps the numbering style the page shows at each level (1. inside 1., or a. inside 1.).
  • No visible word is lost (Word, OpenDocument, PowerPoint and Impress decks): every word the preview shows reaches the file. A table's <caption> is written as a paragraph above its table (below it for caption-side: bottom; a hidden or blank caption is left out). In a PowerPoint / Impress deck the caption is a text box above (or below) the table, and the fill of a normal table covers the table itself, not the caption's space (when the page draws the table's box around the caption, as for a display: block or display: flex table or a floated caption, the fill keeps that shape). A row of short-value cards (KPI, pricing or statistic cards with a border or fill) is written as a borderless table with the card's fill, border and padding, so its numbers stay editable text. Text drawn by CSS (::before / ::after content with strings, attr(), quotes and counter() / counters(), including counter-reset, counter-increment and counter-set on the pseudo-element itself) is written where the page paints it; a pseudo-element that is not painted (hidden, scale(0), clip-path: inset(100%), moved off the page, inside a collapsed overflow: hidden box) is left out. Generated text is capped at 1024 characters per pseudo-element and 100 000 per document (per slide in a PowerPoint/Impress deck export), the counter pass at 20 000 elements, 32 counter names and about 1.2 s; past a cap the generated text is dropped (the converter counts what it dropped and the gateway logs that count as a warning; the response does not carry it) and the real text is kept. The label of a list item the converter cannot reproduce itself (unsupported numbering styles such as hebrew, armenian or cjk-decimal, values outside a style's range such as lower-greek past 24, a page's own @counter-style rules, a rewritten list-item counter, and ::marker content using such a counter) is the text the browser drew for that item's ::marker, read from a bounded browser snapshot (at most 2000 items per page, 256 characters per label, 4 MiB and 3 seconds for the snapshot; measured, a page of about 12 000 elements stays well inside it while one of about 50 000 elements (a 426 KB page) exceeds the 4 MiB), and is not counted as dropped. If that snapshot is missing, too large, late or malformed, or an item is beyond those limits, the label is exported as a decimal number (or none) and counted (logged by the gateway like the dropped generated text). ::marker content mixing an image with a counter keeps the drawn text; the image is not exported. A list item whose bullet is only an image (list-style-image, or ::marker content that is only an image) is written with a plain bullet, also inside a numbered list; the picture itself is not written. Where the browser could not load that image and fell back to its own bullet, the export still writes the plain bullet; a list-style: none item with an image that cannot be loaded gets one as well. A ::before / ::after label made with counter() / counters() that the converter cannot reproduce itself (a page's own @counter-style, hebrew / armenian and other unsupported styles, values outside a style's range, or a number past the counter cap) is likewise the text the browser drew for that pseudo-element, read from the same snapshot with the same limits; a pseudo-element the page hides is left out as before, and one the browser never laid out keeps today's decimal label and count. If the snapshot is missing, too large, late or malformed, or the element is beyond its limits, the label is exported as a decimal number (or dropped past the counter cap) and counted, as before. String list labels and the supported non-native styles (decimal-leading-zero, lower-greek in range, ...) stay text. Text placed directly inside a list but outside its list items (a <p>, a <div> or bare words in an <ol> / <ul>) is kept, in document order between the items; the items after it keep the number the page shows. The Word/ODT export of a slide deck uses the browser snapshot too, on every slide. PowerPoint/Impress deck export (pptx / odp) does not use it: its list labels and counter() labels that cannot be reproduced stay decimal numbers (or are dropped) and are counted, like dropped generated text (gateway warning). A list item Word can number itself keeps Word's own numbering and is not read from the snapshot: a native type (decimal, lower-alpha, lower-roman, ...) in range, not redefined by the page's @counter-style, on a list whose list-item counter the page does not rewrite; a native bullet or letter type on a <ul> with counter-reset also stays native. A marker the browser laid out but drew empty (empty or blank symbols) gets no label and is not counted; an item whose layout the browser skipped (content-visibility: auto far off screen) is not read from the snapshot and stays counted; bidi marks, embedding, override and isolate controls (and control characters other than tab) are removed from a drawn ::marker label. A drawn ::before / ::after keeps its line breaks (CR, CRLF and form feed each become one line break); bidi marks, embedding, override and isolate controls and other control characters except tab are removed. Charts made of CSS bars stay pictures, with their words as the picture's alternative text. A page or section made only of absolutely positioned boxes (an invoice or a letter laid out with position: absolute) becomes text in reading order, top to bottom and then left to right (right to left on a right-to-left page), so the words can be selected, searched and edited; boxes that sit side by side on one line become a borderless table. This applies when the positioned area is at least 160 x 105 mm, or holds at least half of the page's text, or sits inside another positioned page that already became text. A small positioned figure (a badge, a diagram, a logo with a caption) still stays a picture with its words as alternative text. A positioned area that has a fill or a border of its own (a slide of a deck with a dark background, a framed sheet) is written inside a shaded or bordered one-cell table, like a static boxed block, so white text stays on its dark fill in print; where a static boxed block would not get that table (the box holds more than 60% of the page's text, it is an A4 page sheet, or the table limits are reached), the text is written without the box. The text of each such slide counts against the block limit of its own table cell, so a deck of many slides stays text, while a single slide over the limit sends the whole document to the picture pass described below. A break-after: page on a positioned layout or a bar-chart row (not itself absolutely positioned) is kept, also when it stays a picture. A positioned layout whose list items draw their own markers (bullets, numbers or ::marker labels), or whose non-positioned wrappers draw generated content (::before / ::after) or hold loose words outside the boxes, also stays a picture, since those cannot be placed in reading order. A positioned layout with more than 5000 boxes stays a picture with its words in the alternative text, and the positioned layouts written as text hold at most 20 000 elements in total per document: a layout that would take the total over that stays a picture (so on a document of many positioned pages, the first ones become text and the rest stay pictures). If writing the positioned layouts as text would take the document over any limit (blocks, table cells, number or area of pictures, the size of the converter's internal reply, the XML or file size) or makes it unwritable, the whole document is converted again with every positioned layout as a picture, as before; it is refused only if it is still too large that way. Only a layout of plain text becomes text: if anything in it draws more than visible text with plain fills and borders - an image, an svg drawing, a canvas, an embedded object or frame, a formula written in MathML, a CSS background image (gradients included), mask or border image, a filter, an inset shadow or outline, image content from content or ::before / ::after, a form field drawn as a control (an input, a select, a button with its native look, a text area, a meter or a progress bar, or anything with a native widget look; a button restyled with appearance: none is plain text), a <details> disclosure, a list bullet drawn as an image (list-style-image or image ::marker content), text masked with -webkit-text-security, or text in a transparent colour (also ::before / ::after text, such as an outlined or background-clip: text label) - the WHOLE positioned layout stays one picture with its words as alternative text, exactly as before. A page that uses shadow DOM (web components) keeps its positioned layouts as pictures, since their content cannot be placed in reading order, and so does a page too large for that check (its DOM snapshot is over 4 MiB). This is decided before the text pass, for any page that has text in an absolutely positioned box (this check reuses the one page snapshot that every conversion reads for the closed-component check, described under Masked text), so a long document that cannot be checked is converted once, as pictures, in the time of the former output rather than being converted twice. A positioned box that paints only a fill or a border (a coloured bar, a rule, a signature line) and holds no text is not written. On a positioned layout that becomes text, text the preview does not paint (opacity: 0, a screen-reader-only clip, clip-path: inset(50%), transform: scale(0), text moved off the page with left: -9999px or text-indent: -9999px, a box cut away by a 1 px overflow: hidden wrapper) is left out like on any other page (see "Text the preview does not show" below), although the former one-picture output carried those words in its alternative text.
  • Text the preview does not show (Word, OpenDocument, PowerPoint and Impress): text the preview does not paint is left out of the file. That covers text hidden with display: none, visibility: hidden, opacity: 0 or a transparent colour, the content of a closed <details> (its <summary> stays, written with a disclosure triangle: ► closed, ▼ open; none when the page sets list-style: none on it or the summary itself is visibility: hidden; the same triangle leads a summary inside a list item or a table cell; it shares the first line with the summary's content, including tall inline content such as an icon or larger text, and is a line of its own above the summary's content only when that content starts with a block such as a heading, paragraph, list or table, with a line break (a second line break adds one blank line), or with a block-level generated label, as in the browser; and an outer summary keeps its triangle when it holds a table or list with another <details>; a <details> without a summary gets a "► Details" legend), content under content-visibility: hidden on a box where the browser hides it (a block, inline-block, flex, grid, table cell or list item; not inline text or a display: contents element, which the browser still paints, and so the export keeps) and hidden="until-found" content, a screen-reader-only label (clip: rect(0,0,0,0), a 1 px box, clip-path: inset(50%)), text moved off the page (left: -9999px, text-indent: -9999px, a transform that moves it out of view or shrinks it to nothing), and text cut away by an ancestor with overflow: hidden or overflow: clip (a fixed-height box shows only its first lines). Only what the page's own styles prove invisible is dropped: text behind a partial clip-path or a filter, an absolutely positioned element that escapes its clipping parent, and anything whose position cannot be measured are kept. A clip-path that shows nothing, or a clip rect of zero area, hides everything inside the box, absolute and fixed descendants included - except top-layer elements (a modal dialog, an open popover), which the preview still shows but the export currently leaves out. A clip-path on a display: contents element that is not absolute / fixed has no effect (it has no box), so its text is kept. An absolute / fixed display: contents element with such a clip-path is still shown by the preview but currently left out of the export. visibility: hidden hides only the box it is set on: a descendant that sets visibility: visible is painted by the preview and so is exported (in lists, tables, nested boxes and positioned pages alike), while the hidden box's own text, background, borders and list marker are not (its visible descendants take no highlight, gradient text colour or dark picture backdrop from it; a visible box further up still gives them its own). display: none and opacity: 0 hide the whole subtree whatever the descendants set. visibility: collapse on a table row, row group or column removes that row, group or column with everything in it, descendants that set visibility: visible included; on any other box it behaves like hidden. A word cut by an overflow: hidden or clip edge is kept or left out by where the centre of its first box falls. Text that lies wholly before the page's start edge (left of it on a left-to-right page, right of it on a right-to-left page) or above it cannot be scrolled to and is left out like any other off-page text. When the page's own overflow (on html, or on body when html has none) is hidden or clip, the far horizontal edge is cut at the viewport width as well (only the horizontal axis: the print the export is compared with paginates the whole page vertically). Text in a scrollable box (overflow: auto or scroll) is kept as far as the box can be scrolled, even past the page edge or a clipping parent, as long as the box itself is visible. Text the box cannot be scrolled to is left out there too (for example an element inside it moved before its start edge with text-indent: -9999px, left: -9999px or an off-screen transform), and so is the part of a scroll box's content that a clipping parent never lets into view; a scroll box that is itself cut away takes its text with it. A box with mandatory scroll snapping (scroll-snap-type: ... mandatory) can only come to rest on its snap points, so text before the first snap point (which the preview never shows at rest) is left out as well. Text inside elements nested more than 60 levels deep is kept as plain paragraphs (its words stay, its layout does not), still without the hidden text above. If every word of a document is hidden this way the conversion fails with convert_empty. The converter counts the items it left out (text nodes, and on a slide whole shapes off the slide) because they are clipped, off the page or visually hidden by clip, clip-path or a zero scale, and the closed <details>, content-visibility: hidden and hidden="until-found" content above (hidden_dropped; it counts items left out, so one slide element can count as its shape and its text); text hidden by display: none, visibility: hidden or opacity: 0 is left out without being counted. It also counts the paint lookups that failed and kept their text (snap_miss); the gateway logs each count once as a warning and the response does not carry them. Slide decks (PowerPoint and Impress) follow the same rules, slide by slide: screen-reader-only text and captions, and text cut off by an overflow: hidden or clip box, are not written to the slide. A slide is its own page, so only the clipping and hiding set on the slide's contents and the slide's own overflow counts; a word is judged against the slide's own box, not the browser window. Effects set on elements outside the slide (an ancestor's overflow, clip-path, transform: scale(0) or opacity: 0) are ignored and the slide's text is kept. Parking on the slide element itself (a clip-path that shows nothing, a zero clip rect, a singular transform) is ignored as well, while the slide's own overflow: hidden still cuts its content. When the snapshot budget runs out part-way, the text it did not measure is kept. A slide with a running animation that ends is not measured and keeps all its text. visibility: visible inside a visibility: hidden box is still left out in decks. A deck made of printed pages (not .slide boxes) uses the page rules above. The counts hidden_dropped and snap_miss are reported as for Word.
  • Masked text (Word, OpenDocument, PowerPoint and Impress): text the page masks with -webkit-text-security (disc, circle or square, as on a password-style label) is written as the glyphs the preview draws (• ◦ ■), one per character including spaces, never as the real characters; an unrecognised value is treated as disc. The mask is applied after text-transform, so ß set in upper case becomes two glyphs, and a child that sets -webkit-text-security: none is written as plain text (except inside a masked SVG drawing, where all drawn text is masked). The same holds for list-number markers of an ordered list (a bullet or the disclosure triangle is a symbol and stays), the legend "Details" of a masked <details>, text generated with ::before or ::after, SVG <text>, and the alternative text of a picture. Text with no ink at all (font-size: 0, or a fully transparent glyph fill without a gradient clip, stroke or shadow) is left out like any other hidden text; text whose block container is restyled by a ::first-line or ::first-letter that paints a visible colour still has ink where that pseudo-element applies, so its words stay: the rule of the container itself or of a block ancestor that reaches it as its first in-flow block child, ::first-line for text starting on the container's first line, ::first-letter for the container's first painted text; text further down is left out. SVG text is masked as a whole: when the <svg>, one of its ancestors or any <use> inside it is masked, every text node of that SVG (white space included) is written as glyphs, and when any SVG <use> on the page is masked, or any <use> link is not a plain #id (an external file, a url(...) or an empty link), the text of every SVG drawing that another <use> references is written masked as well (the glyphs in the text, the alternative text and the embedded drawing; if a link cannot be resolved, every SVG with a <symbol> or <defs> counts), including text drawn through a <use> of a <defs> or <symbol> definition, which takes the <use>'s mask rather than its own; the SVG <title> that stands in for the alternative text of such an SVG is masked too. The values of form fields (<input>, <textarea>) are not written, masked or not. Text that a web component (shadow DOM) shows through a <slot> is judged by the slot it is shown in, not by the element that holds it in the page source: the slot's masking, transparent or zero-size text and visibility decide, for open and closed components alike. Light text that no slot shows is not painted by the preview and is left out. Reading closed components costs one bounded page snapshot per conversion, capped at 32 MiB (typically about 0.05 s extra on a small page, within measurement noise on pages of a few kilobytes). If that snapshot cannot be read, or a page has more than 1000 closed components, the conversion is refused rather than guessed: the converter reports invalid_layout (reason closed_shadow_roots_unreadable, written to the gateway log only), which the caller sees as the generic conversion failure (502 convert_failed, "The conversion failed."; the document tool answers "the conversion failed"), and no file is produced.
  • Borders, boxes and rules: a border-bottom or border-left becomes a paragraph border (a callout keeps its bar and the padding between bar and text); <hr> and painted rules become rules. A box or rule narrower than its column (a max-width, a percentage or fixed width, an <hr> with a width, a block centred with auto margins) keeps its width and its offset, measured as a share of the box's own parent and applied to the Word text column, so the border does not stretch across the page. A real table that is narrower than its container keeps that share of the column. A real table that sizes itself to its content (no percentage width) keeps its own measured width instead, never narrower than its widest cell content and never wider than the text column, so a memo's key / value header block is not squeezed into wrapped lines. Rules and separators are decoration: when a document runs out of the block budget (2000 blocks) they are dropped rather than refusing the document, so every other block counts toward convert_too_large (blocks): paragraphs, headings, lists, tables, callouts, pictures and page breaks.
  • Label columns (Word and OpenDocument text): a short label followed by its value on the same line keeps the value in the column the preview shows: the converter measures where the value starts and writes one tab stop at that position instead of the spaces a browser collapses, so the values of consecutive lines line up. Only a fixed-width label (an inline-block, inline-flex or inline-grid element whose width / min-width leaves slack after its text) that has no background or border of its own, is the first thing on its line, and sits in a left-aligned (or justified) left-to-right paragraph or heading that is not white-space: pre, pre-wrap, pre-line or break-spaces, fits on one line and has a value on the same line gets a tab; a bold <span> or a plain Label: value line without that fixed width keeps its single space, as do lists, slides, right-to-left paragraphs and centred or right-aligned lines. A value that would have no room left beside the column (the stop would squeeze it into a sliver) also keeps a single space, and so does a value in its own right-to-left or isolated direction (dir, <bdo>, unicode-bidi). A line has at most one tab: only the first fixed-width inline box on a line becomes the label column (an icon box in front of the real label takes the tab and the label keeps its single space), and a fixed-width box nested inside a label never adds a second one - the tab sits after the outermost label. The converter does not measure the label in the document's own font: if Word or LibreOffice draw the label wider than its stop, they move the value to the next default tab stop.
  • Colour: a semi-transparent colour is written as the colour it shows: fills (callout and highlight backgrounds, table-row and cell fills), borders, rules and text are blended over what is behind them (the page, or the colour of the cell or block the highlight sits in). A border or rule that is white or nearly invisible once blended is left out, and so is a highlight that would be unreadable behind its text. Text that a kept fill would leave unreadable (under 1.5:1, even when the source had the same low contrast, such as white on #f4f4f5) is darkened (or lightened on a dark fill) until it reaches 4.5:1 against that fill, in Word and OpenDocument alike.
  • Spacing: paragraph spacing, zero included, is written explicitly, so Word's own defaults never add space the preview did not have. A wrapper's top or bottom padding is added to the spacing of its first or last block (the padding above the page's first block is the page's top margin instead), an empty block with a height and nothing painted (a height: 40px spacer) spaces its neighbours by that height (also next to a table, list, callout or picture), and a table keeps its collapsed top and bottom margin (see below).
  • Reading order: a layout built from flex or grid columns is written as a table, and its cells follow the preview's visual order (a flex order, flex-direction: row-reverse or grid-template-areas that puts the second element first is written second-to-first as it looks), not the order of the HTML source.
  • Highlights and box widths: a highlighted span keeps its background. A callout (a box with a fill or a border that is not a page-like sheet, written as a one-cell table) and a real table that are narrower than their container keep their width and their left, centred or right placement. A callout's width share is measured against the page's text column (not the browser window), and its padding becomes the cell margin. A page-like sheet (a wide box that repeats as a sibling of the same tag and class, such as one div per page, or one that holds three or more blocks) is not a callout: it flows as the page, its border and fill are dropped, and its padding sets the side and top margins. A sheet that is at least 90 % of an A4 page high and is followed by a sibling sheet starts a new page.

Approximated (Word):

  • Word uses its own fonts, so line breaks inside a paragraph can fall at other words than in the browser; the order, rows, alignment and rules are kept.

OpenDocument text is written from the same layout as Word: the page margins and the text column, paragraph borders and padding (a callout, a quote bar, a rule), highlighted backgrounds, the label columns, the space above and below tables and boxes, and right-to-left blocks. Two bordered blocks that look alike stay two boxes (a one-point empty line separates them, since the format cannot say "do not join"). A tab stop is set in the same place as in Word. The same fidelity measures as for Word apply (text, alignment, rules, line breaks and vertical position against the preview). Still approximated: nested lists keep bullet or number but not the per-level numbering style (a. inside 1.), and the placement of a table narrower than its container is approximated. List and picture spacing is written as margin-styled empty paragraphs, so the space is kept but is not part of the list or picture.

Word's side margins follow the preview's text column (Word and OpenDocument text): the converter measures the horizontal span of the page's laid-out body text (a letter on a 210 mm sheet with 25 mm side padding gives a 160 mm column) and, when that column is not wider than an A4 page, sets Word's left and right page margins so the text column is that wide and centred (margins between 10 mm and 40 mm). The top margin follows the preview the same way: it is the distance from the top of the document to the first block of the page (a letter with a 25 mm top padding gets a 25 mm top margin, again kept between 10 mm and 40 mm); the bottom margin stays 2 cm. Tables, pictures and bordered blocks are sized to that width. A page without a measurable column, a wider one, a landscape page and every slide deck keep the standard 2 cm margins. A malformed internal column is rejected with invalid_layout instead of being ignored. Table spacing and blank lines (Word and OpenDocument text): a table, side-by-side row group or callout box keeps the preview's space above and below it (its collapsed top and bottom margin), written as an exact-height empty line before and after the table, since Word tables have no space-before. Two <br> in a row become one blank line, three become two; a single <br> at the start or the end of a text block adds none. OpenDocument text writes the same space as empty lines.

Extreme values are shortened, not refused. Every length the converter takes from the page is cut to the range the document format allows, wherever it comes from: a block's margin and padding (margin-top: 6000px on a paragraph, a rule, a table or a box), a border's width (border-left: 9000px), a table cell's padding (including padding folded in from a flex or grid row, or from the gap between two stacked rows), an indent, a line height, a font size or letter spacing. The page's own <hr style="margin: 9000px 0"> therefore converts, with a shortened space, instead of failing the conversion. Only an internal value that is not a number, or lies outside these ranges after the cut, is rejected with invalid_layout. In Word a box's start offset and width and the spacing are also kept inside the column and inside Word's own spacing limit. Presentations (pptx / odp) follow the same rule: a text block's line height, a corner radius and a cell's padding are cut to the allowed range; a shape's position and size inside 1 000 000 px are kept exactly (a shape, text, table or picture that reaches the slide from beyond 1 000 000 px is refused as slide_size; one that lies entirely off the slide is left out and counted in hidden_dropped), and a picture's alternative text is shortened to 2000 characters. A slide table of more than 600 rows, 64 columns or 6000 cells is written as text boxes instead of a table. Content, by contrast, is never cut silently: more than 400 runs in one paragraph, 400 lines in one text block of a presentation, 20000 characters in one run, a link target over 2048 characters, or a slide taller or wider than 1 000 000 px answer 422 convert_too_large with the matching cap and limit.

Font fallbacks (Word and OpenDocument text). The extracted document carries fonts: a map from each family a run uses to {"fallback": [up to 3 further families from the page's own font list], "generic": "serif" | "sans-serif" | "monospace" | "cursive" | "fantasy"} (both optional; absent means {}). The converter writes them into the file next to the family name, which stays the first CSS family: in a .docx as w:altName (first fallback), w:family (roman, swiss, modern, script, decorative) and w:pitch (fixed for monospace, otherwise variable) in word/fontTable.xml; in an .odt as an svg:font-family list (Georgia, 'Times New Roman') plus style:font-family-generic and style:font-pitch. A face the converter embeds gets no fallback (the file carries the face itself). Word uses all three hints; LibreOffice uses w:family and w:pitch to pick a substitute of the right kind (serif, sans or monospace) and ignores w:altName; in an .odt a list loses to its own substitution for some names (Georgia), so a file opened there without the font can still be set in a wider face than the preview. A fallback list holds at most 3 names (the family itself and case-insensitive duplicates are dropped, the first occurrence kept) and the map at most 64 families; a name is 1..80 characters without , ; " ' \ < > & or control and format characters, and not made only of spaces or other separator characters. A fonts value of the wrong shape, a name that breaks that rule or a generic outside the list is rejected with invalid_layout, and the safety check (doc_safety) rejects a package whose w:font / style:font-face carries a hint outside the same vocabulary. Decks (.pptx, .odp) carry no fonts and get no fallback hints; a deck's embedded faces are unchanged (an .odp matches a family to the embedded font registry case-insensitively, so montserrat embeds the same face as Montserrat).

A label's tab stop (see Label columns above) is the one value that is not shortened: an internal tab run is accepted only as the single tab of a paragraph or heading line, as a bare tab character with a finite position greater than 0 and within the text column limit (20000 px) and without a link or highlight of its own. A tab run whose position is null, negative, zero, non-finite, over-range or non-numeric (a run without a tab key is an ordinary text run), a second tab in one line, or a tab inside a list item or a slide is rejected with invalid_layout, never written as a space or ignored.

The first block's margin still counts in full when the top page margin is measured, so a huge margin on the first element does not move the text off the page.

A flex or grid row that has fewer items than its columns keeps each item in its own column (an item placed with grid-column: 3 stays in the third column). Comments, <script>, <style> and hidden elements between two such rows do not split them into separate tables. Flex and grid rows that become layout tables have a budget of their own (6000 rows, 24000 cells); once it is spent, further rows are converted as plain paragraphs instead of failing the conversion.

List items with several lines (Word and OpenDocument text export): a list item keeps all of its text, also after a <br>, after a preview line break (white-space: pre-line) and in a nested <p>. In Word only the first line carries the bullet or number; the following lines of the item are plain paragraphs aligned with the item's text. In OpenDocument text they are further paragraphs of the same list item. Long content is never refused for its number of paragraphs: an item (or a box, or a block of preformatted text) with more than 400 paragraphs is split, and in Word the lines past the 400th follow the item as unnumbered paragraphs at the item's text indent.

Request body (JSON) — every field is validated before anything else happens; a field that is absent and one that is malformed are both rejected with 400:

Field Type Required Accepted Rejected (400)
conversation_id string yes the id (UUID) of a conversation the caller owns absent, not a string, not a UUID
source object yes exactly one of { "attachment_id": "<id>" } (an HTML file attached to this conversation), { "file_id": "<id>" } (an HTML file a tool wrote in this conversation), { "html": "<markup>" } (an inline HTML artifact) absent, not an object, zero or two keys, an unknown key, a non-string or empty value, an id that is longer than 64 characters or contains anything but letters, digits and -
format string yes pptx, odp, pdf, docx, odt (lower case) anything else, including an array
filename string no the download base name (≤ 255 bytes); trailing .html/.htm/target-extension suffixes are removed repeatedly (trailing dots and spaces are trimmed before each check), then the target extension is appended; a leading dot is kept (.bashrc becomes .bashrc.<ext>); / and \ are replaced by _; invalid UTF-8 becomes U+FFFD; double quotes ("), ;, control characters and invisible format characters are removed; Unicode spaces (such as NBSP) inside the name become ASCII spaces and surrounding spaces are trimmed. A name that is empty after cleaning, or made only of dots and spaces, gets the dated default (slides-YYYY-MM-DD / document-YYYY-MM-DD), and so does a cleaned name over 255 bytes (it is never cut). The app sends it only with {html} — for a stored source the server uses the file's own name not a string, longer than 255 bytes

Unknown top-level fields are rejected too. The whole request body is capped at 16 MB by the edge (413 payload_too_large); the HTML itself at 8 MiB (413).

Where a source may come from. Every source is bound to the conversation named in the request and to its owner: an attachment of another conversation, another user's file, or a project file that is not linked to this conversation answers 404 — exactly like an id that does not exist (no existence oracle). A generated file stays reachable after its conversation was moved into a project. Images the HTML references by a bare relative name (<img src="logo.png">, url(chart.svg)) are taken from the same conversation (attachments and generated files, exact name), checked by their real file type; at most six are used, chosen largest first within the job's remaining byte budget; a reference that cannot be resolved is left out and reported (see below) — it never fails the conversion.

When it is available. Conversion runs in the code-interpreter sandbox, so it follows the same gates as the code-interpreter tool for the conversation's gateway: the sandbox fleet is configured and the gateway has not opted out of the code interpreter. The conversation's project tier is not consulted — a conversation in a Tier-1 local only project converts like any other, because the sandbox is Myra-owned infrastructure inside the estate with no network access. (The one exception: if the deployment's sandbox address is not inside the Myra estate, local only conversations get a permanent 409 not_in_estate — or a retryable 503 tier_unresolved while the conversation's project binding cannot be confirmed — see Code interpreter.) It is not a separate setting. The app shows the menu only when the conversation object it holds — from GET /admin/v1/conversations/<ID>, or from the create / fork / continue response — carried html_convert_available: true; after a permanent 409 it hides the menu until the conversation is loaded again.

Response: the converted file (HTTP 200, Content-Disposition: attachment; filename="…"; filename*=UTF-8''…, always listed in Access-Control-Expose-Headers so a cross-origin client can read it — the name is the caller's filename, else the source file's name, else slides-YYYY-MM-DD / document-YYYY-MM-DD; the name is cleaned as described for filename above). When images were left out, the response carries X-Aig-Convert-Skipped: a percent-encoded JSON array of the image names (exposed cross-origin; at most 8 names of at most 80 bytes, and at most 1500 bytes in all, so a page cannot make the header too large for a proxy). The file carries no AI-generated notice — it reproduces an HTML document, which may be the user's own.

How the document is laid out:

  • Decks (elements with class slide / a data-slide attribute, or two or more full-width <section>s with a slide-like aspect ratio) become one slide per section in pptx/odp, one page per slide in pdf, and a landscape document with a page break per slide in docx/odt. Every slide is converted un-transformed and shown, on the slide itself only: its transform is reset (a slide scaled by the page's script is converted at its own size, e.g. 1920×1080 px), it is never shrunk by a narrower flex container, transitions on it are switched off, a slide hidden by visibility or opacity — also by the page's own !important rules — is shown (a slide designed translucent keeps its opacity), and it stays the containing block of what it pins (position: fixed content inside a slide is placed on that slide). Everything around the slides is kept as it is: a wrapper's scale or zoom, the slides' position and their display. A deck whose slides sit on top of each other (a presentation mode pinned with position: fixed / absolute, or overlapping slide boxes), or one with a slide that shows text but would print a blank page (its text hidden another way — moved off the slide, content-visibility, a hidden child; text the author keeps from painting on purpose, such as a screen-reader-only label, does not count), cannot be printed one slide per page: the PDF answers 422 convert_deck_unprintable with the next step (download it as PowerPoint, or ask for a version whose slides are laid out one below the other) — never a PDF with missing slides. The same answer applies to any deck whose slides sit inside a position: fixed stage (a fixed viewport that shows one slide at a time, or a fixed track moved by translateX) and print fewer pages than there are slides, whether or not it takes the deck preparation below; such a page used to fail as 502 convert_failed. Its PowerPoint export is unaffected. A <section> deck whose hidden sections are display: none is recognised as a deck only when its slides carry class="slide" or data-slide.
  • Print preparation and animations. Before its scripts stop, a deck built on the presentr template is put into its static layout through the template's own layout function (every format). For any other page, the page's beforeprint listeners run once — only for a PDF, and only when the page is a deck whose slides would not print one per page as loaded (pinned, transformed or hidden); a page that prints fine (a chart library's print resize, for example) is never given beforeprint, in any format. Only these two kinds of deck (a template deck, or a paged deck that would not print one per page as loaded) take the deck preparation — slides shown and un-transformed, finite entrance animations shown finished, scroll-driven and endless ones kept at their current frame. That frame is checked against the deck's un-animated state: only when text the un-animated deck shows is hidden or moved at that frame (a scroll-driven fade, a rotator) is the conversion convert_deck_unprintable — a pulse, a colour cycle or an animated background converts as before. Every other page is printed exactly as before (only the failure code of a fixed-stage page that prints fewer pages than slides changed). A deck is then converted in screen media (@media print rules do not apply to it; a non-deck page's PDF keeps its print layout). matchMedia('print') listeners never run, and there is no afterprint: anything a listener changes for print (a chart resized to a print width) is converted as the listener left it, and so is anything else a script left (a class, a number). A listener that throws is ignored; one that does not return within 5 seconds is stopped and the conversion ends as convert_deck_unprintable; a template layout function that throws or does not return within 5 seconds counts as absent (the deck converts as loaded); a page that navigates itself away or rewrites its document (document.open / write, a javascript: URL) — during load, from a listener or from the layout function — ends as 422 convert_open_failed. Console output, script errors and any other browser event the converter does not use (a window.open, for example) are never read: any amount of them neither fails the conversion nor grows its memory; a single event the converter does use that exceeds the browser channel's 64 MiB message limit ends as 422 convert_too_large (a navigation: convert_open_failed). The whole stretch in which a deck's script runs again (the layout function or the listeners, then what they changed settling, then scripts stopped again) is limited to 13 seconds: a deck that keeps the browser busy there — a timer its layout function or a listener starts that never yields — ends as convert_deck_unprintable within that time, never by using up the conversion's whole time. A page that keeps the browser busy while it is still loading (before its scripts are stopped) ends as 504 convert_timeout, as before. Whether the deck is still the document that was loaded is checked from the converter's own isolated script context; the page never sees a converter marker it could copy onto a rewritten document.
  • Other pages become one slide in pptx/odp (the whole page, scaled to fit — never split), the page's own print layout in pdf, and a flowing A4 document in docx/odt (headings, lists, tables, cards as borderless tables, charts as pictures).
  • Dropped generated text and labels (all formats): a deck export (pptx / odp) counts generated text and list labels it cannot write exactly the same way as the Word and OpenDocument exports above (the converter counts, the gateway logs a warning; the response does not carry it).
  • The deck typefaces (Montserrat, Selawik) are embedded, so the file looks the same on a computer without them. Links keep http, https and mailto targets; a link to a heading of the same page becomes an internal link; anything else becomes plain text.
  • Repeated pictures (pptx / odp): a picture that several slides share (the same background, grid or logo box with the same appearance and size) is rendered once, counts once toward picture_area and pictures (every use still counts toward picture_refs, 1000 per deck) and is stored once in the file, so a deck of up to 200 slides (cap: slides, limit: 200) with a common background converts. Slides with genuinely different full-slide backgrounds still count each. A deck that needs longer than the conversion time limit ends as 504 convert_timeout; its body carries done and total (slides finished of slides in the deck) when known. The web chat names the reached cap of a 422 convert_too_large in its message.
  • Large photos (embedded data: images and referenced conversation images) are scaled down before rendering to what the sandbox can hold (about 4 megapixels each — still more than twice a slide's resolution); a JPEG stays a JPEG. A non-JPEG picture above 50 megapixels cannot be processed and the conversion answers 422 convert_too_large (cap: picture_area); so does a picture whose box is wider or taller than 16384 pixels (limit: 16384) or larger than 40 megapixels (limit: 40000000; for example an image with a huge padding).

Output safety. The HTML is hostile input: it is rendered offline inside the sandbox (no network, page scripts stopped once the page has loaded and prepared — the presentr template's layout function, or, only for a PDF of a deck that would not print one per page as loaded, its beforeprint listeners; every request outside the document itself refused), and the produced file is treated as untrusted too. Before delivery the gateway checks it against a positive allowlist of exactly what the converter writes — anything else rejects the whole file (502 convert_failed):

  • the tables are within the converter's document budget (rows and cells of all tables, plus the header rows an OpenDocument text repeats), and no OpenDocument table is longer than 600 rows or wider than 64 columns — checked, together with the element allowlist, on both content.xml and styles.xml before the ODF schema validation, whose cost grows steeply with the size of one table. A long table is written to an .odt as consecutive tables of at most 500 rows, each repeating a header of up to five rows when that header holds only text; a Word file keeps it as one table whose header row repeats on every page;
  • the package's XML is within its budget — 12 MiB for an OpenDocument file, 32 MiB for PowerPoint and Word — read from the package directory before any part is parsed; the converter refuses a larger result itself (422 convert_too_large, cap: document_xml). The vector (SVG) copies of all pictures together stay within 4 MiB; the converter keeps further pictures as their PNG capture;
  • every package part has an expected name; pictures are PNG (rules below) or SVG that is byte-identical to its re-sanitized form; embedded fonts are rebuilt from the bundled fonts and compared byte for byte;
  • every XML part and SVG picture, before it is parsed: no DOCTYPE; at most 256 attributes on one element (namespace declarations included), at most 64 namespace declarations in scope at once and at most 64 levels of nesting; at most 10,000,000 bytes in one text run or attribute value; encoded in UTF-8, UTF-16, ISO-8859-1, US-ASCII or a single-byte character set (a multi-byte one such as Shift_JIS or GB18030 is refused);
  • every XML part: nothing outside the root element; only the elements and attributes the converter writes; pptx/docx relationship types compared in full, and each reference bound to the kind of relationship its element requires (a picture to an internal image, a link to an external hyperlink); PNG pictures structurally valid with nothing after the image; embedded fonts rebuilt and compared byte for byte.
  • pptx/docx: only the XML elements the writers emit; no field codes, macros, OLE/ActiveX, external data or embedded packages; relationships only of the expected types, external ones only http/https/mailto hyperlinks;
  • odp/odt: valid ODF 1.3 plus the same element allowlist; every reference package-internal except http/https/mailto links;
  • pdf: checked on the parsed object model (indirect objects followed): not encrypted or damaged; only link annotations, whose actions are URI (a plain http/https/mailto string) or GoTo; no JavaScript, open/automatic actions, file specifications, embedded files, forms or XFA; stream filters only FlateDecode (and DCTDecode on pictures); no inline images.
    • pictures: 8-bit RGB or greyscale (no colour profiles), either raw pixels of exactly the image's size or a plain baseline JPEG with no metadata segments and nothing after its end; at most 16384 pixels per side, 40 megapixels per picture and 160 megapixels per document (larger pictures are scaled down during conversion). The converter never copies a picture's original bytes: a JPEG from the page is decoded and encoded again, and the gateway decodes and re-encodes it once more for the delivered copy.
    • fonts: TrueType only (FontFile2), with only the outline, metric and naming tables and no hinting programs — the converter removes them from every embedded web font, the gateway refuses any font that still has one and delivers its own re-serialization of each font. Each font is bounded on its own, and all fonts of the document together to 6 MiB of glyph outlines, 500,000 glyphs and 1.5 million points in composite glyphs (fonts embedded in a PDF are subsets, far below this); the character maps (ToUnicode) together to 8 MiB, calculator functions to 512 KiB, the page content to 2.5 million drawing operators (4 million values in any one content stream), and the whole file to 300,000 objects and entries; and all of these together to what the check can verify in time. An identical font program is checked once, and each part of a page's content is also checked on its own. The converter applies the same budgets while it builds the PDF (422 convert_too_large, cap: font_outlines, font_glyphs, font_composites, tounicode, functions, content, pdf_objects or pdf_complexity). The check itself runs under a time limit; a file it cannot finish checking in time is refused, never delivered. Every file the converter itself produces is within the budgets above and is checked in a few seconds; only a hand-crafted file can reach the limit.
  • links everywhere: http, https or mailto without whitespace, backslash or control characters; a mailto keeps only its to, cc, bcc, subject and body fields (anything else, e.g. attach=, is removed).
  • pictures (pptx/odp/docx/odt): PNG only, at most 16384 pixels per side, 40 megapixels each and 160 megapixels per document, not interlaced, the pixel data exactly the image's size, no embedded colour profile; a PNG inside an SVG follows the same rule.

The file you download is the gateway's normalized copy of the checked output — re-packed from the checked parts (no extra data, comments or hidden entries) or, for a PDF, re-saved from the checked object graph — never the sandbox's original bytes. The artifact size limit applies to that copy.

Status code Meaning
200 — the file
400 — the body failed validation (table above); error names the field, e.g. unknown field, source must have exactly one of attachment_id, file_id, html
401 / 403 — / viewer_read_only not signed in / a viewer (read-only) account; demo sessions and impersonation are refused too
404 not_found the conversation is not the caller's, or the source is not in it
409 convert_unavailable not available for this conversation — permanently (reason: no_gateway, gateway_gone, gateway_unreachable (the caller can no longer reach that gateway), not_configured, disabled, not_in_estate (a Local only conversation while the deployment's sandbox address is outside the Myra estate))
409 convert_not_ready the file is still being processed — try again shortly
413 convert_too_large the HTML exceeds 8 MiB
422 convert_not_html / convert_no_file the source is not an .html/.htm file / has no content
422 convert_open_failed / convert_empty / convert_bad_input the page could not be opened / shows nothing / is not HTML (binary)
422 convert_deck_unprintable a deck that cannot be converted slide by slide: pdf — its slides sit on top of each other (a presentation layout), are kept in one fixed window by a position: fixed stage (only one slide would print), or a slide that shows text would print blank (convert it to pptx instead); any format — a scroll-driven or endless animation keeps moving its slide text, or the deck's own script does not finish preparing it (a beforeprint listener that does not return within 5 seconds, or a timer the listener or the layout function starts that keeps the browser busy past the 13-second limit). Lay its slides out one below the other, without animated text
422 convert_too_large the result would exceed a limit (cap, limit say which: slides, pictures (300 distinct pictures; a picture a deck repeats counts once), picture_refs (1000 picture items in a deck in total, repeats included), picture area, blocks, the tables of the document — table_rows (6000 rows) or table_cells (24000 cells, counted as rows × columns of the real tables only; layout rows have their own budget and fall back to paragraphs) —, list_items (2000 items in one list), runs (400 runs in one paragraph — also in a presentation), paras (400 lines in one text block of a presentation; Word / OpenDocument text split such a block into paragraphs), run_chars (20000 characters in one text run), href (a link target over 2048 characters), table_cols (a document table of more than 64 columns — Word / OpenDocument text), slide_size (a slide or page over 1 000 000 px in width or height, including content that overflows it), document_xml, items_total (20000 drawing shapes in a presentation — a box whose four borders differ counts once per drawn border), the budgets of a PDF — font_outlines, font_glyphs, font_composites, tounicode, functions, content, pdf_objects, pdf_complexity —, extraction (the page's layout is too large to read out), or the gateway's file-size cap for generated files)
422 convert_unsafe_file the HTML or a picture it uses was refused by the sandbox staging safety check (an XML DTD / entity declaration, an unreadable encoding, an unsafe archive) — see Inference › Files a sandbox tool will not open
429 convert_rate_limited more than 30 conversions per user per minute (Retry-After)
502 convert_failed the conversion failed, or the produced file failed the safety check. The converter's logs tell a renderer that was killed from outside apart from one that crashed; the response is the same
503 convert_unavailable temporarily unavailable (reason: config_error, converter_missing, tier_unresolved (the conversation's project binding could not be confirmed while the sandbox address is outside the Myra estate), or a storage fault) — retry (Retry-After)
503 convert_busy all conversion slots (4) or sandbox runners are busy — retry (Retry-After; the web chat retries it automatically, 3 requests at most)
504 convert_timeout the conversion took too long (done/total give the slides finished, when the converter got far enough to report them)

The name in Content-Disposition follows RFC 6266: the quoted filename parameter is an ASCII fallback (each non-ASCII character and each % becomes _), and filename*=UTF-8''… carries the exact name, percent-encoded per RFC 5987. Invalid UTF-8 in a requested name is replaced by U+FFFD, and control and invisible format characters (bidirectional overrides, zero-width characters) are removed. A name that is empty after that, or made only of dots and spaces (for example ., .., . . .), is replaced by the endpoint's default name. A client that knows the name it wants (as the app does) may still prefer its own.

A conversion has a 90-second budget (up to 60 seconds of it in the sandbox). A client that disconnects does not cancel it (the slot is released when it finishes).

The convert_document chat tool

The same conversion is offered to the assistant as the tool convert_document wherever the code interpreter is available in a saved conversation the caller owns. Its arguments come from the model and are validated before anything is read:

Argument Accepted Rejected (the tool answers with an error text, nothing is read)
format pptx, odp, pdf, docx, odt absent, any other value or type
file a file name (trimmed, ≤ 255 bytes); null, empty or omitted means "the newest HTML file of this conversation" a non-string, longer than 255 bytes

The conversation must be the caller's own, live conversation; a name is looked up among this conversation's attachments and generated files first (the most recent of them wins — for a generated file that is its last write, so a file changed with edit_file counts as new when it was edited), then — only when named explicitly — among the files of the conversation's project the caller can read. An unknown name returns the list of available HTML file names (fenced as untrusted text). The tool shares the endpoint's limit of four concurrent conversions and is refused before converting once the reply's file limit is reached.

The converted file is named after the source (its stem + the target extension, a -NN suffix when the name is taken). A source stem longer than 242 bytes is not shortened: the file is named slides.<format> (pptx, odp, pdf) or document.<format> instead — the stored name is repeated to the model, and a cut name could carry a fragment of personal data no masker recognises.


Audio transcription

POST /admin/v1/chat/transcribe — transcribe a recorded audio message to text. The web app sends the browser's native recording as-is (WebM/Opus on Chrome/Firefox/Android, Ogg/Opus on Firefox desktop, MP4/AAC on Safari); the gateway re-encodes it to Opus server-side and retries on an empty transcript. It does not decode or re-encode client-side — sending the compressed recording (rather than a WAV) is what keeps a multi-minute recording under the per-request cap. The common browser codecs are handled by the image's stable ffmpeg; a rarer codec that only a native upload could carry — notably xHE-AAC / USAC in an MP4 container — is decoded best-effort by a modern fallback ffmpeg that the server uses when the primary decoder produces no audio.

Recordings without speech are answered with 422 no_speech, not with invented text. Speech-to-text models produce plausible phrases ("Thank you.", "Vielen Dank.", "you", " .") for silence, background noise or garbage input. The gateway checks the audio before transcription and the result after it, and rejects the known classes of such output (see Validation below). The checks cannot catch every case: a noise-only recording longer than 25 seconds gets only the result check, and a phrase the model produces with timing that looks like real speech is passed through.

Request body (JSON):

Field Type Required Description
audio string yes Audio bytes, base64-encoded. Maximum 10 MiB of decoded bytes per request — for a compressed recording (~64 kbps) that is roughly 20 minutes of speech — and at most 30 minutes of decoded audio. The bytes must be one of the accepted containers below.
mime_type string no Advisory container hint (e.g. audio/webm). Never used to decide how the bytes are decoded — the server identifies the container from the bytes themselves.
language string no ISO 639-1 language hint (the web app sends its UI language). Used only when the caller has no fixed dictation language: the first attempt then auto-detects the spoken language, and only a retry after an empty result uses this hint. Its first two letters must be one of en, de, fr, es, it, nl, pl, pt; anything else is ignored (auto-detect). When the caller has set a fixed dictation_language (PATCH /admin/auth/me), that language is used on every attempt and this field is ignored.

Response: { "text": "<transcript>" } — always non-empty. (Changed: a recording that yields no text used to return 200 {"text": ""}; it now returns a typed 422 — no_speech or empty_transcript — so a client can never mistake "nothing heard" for a transcript.)

Accepted containers. The server identifies the container from the first bytes of the decoded audio (its magic number) and decodes it only with the matching decoder — it never lets ffmpeg guess a format: WebM/Matroska, Ogg, MP4/M4A/3GP (ISO-BMFF ftyp), WAV (RIFF and RF64), FLAC, AIFF/AIFC, CAF, ASF/WMA, AMR, FLV, MP3 (an ID3v2 tag or a valid MPEG-audio frame header) and ADTS AAC (an ID3v2 tag is skipped and the audio behind it identified). Anything else is rejected with 415 unsupported_audio before any decoding.

Validation (untrusted input — fail closed).

  • audio is required and must be a base64 string — any non-string value (a number, boolean, JSON null, or object) is rejected with a 400. mime_type and language are advisory and untrusted: a non-string value is silently ignored (treated as absent), never a 400.
  • Absent and malformed are different answers: a missing audio is 400; bytes that are not an audio container are 415; a recognised container that cannot be decoded is 422 undecodable_audio. None of them reaches the speech-to-text model.
  • Speech check (before transcription). The recording is re-encoded once (all of its metadata dropped) and the gateway measures how much of that audio is active (anything except stretches of at least 0.1 s quieter than −55 dBFS, which count as silence). Less than 0.15 s of active audio — silence, a muted microphone, the tap of the microphone button — is answered 422 no_speech without calling the model. (A WebM or Ogg recording stopped before its first audio block cannot be opened at all and is answered 422 undecodable_audio; a WAV or MP4 with no audio samples is no_speech.) A single spoken word at a normal level is well above this floor; a very quiet (below about −40 dBFS), short word can fall under it.
  • Speech detector (before transcription). A recording that clears the floor is then checked by a speech detector on the same re-encoded audio. Breathing, a fan, room noise or typing is not speech: if the detector finds less than 0.1 s of speech, the answer is 422 no_speech without calling the model. On a long recording the detector examines the start only and stops as soon as it has found enough speech. If the detector is unavailable or its answer cannot be read, the recording is transcribed anyway (the check fails open) and the result check below still applies.
  • Result check (after transcription). The model's answer is untrusted too. A transcript made only of punctuation or of sound-event captions (*Burps*, [Music], (Applause), ♪) is 422 no_speech. For recordings under about 25 s the gateway also requests the model's segment timing; a transcript whose earliest segment ends more than 5 s after the end of the audio (the model "decoding" its own padding — the signature of the silence hallucination "Thank you." / "Vielen Dank.") is 422 no_speech. A real spoken "Thank you." is transcribed normally: the gateway does not block phrases.
  • A malformed timing answer from the model (segments that are not a list, an empty list next to non-empty text, a non-numeric start, or an end that is not a non-negative number at or after its start) is a contract break → 502.

Error codes:

Status code Meaning Retry?
200 — Success — { "text": "<transcript>" }. —
400 — audio missing, not a string, empty, or not valid base64. Fix the request
403 viewer_read_only The caller is a viewer (read-only) account: speech-to-text spends inference credit. An impersonation session is refused too. No
413 — / too_long audio exceeds the 10 MiB decoded-bytes limit (no code), or decodes to more than 30 minutes (too_long, the recording is too long to transcribe). The web app caps recordings at about eight minutes. Record shorter
415 unsupported_audio The bytes are not one of the accepted audio containers. Send a supported format
422 no_speech The recording holds no speech (see Speech check / Result check). The web app shows "No speech detected — nothing was added to your message" and leaves the draft unchanged. Re-record
422 empty_transcript The recording had audio, but every transcription attempt (up to five) returned no text. The web app shows "Couldn't transcribe the audio — please try again". Re-record
422 undecodable_audio A recognised container from which no audio can be decoded at all — corrupt data behind a valid header, or a WebM/Ogg recording stopped before its first audio block. Re-record
422 unusable_audio The speech-to-text backend rejected the re-encoded audio with a 400 carrying Whisper's audio-reject signature ("Invalid or unsupported audio file") — overwhelmingly a too-short recording. Re-record
429 — Genuine saturation ("busy"). Either the gateway's local admission cap of two concurrent transcriptions, or the speech-to-text backend signalling a 429 rate-limit. Carries Retry-After: 5. Yes, shortly
502 — A permanent failure the client cannot recover by retrying — a contract break (non-JSON, missing text, malformed segment timing), a non-audio upstream 4xx such as 401/403/404, a misconfiguration 400 whose body does not carry the audio-reject signature (additionally logged at ERR), or the server's audio decoder could not be started, failed on its own re-encode, or failed re-encoding audio it had already decoded once. (The web app still offers Retry transcription after a 502: it cannot tell this gateway response from a 502 produced by an intermediate proxy.) No
503 — Temporarily unavailable — a transport failure (5 s connect deadline), an upstream 5xx, the server's audio decoding did not finish in time (on any attempt), or its file I/O was momentarily unavailable. Carries Retry-After: 5. Deliberately distinct from 429: an overload-503 and a hard-down-503 are indistinguishable, so a 5xx is never reported as "busy". Yes, shortly

A transient failure is reported as 429 (busy) or 503 (unavailable), never 502, so a client can tell "busy/unavailable, try again shortly" from "broken". The web app keeps the recording after a 429, any 5xx, or a request that never got an answer, and offers Retry transcription with the same audio; after any other status it asks the user to record again. The gateway does not auto-retry a 429/503 — the retry loop only re-attempts an empty transcript (the model's known intermittent-empty result). A punctuation- or caption-only answer is not retried: retries add the language hint, which can turn noise into a hallucinated phrase. Every 4xx body carries an English error message meant for logs; branch on the status and code, never on the message.

Outcome counter (operators). Every response of this endpoint — once the caller passed the impersonation and viewer checks and the request body was read — increments the Prometheus counter aig_transcribe_outcome_total{outcome=…} on the internal /metrics endpoint. outcome is one of a fixed set: ok, bad_request, too_large, unsupported_audio, no_speech, empty_transcript, undecodable_audio, unusable_audio, too_long, busy, unavailable, failed, client_aborted. The counter carries no audio, no transcript text, and no tenant or user label. A rising share of no_speech, empty_transcript, or undecodable_audio among all outcomes is the signal that the speech check rejects too many real recordings. A failed request whose client had already disconnected is counted as client_aborted instead of its failure outcome (the response status is unchanged); a transcription that succeeds is counted ok either way. A recording in which the browser captured no bytes at all never reaches the server, so it is not counted.

Speech detector counter (operators). aig_transcribe_vad_total{verdict=…} counts the speech detector's verdicts: speech, no_speech or unavailable (the detector could not run, so the recording was transcribed without the check). A non-zero unavailable rate means the check is not protecting dictation; the gateway log carries the marker AIG_TRANSCRIBE_VAD_UNAVAILABLE with the reason. The detector needs Python with onnxruntime; set AIG_SPEECH_VAD_PYTHON to the interpreter if it is not python3 on the path.

Live transcription (WebSocket)

GET /admin/v1/chat/transcribe/stream upgrades to a WebSocket and relays the browser's microphone audio to the streaming speech-to-text service, returning interim and final transcripts while the user is still speaking. The recorded-message endpoint above is unchanged and remains the fallback.

Authentication and origin. The browser session cookie authenticates the upgrade, exactly as for any admin route; there is no token in the URL and the URL carries no query string (400). A missing or invalid session is 401, a viewer or an impersonated session is refused, and a request without Upgrade: websocket is 400 websocket_required. The Upgrade check runs before the session check, so an unauthenticated request without it is 400 websocket_required (not 401) and a foreign Origin without Upgrade is 400 websocket_required (earlier 403 origin_forbidden). The Origin header is checked before the upgrade: an absent Origin (a non-browser client) is allowed, any other value that is not the admin origin is 403 origin_forbidden. The comparison is case-sensitive against the configured admin origin, which is lowercase (https://host); an Origin that differs only in case (HTTPS://Host) is refused. The configured admin origin must be a hostname origin (http(s)://host[:port]); an IPv6-literal origin is not accepted and the check then fails closed. Nothing is dialed upstream before every check passed.

Messages the client sends.

Frame Content
text, first exactly {"type":"start","encoding":"pcm_s16le","sample_rate":16000,"channels":1}
binary, after start raw little-endian 16-bit mono PCM at 16 kHz; an even, non-zero number of bytes, at most 32000 per frame (one second)
text, last {"type":"stop"} — flush: the relay returns the remaining final and closes 1000

The start message has no language key. The language is the user's stored dictation language (an allowlisted fixed value) or automatic detection; the browser never chooses it, and any extra key is rejected. An absent key is invalid_start; a wrong value is unsupported_format.

The browser captures the microphone with an AudioWorklet and, in parallel, a second tap (a MediaStreamTrackProcessor on a cloned track, else a script processor). If the worklet has delivered no samples within 700 ms while the second tap has, the capture switches to the second tap and the session continues; a worklet that delivers first keeps the capture. After such a switch the live preview continues, and the final text comes from the recorded upload whenever the second tap started too late to cover the start of the recording (it typically starts about a second later). If the worklet module cannot be loaded, the second tap is the only tap and, because that path settles only after the module timeout, the final text also comes from the recorded upload. Which tap carried the audio is decided by the signal alone, never by the browser's name.

Messages the gateway sends. Every message is a text frame.

  • {"type":"ready","language":"auto"|"<code>","limits":{"max_frame_bytes":32000,"idle_timeout_s":20,"max_session_s":600}} — audio may be sent from now on.
  • {"type":"partial"|"final","text":"…","lang":"…","t0":0.1,"t1":0.9} — exactly these five fields; nothing else from the upstream is forwarded. The gateway supports German, English and French only. A partial or final that the speech service reports in another, well-formed language (for example it) is dropped and does not end the stream: nothing of its text is forwarded or stored. A dropped partial is silent; a dropped final is answered with the notice below. A transcript whose lang is absent or not a language code (for example de-DE) is still an upstream protocol violation and ends the stream with internal_error.
  • {"type":"notice","code":"language_skipped","lang":"it"} — informational, the stream continues. A final transcript in a language other than German, English or French was dropped; lang is the language code the speech service reported. The web app clears the preview of the dropped words. Clients that do not know a notice frame can ignore it.
  • {"type":"error","code":"…","message":"…"} — followed by a close with the matching code. message is fixed gateway text; the upstream's own wording never reaches the browser.

Errors and close codes. An error frame is sent first (except where the handshake itself is refused with an HTTP status), then the close.

code Close Meaning
invalid_message 1008 not JSON, not an object, over-long text, an unknown or out-of-order message (stop or audio before start, a second start), a fragmented message
invalid_start 1008 the start message lacks a key or carries an extra one (including language)
unsupported_format 1003 the start message names another encoding, rate or channel count
bad_frame 1007 an empty or odd-length audio frame
frame_too_large 1009 an audio frame over 32000 bytes
idle_timeout 4000 no start within 10 s, or no audio for 20 s after it
session_limit 4001 the stream reached 600 s. The gateway sends stop upstream once, relays the final transcripts the flush produces, and only then ends the stream (at most 25 s later, so within 625 s of the start, plus at most 6.25 s of closing frames); client audio, stop and hang-up after that point change nothing
backlog_exceeded 4002 the browser sent audio faster than the upstream consumed it
not_entitled 4403 the workspace has no live_transcription_enabled
unsupported_language 4422 the user's dictation language cannot be streamed
too_many_streams 4429 this user already has an open stream on this gateway node
busy 4013 fleet at capacity — fall back to batch dictation. The ONE answer for every capacity form: this node is at its stream capacity (32), or the speech service is saturated (HTTP 429, server_busy, not_ready, or a close 1013 before it was ready) on every replica tried
unavailable 1013 the upstream is not configured, unreachable, dropped mid-stream or did not flush within 25 s
shutting_down 1001 the gateway is restarting
internal_error 1011 a gateway or upstream fault (including an upstream protocol violation, such as a transcript without a language or with a malformed one, or a rejected gateway credential). A transcript in a well-formed but unsupported language is not a fault: it is dropped, see notice

From the moment the gateway has read stop (before or after ready), everything the client sends is read and discarded without an error: text, binary, and a fragmented message (nothing reaches the upstream, nothing ends the stream, and none of it counts against the pre-ready hold). A client that closes the connection after stop is treated the same way in every state: the gateway still waits for ready, forwards the held audio and stop, relays the final transcript(s), and the flush decides the outcome (bounded by the 25 s flush wait plus the connect and ready timeouts). A client that vanishes after stop is different: when the gateway can no longer read from or write to the browser's socket (a socket error or timeout, an over-size or malformed frame, or a failed write of a transcript, close or pong), nothing more can be delivered, so the stream ends at once as client_closed (or session_limit when the 600 s cap started the flush) instead of waiting for the flush. A write that is merely slow (a live browser on a poor link) is not a failure: a slow write is waited for, but never past the session's current deadline (10 s before start, 600 s while open, 25 s after the stop went upstream); a write cut by its timeout is a failed write, and so is a write still in progress at that deadline (for example a client that reads one frame a byte at a time, which keeps restarting the socket's own timer): the gateway abandons it and closes the connection, so no client can hold the stream, or its slots, longer. After the deadline the gateway tears down: each of the three closing frames (upstream close, client error, client close) is bounded to 2 s, so a session ends at most 6.25 s after its deadline however slowly the client reads. Pings and pongs go through the same bounded write; none is skipped. Before stop, any text after start that is not a valid stop (garbage, a second start, an unknown type, an oversize text) is rejected at once with invalid_message (1008). Pings are still answered. Frame size bands. The WebSocket library reads at most 65535 bytes per frame. A binary frame of 32001 to 65535 bytes is a typed frame_too_large with close 1009 while the stream still accepts input; after stop (or at the session limit) the same frame is discarded like any other input. A frame over 65535 bytes is fatal inside the library: the gateway sends no error message and the browser sees an abnormal close (1006); the per-user and node slots are released as in every other end, so the next stream opens. The same holds for a frame the WebSocket library rejects as malformed framing (for example an unmasked client frame): the stream ends with no error message and no close frame (the browser sees 1006), like the over-65535-byte case. Client input is handled by ONE state machine (before start, open, draining after stop or at the limit) that decides every message the same way in every state: a valid start opens the stream (a second one is invalid_message while open, discarded while draining), a valid stop starts the flush (invalid_message before start, discarded while draining), a malformed text or audio frame gets its own code and close, and a fragmented message is invalid_message before the flush and read and discarded during it. Whatever else happens, exactly one outcome is counted per stream and nothing is sent after the close.

When a client offers live transcription. Clients use tenant_live_transcription_enabled on GET /admin/auth/me to decide whether to offer live transcription; the stream itself still refuses a non-entitled workspace with not_entitled / 4403. The field is computed with the same predicate, so it never says 1 where the stream would answer 4403.

Dictation voice commands (web app). The browser, not the gateway, interprets spoken commands in the partial/final text of this stream: pause and resume phrases and a send phrase ("Senden.", "Send it.", "Envoyer."). The relay protocol, its frames and its close codes are unchanged, and the gateway neither logs nor stores the transcript text. A send phrase counts only as the whole last sentence of the dictation: not inside a longer sentence, not as a question, quote or trailing-off sentence, and never after a pause in the same recording. When it counts, the web app ends the recording about 1.2 s after the last text, removes the phrase from the text and submits the message through the composer's normal send path. If that path is unavailable (an answer is still streaming, or the draft cannot be sent), nothing is sent and the text stays in the composer. If the dictation holds only the send phrase, nothing is sent and the web app shows the no-speech note. A send phrase as the last sentence is also honoured when the user ends the recording with the button; in that case the phrase may also follow the text after a comma ("The first point is the budget, send."), provided the text before it is a statement of at least three words, holds no condition, negation or hesitation ("if", "not", "maybe"), does not end on a connecting word ("and", "because"), and is not a list. The comma form never ends a live recording by itself. Without the live stream (a workspace without live transcription, or a live fallback) there is no automatic end; the user ends the recording with the button. When the recording is transcribed as a whole through the recorded-message endpoint (a workspace without live transcription, or a live fallback), a send phrase (including the comma form) is honoured only if the capture was never paused and the text holds no pause or resume command; otherwise the words stay in the text. The phrase list is in Dictate and pause by voice.

Limits. At most 1 concurrent stream per user and 32 per gateway node (both counted per node, not cluster-wide), a hard session length of 600 s (at the limit the gateway flushes: it stops the upstream, relays the remaining finals and ends with session_limit within 25 s, so a stream lasts at most 625 s, plus at most 6.25 s of closing frames), 20 s without audio, a flush wait of 25 s after stop. All are at or below the upstream's own limits. The relay pings the browser periodically and answers its pings. Entitlement and the session are checked when the stream opens; a running stream is not re-checked, so revoking access or entitlement takes effect for a running stream after at most 631.25 s (the session limit plus the flush plus the closing frames), and for any new stream immediately.

Replica failover. stt_stream_url is a list of 1 to 4 comma-separated replicas. Each stream starts at the next replica in round-robin order (per gateway worker). If that replica answers with a capacity form (above) or cannot be connected to (connect, TLS or handshake failure) before it is ready, the gateway dials the next URL once and sends start again; there are never more than two dials per stream, and a stream is never retried after the upstream was ready. A second failure keeps its own answer: busy again is busy (4013), anything else is unavailable (1013). A rejected gateway credential (HTTP 401/403) is not failed over and ends internal_error (1011). Audio the browser sends before the upstream is ready is held by the gateway (at most 15 s / 480000 bytes of PCM16 16 kHz mono and at most 1500 audio frames before ready; pings are answered and never buffered; exceeding either bound before ready ends the stream with backlog_exceeded, close 4002) and delivered intact and in order to the replica that serves the stream; a replica that answered busy never receives audio. The client sees none of this: it receives one ready from the serving replica, or one busy / unavailable error.

Closing. Either side may close. If the browser disappears without a close frame, the relay detects the broken socket and closes the upstream within moments; both slots are released in every case. A close from the browser is answered with a close frame (1000), so onclose reports a clean close. The per-user slot and the node slot are released before that answer is sent, i.e. when the close completes. Client rule for pause/resume: open the new stream only after onclose has fired on the old socket; reopening earlier can be refused with too_many_streams (4429). A browser that hangs up while its audio is still held (before ready) is noticed at once and does not keep the slot.

Operators. aig_transcribe_stream_outcome_total{outcome=…} counts one outcome per stream; outcome is one of ok, client_closed, upstream_auth, upstream_protocol, any error code of the table above (invalid_message, invalid_start, unsupported_format, bad_frame, frame_too_large, idle_timeout, session_limit, backlog_exceeded, not_entitled, unsupported_language, too_many_streams, busy, unavailable, shutting_down, internal_error), and the three pre-upgrade refusals origin_forbidden, websocket_required and bad_request (an HTTP 4xx, no WebSocket). aig_transcribe_stream_failover_total{result=served|busy|failed} counts, once per stream that dialed a second replica, whether that stream was then served (served), ended busy (busy) or ended otherwise unavailable (failed); a rising busy share means the whole fleet is saturated, a rising failed share that a replica is down. A stream that never needed a second replica is not counted there. aig_transcribe_stream_session_seconds is a histogram of session lengths. aig_transcribe_stream_notice_total{code="language_skipped"} counts the dropped finals in an unsupported language (a rising value means speakers use a language the feature does not support; each drop also logs one WARN line with the language code, never the text). Configuration: stt_stream_url and stt_stream_basic_auth.


Text-to-speech (read aloud)

POST /admin/v1/chat/speak — synthesize text to speech ("read aloud"). The synthesis runs off the streaming critical path; it is a separate request the client makes after the answer has finished streaming.

Speech is produced by a self-hosted EU-hosted Piper model (piper-de, voice de_DE-thorsten-medium) on the sovereign fleet — the request never leaves the EU boundary, matching the residency guarantee of every other model call. The engine and voice come from the tenant's configuration (default piper-de / de_DE-thorsten-medium) and the language hint below; the audio format is fixed server-side. The client supplies only the text and the hints. An impersonation session is refused.

One request carries one segment, not a whole answer. Synthesis costs roughly 3.6 seconds per 1000 characters, so a long answer sent as a single request takes almost a minute before the first byte of audio exists. The web app therefore splits the answer at sentence boundaries and requests the segments one at a time — playing segment 1 while segment 2 is still being synthesized — so audio starts after about 1.5 seconds regardless of how long the answer is. In practice each request carries roughly 400 characters (the first) or 1200 characters (the rest). Integrators are strongly encouraged to do the same: a single 16 KiB request is accepted but will keep you waiting for the whole synthesis, and it occupies the shared engine for the entire time.

Request body (JSON):

Field Type Required Description
text string yes The text to read aloud. Must be valid UTF-8 and at most 16384 bytes.
language string no ISO-639-1 hint for which voice to synthesize with: de, en, fr, nl or es (honoured only when the tenant's engine serves a voice for it). Any other value — an unsupported code, a non-string, or the field omitted — falls back to German (de). The web app detects the answer's language once over the whole answer and sends the same value for every segment.
message_id string no The id of the committed assistant message this text was taken from. When present and the message belongs to one of your own conversations, the gateway serves the pronunciation-normalization step from a precomputed cache (see below) and populates it on a miss. A missing, unknown, or another user's id is silently ignored — the request simply takes the live normalization path — so it is never an authorization surface.

Response: the raw audio bytes with Content-Type: audio/mpeg (MP3), for inline playback.

Error codes:

Status Meaning Retry?
400 text is missing, not a string, empty (text is required), or not valid UTF-8 (text must be valid UTF-8) no — fix the request
401 / 403 the session has expired or lacks access no — sign in again
413 text exceeds 16384 bytes no — split the text and send it as segments
429 per-user rate limit (rate limited) yes, after the Retry-After seconds (at most 60)
502 synthesis genuinely unavailable (the upstream is down, unreachable or rejected the request) no
503 at capacity — the gateway admits two concurrent syntheses, and the shared engine synthesizes one clip at a time yes, after a few seconds

429 and 503 both carry a Retry-After header, and both mean "come back shortly". 502 means the service is not working and retrying will not help. Capacity pressure anywhere in the chain — this gateway, the fleet's admission limits, the engine's own queue, or a synthesis that runs past the gateway's deadline — is reported as 503, never as 502, precisely so a client can tell a temporary condition from a broken one.

Two practical notes for clients:

  • Retry-After is not a CORS-safelisted response header, so browser JavaScript cannot read it. Browser clients should key their retry policy on the status code alone, and should treat 429 as "wait up to a minute" rather than retrying immediately.
  • The rate limit is charged by size, not by request count. The budget is 15 segment-equivalents per 60 seconds per user, where one segment-equivalent is 1200 codepoints (characters, counted independently of UTF-8 byte length); a request is charged ceil(codepoints / 1200). Sending segments of the recommended size therefore costs one unit each, while a single maximum-size request costs 14. This exists because the shared engine synthesizes one clip at a time and the cost of a request varies roughly 40x across the accepted range.

The gateway also scales its own upstream deadline to the size of the request, so a small segment fails fast when the engine is wedged while a maximum-size request still gets the time it legitimately needs.

Voices and language routing: the deployed engine serves eight voices — German (de_DE-thorsten-medium), English (en_US-lessac-medium), French (fr_FR-siwis-medium), Dutch (nl_NL-mls-medium), Spanish (es_ES-davefx-medium), Italian (it_IT-serena-medium), Danish (da_DK-talesyntese-medium) and Swedish (sv_SE-nst-medium). Norwegian answers are sent with language: "da" (no Norwegian voice). The read-aloud request's language hint selects the matching voice; German is the default when the hint is absent or unsupported. A single answer is synthesized in one language (the detected/hinted one) — a mixed-language answer is read in its dominant language.

Pronunciation normalization: before synthesis, the text is rewritten into fully spoken form so the phonemizer reads it correctly. First, a small deterministic pass expands the few language-universal approximation symbols that must never be left to a model — a ~ or ≈ immediately before a number (at a word boundary) becomes "circa" (e.g. ~64 → "circa 64"); a tilde glued to a token like a git ref (HEAD~3) or a path (~/dir) is left untouched. The speech engine's own normalizer also reads dates (ISO and dotted), clock times, § / Art. / Abs. references, currency amounts and unit symbols, and removes citation markers such as [1]. Since tts:1.2.4 it also expands common abbreviations in German, English and French (z. B. → "zum Beispiel", e.g. → "for example"), reads ± as words, turns an arrow → into a short pause (A → B is read "A, pause, B"; inside an address token it is kept), and reads years as years (German 2010-2099 and English 1900-2099 in a year context: 2026 → "twenty twenty-six" in English, "zwanzig sechsundzwanzig" in German), while amounts, counts, postcodes, phone numbers and numbers inside URLs or emails keep the cardinal reading. Since tts:1.2.5 it reads German ordinals with the case of the article before them (in der 3. Runde → "in der dritten Runde") and date ranges (vom 3. bis 5. März → "vom dritten bis fünften März"), roman numerals after a section word or a ruler's name (Kapitel IV → "Kapitel vier", Ludwig XIV. → "Ludwig der Vierzehnte", Louis XIV → "Louis the Fourteenth"), French ordinal suffixes (3e → "troisième") and decades (1990er → "neunzehnhundertneunziger", the 1990s → "nineteen nineties"); an ordinal without an article, a list number at the start of a line, a roman numeral without such a context word and a ruler's numeral whose period could end the sentence (Das war Ludwig XIV.) keep their earlier reading. Since tts:1.2.6 it also reads version numbers (Version 1.2.3 → "Version eins Punkt zwei Punkt drei", Python 3.12 → "Python drei Punkt zwölf"; IP addresses, dates and thousands such as 1.234.567 are not versions), common fractions in a quantity context: before a singular unit word or, in German and English, a unit symbol (⅛ Liter → "ein Achtel Liter"), before der / aller / of / des / de at the start of a sentence or after a quantity word such as etwa, bis zu, about or environ (etwa 3/4 der Befragten → "etwa drei Viertel der Befragten"), and always in a mixed number (2 1/2 → "zweieinhalb") or as a Unicode fraction (⅛ → "ein Achtel"); in any other context, such as Seite 1/2, Ja, 3/4 der Befragten or a date like 3/4/2026, the digits keep their earlier reading. It also reads English 24/7 ("twenty-four seven"); in German the ending .de, .eu, .at, .ch or .io of a domain or e-mail address letter by letter (myra.de → "myra Punkt d e", info@myra.eu → "info@myra Punkt e u"; other endings such as .fr stay as written); in French the dots of an e-mail address, with a two-letter ending letter by letter (info@myra.eu → "info@myra point e u", info@myra.com → "info@myra point com"; English is unchanged); and the French = between spaced operands (2 + 2 = 4 → "deux + deux égale quatre"). Then the primary layer, an internal EU language model, expands dates, times, currency amounts, percentages, mathematical symbols, acronyms, and abbreviations into spoken words in the answer's own language — this is language-agnostic, with no per-language rule set. Every numeric token (dates, times, amounts, plain numbers, numeric ranges, phone numbers) is masked from the model before it sees the text and is spelled afterwards by the speech engine's own deterministic normalizer, so the model never reads or rewrites a number itself: a phone number is read digit by digit with a pause between the groups, and a hyphen between phone groups is a separator, not a range (0800-1234567). A phone number is recognised by a leading +, a cue noun directly before it (such as "Tel.", "Telefon", "Hotline", "phone"; only blanks, a : and one "Nr." (also the compound Tel.-Nr., Telefon-Nr.) may sit between the cue and the number, so a verb such as "call" or "dial", or a cue followed by any other word, is no signal), a leading-zero area code (with at least two groups: a first group that starts with 0 and has at least two digits), a later leading-zero group of at least three digits when there are three or more groups or exactly two of 3 and 4 digits (555-0134, 4711-2026-0815), or the 555-123-4567 / (555) 123-4567 shape; a number directly followed by Uhr or h (also after a blank) is a time and never a phone, whatever the signal (Tel. 1234 h, Hotline Mo-Fr 0800-1800 Uhr); a bare 555-1234, 1999-00, 1 000 0815 and Seite 12 0815 stay as written. Independently of the phone rule, a standalone group of three or more digits that starts with 0 is read digit by digit (0815 → "null acht eins fünf"), unless another digit or a currency symbol or word is within 8 characters, it is attached to a letter, or it is a 24-hour HHMM followed by Uhr, h, hours or hrs; a two-digit group such as 05 is left to the ordinary number reading. A run of more than 15 digits is left unchanged, and the phone rule never reads it again, so reading the already-spoken text a second time changes nothing. Under a + or a cue word a / or / also separates the groups, but only directly after a 0-led area code of 3 to 6 digits (Tel. 0221 / 123 45 67, Tel.: 030/1234567); any other slash is a date, range or fraction, so Hotline seit 03/2024, Hotline-Anrufe 2023/2024 and Hotline 24/7/365 stay as written. A group followed by :, . or , and a digit (Hotline:0900-1700(0):12) is a time, date or decimal, so the run is left unchanged; in German, a clock time or a date (day 1-31, month 1-12) written after a phone number that starts with + or a cue word is read as a time or date and the number keeps its digits and its leading zero (Hotline 0800 123456 14:30 Uhr → "null acht null null, eins zwei drei vier fünf sechs vierzehn Uhr dreißig"), while a decimal or an amount after the number keeps the reading above. A digit group that follows the number after a blank or a hyphen is read as part of it (0800 1234567 89); a comma ends the number (0800 1234567, 24 Stunden). A last group of at most 2 digits, reached through a blank and shorter than the group before it, is a quantity and not part of the number when it is directly followed by / or by a unit or percent word (0800 1234567 24 Stunden, Tel. 0221 1234567 50%, and in German, English and French also a measuring unit: Fax 0459 7186 40 km → "…, sieben eins acht sechs vierzig Kilometer"). A number next to a currency (809 EUR, also with a tab or a non-breaking space between) is an amount, never a phone. It is a pure rewrite that never changes the meaning of the answer, and it is fenced so that text inside the answer is treated strictly as content to rewrite, never as instructions. The model layer is fail-open: if it is unavailable, times out, or returns a truncated reply, the request falls back to the synthesis engine's own deterministic num2words normalizer (the deterministic symbol pass having already run), so read-aloud never breaks — it only reads a little less fluently. No layer ever routes text outside the EU boundary.

Normalization cache: the model normalization above is a pure rewrite — for a fixed (language, exact text) it always produces the same spoken form. When a request carries a message_id you own, the gateway caches that (text → spoken) result and reuses it on any later read of the same text, so a replay skips the language-model call entirely (its ~1–3 s of latency and its cost). The cache is keyed by a hash of the exact text sent — a single changed byte is a different key, so it can only ever return the normalization of precisely what was asked for, never stale or mismatched audio. It is a pure optimization: it does not change what is synthesized, only how fast the normalization step returns, and it never affects the fleet-serialized synthesis itself. A miss (a first read, an edited answer, or any request without a usable message_id) transparently takes the live path. The cache is scoped to your own messages and is deleted together with the message under retention and account-deletion.

Live speech (sentence streaming)

Read-aloud (above) is a separate request after the answer is complete. Live speech is the server-side counterpart for speaking an answer while it is still being written: the gateway takes the answer text as it streams in, cuts it into sentences, and synthesizes each sentence as soon as it is complete, so the first audio is ready after the first sentence rather than after the whole answer. Read-aloud, its endpoint, limits and normalization are unchanged.

  • Input. Text arrives in fragments of any size, down to a few bytes. Each fragment must be a string; an empty fragment is ignored. The cumulative input of one stream is capped (default and ceiling 65536 bytes); a fragment that would exceed the cap is refused whole and the stream stays usable.
  • Languages and voice. de, en or fr. The voice is chosen on the server from the language, the same way read-aloud does; it cannot be set by the caller. Audio is WAV unless mp3 or opus is requested.
  • Sentences. A sentence ends at ., !, ?, … followed by whitespace, or at a line break. Up to four closing quotes or brackets directly after the mark (", ', ), ], ”, “, ’, ») stay with the sentence they close, so Er sagte „Ja.“ Weiter. is two sentences. A period after a number (3. Oktober, 3.5), a single letter (z. B.) or a common abbreviation is not an end. Fenced code blocks are not spoken. Runs of blanks (spaces, tabs, non-breaking and other Unicode spaces, zero-width characters) inside a line are read as a single space, the Unicode line and paragraph separators (U+0085, U+2028, U+2029) end a sentence like a line break, and a line's leading blanks are reduced to at most four, so a long run of whitespace never delays a sentence end or cuts a word in two. A run-on of more than 1 KiB without a sentence end is cut before sending, at a comma or similar, else at whitespace, else between digit groups, else at a character boundary.
  • Plain text only. Speakable text, no markdown, like POST /admin/v1/chat/speak: removing markdown is the caller's job. Markdown that still arrives is not refused; it is read literally (brackets, link targets, * are ordinary text, and a sentence end inside [...] is a sentence boundary). Fenced code blocks (lines starting with three backticks or tildes) are still skipped.
  • Normalization. Live speech sends each sentence to the speech engine as it is written, with no model layer and no gateway-side number rewriting:
    • The text first goes through the same deterministic symbol pass as read-aloud (~5 becomes "circa 5", non-ASCII numerals become ASCII digits), then the speech engine's own normalizer reads numbers, phone numbers, dates, times, currency amounts, units and § / Art. references. Since tts:1.2.4 the engine also expands common abbreviations in German, English and French (z. B. → "zum Beispiel"), turns an arrow → into a short pause, and reads years as years (2026 → "twenty twenty-six" in English). Since tts:1.2.5 and tts:1.2.6 it also reads German ordinals and date ranges with their case, roman numerals in context, decades, version numbers, common fractions, English 24/7, German domain and e-mail endings and French e-mail addresses letter by letter, and the French =, exactly as described for read-aloud (vom 3. bis 5. März → "vom dritten bis fünften März", Version 1.2.3 → "Version eins Punkt zwei Punkt drei", etwa 3/4 der Befragten → "etwa drei Viertel der Befragten"). The rules for phone numbers are the ones described under Pronunciation normalization above; there is no second copy.
    • Citation markers such as [1] are removed by the engine. A citation marker here is [N] (N of one to three digits, not all zeros) that is not glued to a letter, digit or non-ASCII character before it, or to (, [ or a letter or digit after it (so [0], [1](x) and “[1]” are not markers and are sent to the engine). A piece with no letter, digit or other non-ASCII character apart from dashes, the ellipsis, quotation marks and citation markers (for example a line of citation markers only, or a dash that opens a sentence) is skipped: nothing is synthesized, it is not counted, and the stream continues.
    • A cue word does not carry across a line break: Telefon followed by a line break and 030 1234567 is read by the shape of the number alone. A line break directly between an amount and its currency (809, line break, EUR, with no blank or carriage return before the line break) does not end the sentence, so the engine sees the amount and the currency together.
    • A sentence longer than 300 bytes is cut into pieces of at most 300 bytes. A cut is only made at a blank that has no digit within 48 bytes on either side and does not follow Nr., so a number keeps its cue word and its neighbouring groups. Among such blanks the order is: the last comma, semicolon, colon or dash within the first 160 bytes, else the first one up to 300 bytes, else, only when the remaining text exceeds 300 bytes, the last ordinary blank that leaves a piece of at least 48 bytes (no one-word pieces). When no blank is safe, the blank with the greatest distance to a digit is used (among the blanks between 160 and 300 bytes if there are any, otherwise among those within 160 bytes), except that a blank which would separate an amount from its currency (5 | EUR, EUR | 5, also across a line break) or follows Nr. ranks below every other blank and is used only when no other blank exists; with no blank at all, the piece is cut at a character boundary at 300 bytes, and never between two digits.
    • Differences to read-aloud that remain: a sentence over 300 bytes (or a run-on over 1 KiB) with no number-safe break is cut near a number; rules that look across a line break or a sentence end do not apply, because live speech speaks sentence by sentence; blank runs are read as a single space (a no-break space or narrow no-break space becomes a space); markdown that arrives despite the plain-text contract is read literally; and the model layer of read-aloud does not exist here. The amount-and-currency join matters for English and French (809 and EUR read as one amount); for German the engine reads the parts the same way joined or not, so it only keeps one phrase.
    • Each chunk's text is the raw piece that was sent. One audio chunk is delivered per piece, and the statistics count pieces.
  • Errors. Every failure carries one of these codes: invalid_input (wrong type, bad language or format, invalid UTF-8), input_too_large, aborted (the consumer stopped, or the stop check fired), busy (the engine is at capacity; retry later), bad_request, failed (synthesis unavailable), unconfigured, and closed (the stream was already finished). A busy, bad_request or failed answer closes the stream and every later call reports the same code; the gateway does not retry on its own. The upstream response body is never included in the error.

Voice-mode text preparation. A pure server-side text filter, utils.speech_markdown, prepares markdown for being spoken. It is used by the spoken answer of the voice session; the input handling of live speech and of POST /admin/v1/chat/speak is unchanged, and markdown that arrives there is still passed on as it is. The filter takes fragments of any size and its output does not depend on how the text was cut into fragments: the fragments together give exactly the result of the whole text. It holds back at most 527 bytes (an unfinished link, table cell or character) and releases plain text without waiting. Non-string input is rejected with invalid_input; a filter that was finished answers closed. The rules:

  • Emphasis (**x**, __x__, *x*, _x_, ~~x~~) and code spans keep their text; the markers are dropped. A word-internal _ (snake_case) and a lone * in 2 * 3 stay. The output never contains a backtick.
  • Links [text](url) keep the text, images ![alt](url) keep the alt text, and the target is dropped. Bare http(s)://, www. and <https://…> addresses are dropped; a ) that closes a parenthesis around the address ((siehe https://x.de)) is kept and spoken. The link-text bound (256) counts held output bytes, not input bytes. A link whose text is itself an address is dropped entirely. A Unicode blank (U+0085, U+00A0 no-break space, U+1680, U+2000 to U+200A, U+2028, U+2029, U+202F narrow no-break space, U+205F, U+3000 ideographic space) ends an address like an ASCII blank does: the address is dropped and ONE ASCII space is spoken in its place (inside a parenthesis the pending ( is spoken first, then the space). An address may also start right after such a blank. A hyphen (U+2010) is not a blank. A tab is a blank too and collapses with the blanks around it.
  • Citation markers are dropped wherever they stand, whatever precedes them (see the format below). Because there is no check on the preceding character, arr[0] and Hauptstadt[1] also lose their bracket in speech.
  • A backslash before a markdown punctuation mark keeps the mark (\* gives *), except that \` drops the backtick (the output never contains one); before anything else the backslash stays.
  • Headings, block quotes, bullet and numbered list markers at the start of a line are dropped. Horizontal rules vanish. Fenced code blocks (three or more backticks or tildes) are dropped with their content. A fence may start after any number of leading blanks and after any mix of block-quote > and list markers (-, *, +, 1., 1)) in any order and nesting, such as > -, 1. > or * *. A closing fence (same character, at least as long, no text after it) may carry the same kind of prefix. An unclosed fence at the top level drops the rest of the text, but a fence inside a block quote ends at the first line with fewer > than the line that opened it; that line is spoken normally (so a quote fence whose body lines lose their > ends at the first such line, and a bare fence line after it then opens a top-level fence). A fence opened after a list marker (outside a quote) ends only at a closing fence, which is recognised behind any prefix or none, column 0 included, so a sloppy 1. plus fence with an unindented body and a column-0 closer is dropped cleanly and the next list item is spoken; unclosed, it drops the rest like a top-level fence. A heading marker or a task-list checkbox ([ ]) before the fence characters keeps the CommonMark reading, so the fence characters are ordinary text there. A marker pair such as - - item is dropped as two markers. Bounds: a prefix of more than 64 bytes is not recognised as a container prefix, a line that ends a quote fence is replayed with its container prefix only when that prefix is at most 192 bytes (longer: only the text after the prefix is spoken), and a closing run longer than 64 bytes inside a container does not close. A line that starts with three backticks and holds a closing run of backticks later is a one-line code span, never a fence: its content is spoken like any inline code, and so is the text after it on that line, however long the line is. Limit: the part of a backtick fence line after the opening backticks is held for at most 64 bytes; a fence whose info string is longer than that (no real language name is) has the info string spoken, and its body is still dropped. A fence is only recognised where a block can start; fence characters in the middle of a line are ordinary text.
  • A table (a pipe-led row, or a header row followed by a delimiter row such as --|--) is dropped with its rows up to the first line without a pipe. A line that starts with a pipe is dropped at any length. In a table, a row is dropped only if its first pipe comes within 256 bytes; otherwise the row is spoken with its pipes as blanks and the table ends. A pipe elsewhere becomes a blank.
  • Runs of blanks collapse to one, CRLF becomes LF, more than one empty line collapses to one, and leading and trailing blanks and empty lines are removed.

Known differences to full CommonMark: a table header row without a leading pipe is spoken once (only the rows after the delimiter row are dropped), a setext underline (===) is spoken as text, -*- is spoken as text, and a heading marker after a list marker (- # Heading) is spoken as text, as in the frontend. Deliberate differences to the frontend stripper: the sources-footer cut (stripUnspeakable) is not part of this filter; on the voice path the answer stream is cut before the filter, in every language's footer form, so the sources footer, citation markers and file blocks are stored with the message but never spoken, and the citation marker is recognised by a byte-wise state machine that is fed the input as it arrives. Remaining differences, where read-aloud still departs from voice mode and which are block-level only, in both directions: (1) a line that starts with a pipe is dropped by voice mode (it enters table mode), while read-aloud keeps its cell text unless the whole line is a separator row (| - | is spoken as -, |--|x as -- x by read-aloud and not at all by voice mode; |---|---| is dropped by both); (2) a separator-shaped line without a pipe is dropped by read-aloud (--) and spoken as text by voice mode, which treats a dash row as a table separator only when it also holds a colon or pipe; (3) fenced code (a line of three backticks or ~~~) is read by read-aloud without the fence lines and dropped by voice mode, and an unclosed ~~~ fence drops the rest of the text in voice mode; (4) nested block markers: voice mode peels quote and list markers repeatedly in any order but stops after a heading marker, read-aloud peels heading, quote, bullet and ordered marker once each, in that order (- > x: voice "x", read-aloud "> x"; - - x: voice "x", read-aloud "- x"; # - x: voice "- x", read-aloud "x"; > # x: voice "x", read-aloud "# x"; # > x is voice "> x", read-aloud "x"), and a rule after ONE quote marker (> ---) is dropped by both, but after two (> > ---) voice mode drops it and read-aloud speaks > ---; (5) a setext underline (===) is spoken as text by both, and a --- line is dropped as a rule by both; (6) table rows after a delimiter row that has no leading pipe: voice mode drops the following rows that contain a pipe, up to the first line without one, and read-aloud speaks their cell text (a | b, --|--, c | d: voice "a b", read-aloud "a b" and "c d" on two lines; a pipe-led header, delimiter and row | a | b |, |---|---|, | 1 | 2 |: voice nothing, read-aloud "a b" and "1 2" on two lines). Rules written with blanks between the characters (- - -, * * *), a rule after one quote marker (> ---, see (4)), CRLF line ends, a one-line ```code``` span (kept as text) and an ordered marker of up to nine digits (a ten-digit number is text) behave the same in both paths. For emphasis a no-break space counts as a word character in both paths, so a _ right after it does not open emphasis: x, U+00A0, _y_ z is spoken as x, U+00A0, _y z. Everything inline (emphasis, code spans, escapes, links, link targets, the 256-byte link-text bound, bare and bracketed addresses, citation markers) is one rule set: read-aloud runs a port of the voice-mode inline filter on the text left after the block step, and a shared fixture checks both against each other.

Citation marker format. The renderer in the chat, the read-aloud filter and the voice-mode filter share one grammar. The text between [ and ] is exactly one of:

  • a list: one to eight numbers separated by a comma, each comma followed by none or one space ([1], [1,4], [1, 4, 11]);
  • a range: two numbers joined by a hyphen or an en dash, no spaces, the first smaller than the second ([2-5], [2–5]).

A number has one to three ASCII digits. A list and a range cannot be mixed, a range is never expanded to the numbers in between, and a marker followed directly by ( is a link and not a citation. In the chat each number of a list becomes its own citation link; a range becomes a link on each end with the en dash between them. A marker is rendered only if every number in it belongs to a source; otherwise it stays as plain text. Read-aloud and voice mode drop the whole marker. Both speech paths match the grammar after markdown removal, so formatting inside the brackets ([**1**], [1*,2]) can change whether a marker is dropped. Backslash escapes, bare and parenthesised URLs and the bracket depth follow the same rules in both paths (read-aloud mirrors the voice-mode filter, which is the reference): a backslash before ASCII punctuation is removed, so [1\,2] and [1\-3] are dropped as markers in both; an escaped bracket is never a marker delimiter, so \[1] and [1\]] are spoken as [1] and [1]]; in the chat \[1] is still rendered as a citation link (the markdown parser resolves the escape first), and this difference is deliberate; a [ beyond the eighth open bracket is plain text; and a URL inside or after brackets ([1 (https://x)]) is removed before the marker is matched. A fenced code body such as arr[0] also loses the bracket in read-aloud; voice mode drops fenced code entirely. Read-aloud runs the same inline pass as voice mode on the text left after the block-level step, so the two agree on a*https://x* z, [1]**(y)**, an unpaired ~~, a code span with an escaped closing backtick, and a URL start after a paired backtick. A backtick that is not part of one of these shapes (a lone one, or a code span without a URL start, a ]( or an escaped closer) is dropped in both paths. An unclosed link target ([x](y) reads as the link text in both paths. Spacing is normalised the same way in both paths; a URL directly after a Unicode blank is removed by both.


Memories

GET /admin/v1/memories — list stored memories for the calling user. A memory stored encrypted that no current master key can decrypt (for example after a key was removed) is listed with content: "" and undecryptable: true, never as ciphertext; the user and tenant data exports refuse (fail closed) rather than include such a row. The response is bounded: it returns at most 50 memories per scope (the per-scope cap, see below), in the stored order (sort_order, then created_at, then id). A user who somehow holds more than the cap (rows created before the cap existed) sees the first 50 in that order.

POST /admin/v1/memories — create a new memory entry. Each scope holds at most 50 memories; a create that would exceed the cap is rejected with 409 and a machine-readable body { "error": "memory limit reached for this scope", "code": "memory_quota_exceeded" } (the count is not silently clamped — the create simply does not happen). Delete a memory to make room. Body: content (required, see below), type (fact, preference or instruction; default fact; any other value is 400 invalid type, code invalid_type), source (manual or auto; default manual; any other value is 400 invalid source, code invalid_source), project_id (optional, see Project scope). Success is 201 with the created memory. Database faults: a failed read before the create (the caller's access to the project) is 503 {"error": "temporarily unavailable; retry later"} — nothing written, retry; a failed create, or a failed read of the list after the create committed, is 500 {"error": "internal error", "request_id": "…"} — the memory may exist, so list the memories before creating it again. The database's own error text is logged, never returned.

PATCH /admin/v1/memories/<ID> — update a memory entry. On POST and PATCH, content must be a non-empty string: an absent content or "" is 400 content is required with code content_required, JSON null is the same sentence with code invalid_content, any other type (number, boolean, object, array) is 400 content must be a string with code invalid_content, and more than 4000 bytes is 400 content too long with code content_too_long. PATCH changes only content and answers 200 {"ok": true}; it touches only a memory the caller owns. A database failure is 500 {"error": "internal error", "request_id": "…"} (the database text is logged, never returned).

DELETE /admin/v1/memories/<ID> — delete a memory entry the caller owns; answers 200 {"ok": true}, also when nothing was deleted. A database failure is 500 {"error": "internal error", "request_id": "…"} (the delete may or may not have landed; repeating it is harmless).

POST /admin/v1/memories/reorder — set the ranking of memories within one scope (drag-and-drop). Body: { "ids": ["<memory-id>", ...], "project_id": "<id>" }. ids is the desired top-to-bottom order and must be a non-empty JSON array of strings — a missing ids, a non-array ids, an empty array, or any non-string / empty-string element is rejected with 400: a missing ids answers code ids_required; a null or non-array ids, an empty array and a bad element answer invalid_ids. project_id is optional: omit it for the caller's user-scope pool, or supply it for a project scope (a caller who cannot see the project gets the audited 404, a caller who can see it but is not a direct member or platform admin gets 403; see Project scope below). Each id is applied only to a row the caller owns in that scope; ids the caller does not own are silently ignored (no cross-user or cross-scope write). Returns the re-listed memories in their new order. The ranking is applied atomically — a failure mid-list rolls back so the order never lands half-applied. More than 50 ids (the per-scope memory limit — a scope never lists more) is rejected with 400 too many ids (max 50) (code too_many_ids). The other 400 bodies are ids array is required and ids must be non-empty strings. The transaction is re-run on a transient database conflict; if every bounded attempt conflicts (or a row lock could not be obtained in time) nothing changes and the route answers 503 — retry the request. Any other database failure — including a failed re-list after the new order was saved — is 500 {"error": "internal error", "request_id": "…"}.

Project scope and project_id. On GET /memories (query parameter), POST /memories, POST /memories/reorder and each POST /memories/feedback item, project_id selects a project's memory pool. Absent or null is the caller's user scope (on GET, an empty ?project_id= also is). A project_id the caller cannot see — unknown, malformed, another tenant's, or a same-tenant project with no access — is answered 404 { "error": "not found" }, byte-identical for every such id, and recorded as one access.denied security event (status 404, no entity); nothing is read or written (see projects). This holds for platform admins too: an id that names no project is the audited 404 (a platform admin used to get 200 [] from the list). A project the caller can see but is not a direct member of (for example one shared through a group or the organisation) stays 403 { "error": "forbidden", "code": "project_member_required" } — memories belong to direct members and platform admins. A project_id that is not a string (a number, boolean, object or array, a repeated or bare ?project_id on the GET) is 400 { "error": "invalid project_id", "code": "invalid_project_id" }, and so is an empty string in a JSON body; a query truncated past 100 parameters is 400 malformed_query. A database fault while resolving the project is 503.

A memory is a piece of long-lived context that the chat engine may inject into future requests. Memories are injected into the model's system prompt in this stored order, so a higher-ranked memory takes precedence; new memories are appended at the bottom of their scope.

Per-scope cap. Each scope — the caller's user scope, and each project scope independently — holds at most 50 memories. This is a security ceiling, not only a tidiness limit: every stored memory is encrypted at rest, and list_memories runs on every chat turn and decrypts each returned row (one key derivation per row on a cold cache), so an unbounded pool would make each turn arbitrarily expensive. The cap bounds that per-turn cost. It applies to every create path — the POST /memories above and the accepted/edited items of the suggestion-feedback batch below both reject with the same 409 memory_quota_exceeded when the target scope is full.

Memory provenance

Each memory records whether it is tenant-authored or outside content. The server sets the marker; a provenance field in a request body is ignored.

  • POST /admin/v1/memories always stores tenant content, whatever source the body claims (the call is made by a person or the tenant's own API token).
  • Memories created from accepted or edited suggestions (POST /admin/v1/memories/feedback) are outside content, because the model proposed them.
  • PATCH /admin/v1/memories/<ID> never lowers the marker.

This release only records the marker; it does not change what any read returns. Existing memories are classified once: those whose source is not auto count as tenant content, auto ones as outside. The two rules differ on purpose for auto: historical auto rows were created by the model's suggestion batch, so they count as outside; a memory written through POST /admin/v1/memories is made by a person or the tenant's own token, so it is tenant content even when its body says source: "auto". The write path decides, not the label.

Context-layer suggestion feedback

POST /admin/v1/memories/feedback — record the user's decisions on the model-proposed <memory> suggestions and, for the accepted/edited ones, create the corresponding memory. The whole batch runs in a single transaction: either every decision and every created memory is persisted, or nothing is (a mid-batch failure rolls back, so a client retry never duplicates a memory or double-counts a metric). A transient database conflict re-runs the whole batch; if every bounded attempt conflicts, nothing is written and the route answers 503 (retry the request). Any other database failure is 500 {"error": "internal error", "request_id": "…"}, never the database's own text.

Request body: { "items": [ { "decision": "accepted"|"rejected"|"edited", "proposed_content": "<the model's original suggestion>", "final_content": "<edited text>", "type": "fact"|"preference"|"instruction", "project_id": "<id>" } ] }.

  • items must be a non-empty JSON array of at most 100 objects — a missing, non-array, empty, or over-cap items, or a non-object element, is rejected with 400: a missing items answers code items_required, a null, non-array or empty items answers invalid_items, an over-cap items answers too_many_items, and a non-object element answers invalid_item.
  • decision is required and must be one of accepted, rejected, edited — any other value is rejected with 400: a missing or empty decision answers code decision_required, any other value (including null or a non-string) answers invalid_decision.
  • proposed_content is required, must be a non-empty string, and is capped at 4000 bytes (over-length → 400). Absent or "" answers code proposed_content_required, null or a non-string answers invalid_proposed_content, over-length answers proposed_content_too_long.
  • final_content is required for an edited decision (non-empty, same 4000-byte cap; empty/missing → 400). The codes are final_content_required (absent or ""), invalid_final_content (null or a non-string) and final_content_too_long. It is ignored for accepted (the proposal is saved verbatim) and for rejected (which creates no memory).
  • type is best-effort metadata: an unknown or missing value is clamped to fact rather than rejected, so a stray model-emitted type never blocks the batch.
  • Scope is per item: each item's optional project_id selects its scope (absent/null = the caller's user scope). Every distinct project_id in the batch is checked before anything is written (in sorted order): a project the caller cannot see is the audited 404 not found, a visible project the caller is not a direct member of (and not a platform admin) is 403, and a non-string or empty project_id is 400 with code invalid_project_id. tenant_id and user_id are taken from the session, never from the body.

On success returns 200 with { "created": [ <memory>, ... ] } — the memories created for the accepted/edited items (an all-rejected batch returns { "created": [] }). Rejected suggestions are also fed back into the memory system: the model stops re-proposing a fact the user explicitly rejected (bounded to the user's 200 most recent rejections per scope).

GET /admin/v1/memories/feedback/metrics — the S6.2 quality metrics for the caller's tenant, tenant-isolated: { "accepted": N, "rejected": N, "edited": N, "total": N, "accept_rate": 0..1, "reject_rate": 0..1, "edit_rate": 0..1 }. The counts never include another tenant's rows; a tenant-less caller sees only their own rows. accept_rate counts only verbatim accepts (edited is its own bucket, so a "kept" rate is accept_rate + edit_rate); rates are over total decisions and a zero-decision scope returns all zeros. Each decision is an append-only event — re-deciding a proposal records another event by design. A read failure is 503.

All /admin/v1/memories routes refuse an impersonation session (personal data).

How memories are injected (fenced private context)

Stored memories are never mixed into a user message or into the text of an attached file. They are injected as their own clearly-delimited block inside the system prompt, fenced between a [Stored memory …] opening line and a [End of stored memory] closing line, and placed directly after the user's profile block, before the task and project blocks — user context, never the trailing block of the prompt (see System prompt block order below). On the one route that has no system role — Mistral with web search enabled (the Mistral Agents API, /v1/conversations) — the gateway folds the whole system prompt into the first user message; there the memory block sits inside the folded system text, separated from the user's own message by the prompt's block rule (---), never running straight into it. The fence labels the block as private operating context: the model may use the facts to inform its answers and state a specific fact when the user asks for it, but must not quote or reproduce the block (or its markers) to the user, and must never treat it as an attached document to evaluate, summarise, or review. This keeps a request like "evaluate the attached text" scoped to the attachment only, and keeps the internal <memory> proposal envelope out of visible output.

System prompt block order

The gateway composes one system message per turn, in this fixed order (a block is omitted when it has nothing to say; blocks 1-9 are joined by a --- rule; the memory-capture instruction, item 10, is appended after a blank line; items 11-14 again follow a --- rule each):

  1. the default prompt (identity, date, product self-help, the reply-language rule with its explicit-instruction precedence);
  2. the tenant's organisation policy;
  3. the user's profile block: the preferred name and work category, then the Answer preferences section, then the user's own instructions (the personal style);
  4. the stored-memory block (fenced, see above);
  5. the curator task;
  6. the project block — the project's instructions, then the reply-language anchor that qualifies them, then the project-files tool rules;
  7. the inline file-write fallback (providers without native tools), the imported-transcript notice, and the "Referring to files" rule (how to name a file a tool created or changed in this turn), when applicable;
  8. the response-style block;
  9. the voice-conversation block, set only on a spoken-answer turn of the voice session (the gateway-internal x-aig-voice-lang request header, set by the voice session's loopback call; the session is behind voice_mode_enabled, off until voice mode ships) and never in typed chat: answer format and length for speech, the reply language, and the precedence of an explicit language instruction; the German block for de, the English block (which answers in the speaker's language) for every other accepted value;
  10. the memory-capture instruction (capability-gated per model);
  11. the "Tools on this turn" notice, when the model's tools were removed for this turn;
  12. the "What you can do in this chat" block (the capabilities this workspace offers on this turn);
  13. the record of what earlier replies in the conversation actually produced (images, files);
  14. the runtime identity line (model, gateway, whether personal-data masking is on for this turn), always last.

The Answer preferences section is part of the profile block of every signed-in user, even one who has set nothing: it states the unit system (default metric), the form of address in German replies (default formal "Sie") and, only when set, the region (the country name and its ISO code). It ends with a precedence sentence: these are defaults, and an explicit instruction or offer in the conversation (also from an earlier turn), the personal style, project instructions, the organization policy, a stored memory or a selected response style takes precedence. The section is not removed by the per-conversation switch that turns the personal style off (only the user's own instructions are), and it is applied in ghost mode too. Each value is rendered only when it is exactly one of the allowed values (see Update the profile); a stored value that is not (a malformed or tampered row) is treated as unset and its text never reaches the prompt, so the default applies. The values are fixed lists, not free text, so they are not masked by the PII pass. The default prompt (item 1) also tells the model to start directly with the answer, without a label line such as "Short answer:" or "Fazit:", and to render the content of a source in another language with the reply language's established technical terms.

The per-request reply-language directive ("If the project instructions or the user's own instructions explicitly name a reply language, use that language … Otherwise: the user's most recent message is written in German. Write your entire reply in German …"; when the latest message does not show its language but the conversation does, the claim reads "does not clearly show its language; the conversation so far is in German") is appended by the same middleware after these blocks (the language is detected on the user's latest message — on a regenerate with a reason, the message that answer replied to, not the reason); later content middlewares (the web-search notice, the context-compaction guard) may merge their own text after it. Client-sent system messages are dropped wholesale.

The rendered memory block is also byte-bounded: it emits at most 16 KiB into the system prompt regardless of how many memories the scope holds, so the per-turn input-token cost can never grow without limit. When the memories would exceed that budget they are included in stored order until the budget is reached and the boundary entry is truncated; truncation is deterministic (the same memories in the same order always produce the same block). With the 50-per-scope cap and the per-memory length limit this budget is not reached by ordinary use — it is a backstop against pathological content.

Memory content is treated as untrusted input at the composition boundary: any value that tries to forge the fence's [Stored memory / [End of stored memory] markers, or to embed a live <memory>…</memory> envelope, is neutralised (its leading bracket/angle is broken) so it cannot break the framing or ride into the prompt as a live tag. Empty or whitespace-only content is skipped. This is spotlighting-grade hardening — it reduces, it does not eliminate, a model's own confusion — layered over the gateway's output strip, which remains the backstop that removes any <memory> tag the model emits before it reaches the user. While streaming, the strip holds back trailing text that could still become a tag (such as <, <mem, or the start of a tool tag) until the next chunk decides. At the end of the answer, text that never became a tag is delivered and saved as part of the answer, so an answer ending in a < b or see <mem keeps its last characters. An unfinished <memory or <memory type="… opening tag at the very end is removed, as are the contents of an unclosed <memory> block; text that merely mentions <memory (for example "use the <memory tag …", with no closing >) is ordinary text and is kept. When a long answer is automatically continued after the output limit, held text at the cut is dropped, so the continuation starts from exactly what was shown.