Projects API
The projects API manages chat projects, project membership, and project knowledge attachments.
All endpoints require an authenticated admin session (aig_admin cookie). The base URL is https://ai-api-admin.myra.eu/admin/v1.
Project-level access is governed by per-project membership: owner, editor, viewer. A membership only applies while the member belongs to the same tenant as the project (platform admins, i.e. holders of the sys:admin role, excepted); a stale row for a user who moved to another tenant grants no access and answers the same 404 as an unknown project. The owner can still list and remove such rows, and they are not counted when checking that a project keeps at least one owner.
While an administrator is viewing as another user (impersonation), every project route except the project list and the add-member candidates refuses the request with 403 impersonation_forbidden: a project's content and membership are the impersonated user's personal data.
Listing projects
GET /admin/v1/projects
Returns the projects the calling user can access. A non-admin caller is scoped to the projects in their own tenant. An admin-role caller must pass ?tenant_id=<ID> to select the tenant; the request returns 400 { "error": "tenant_id required", "code": "tenant_id_required" } if it is omitted, 400 { "error": "tenant_id must be a single value", "code": "bad_param" } for a repeated or bare parameter, and 400 { "code": "bad_param" } for a value that is not one canonical tenant UUID. A non-admin caller is pinned to its own tenant (a repeated or bare ?tenant_id is still 400); one whose account has no tenant is refused 403.
Each project card's knowledge_count is source-ACL filtered for the calling user — it counts only the knowledge files that user is permitted to read at the source, so it always matches the (also filtered) knowledge list on the project detail. A member of a project that holds creator-only connector-synced documents therefore never sees a card count larger than the files they can actually open. (Admins are filtered too, with no bypass, consistent with the detail list.)
Required role: authenticated.
Creating a project
POST /admin/v1/projects
Required role: any authenticated role except viewer. The caller is auto-added as a project member with the owner role. On success the response is 201 with the new project object (including its knowledge list); a missing, empty or blank name (nothing visible) is 400 with code name_required.
A new project is always an ordinary project: it is created with department_id: null and gateway_locked: 0, also when the caller belongs to a department. The create body does not set either field (a department_id or gateway_locked key is not read). To give the project to a department, or to lock its gateway, use PUT /projects/<ID>/governance afterwards. The caller's department still limits the gateways they can route through in this project, as in every project, because it is checked per user on every request (see Departments API).
Four-eyes config approval. When the organization has config approval enabled and the caller is a Fachadmin (tenant_admin / ki_manager), a project create/update/delete — and a change of the project's department or gateway lock (PUT /projects/<ID>/governance) — does not apply immediately — it returns 202 Accepted with { "status": "pending_approval", "approval_id": "…" } and is held until a second, different administrator approves it. At approval the change is re-validated against current state (the same offer validation below, and the requester's project role — including this update's owner-only tier/retention gate) — never a stale replay. If the organization itself was deleted while the change was held, approving it fails with apply_failed / tenant_not_found and nothing is written. With config approval off (the default) these calls apply immediately, exactly as documented here. A held create's body has no id (no project exists yet): the web client shows "Submitted for approval" with a link to Approvals › Configurations, adds no list row and opens no project page; the requester is told the decision in the notifications bell (config_approval_outcomes) — the approved project is owned by the requester, so the approver does not see it unless they are a member.
| Field | Type | Required |
|---|---|---|
name |
string | yes — a non-empty string of at most 255 characters (counted as Unicode code points) and valid UTF-8. An over-long name returns 400 name_too_long; a malformed-UTF-8 name returns 400 invalid_name; an absent, empty or blank name (only whitespace, Unicode spaces, zero-width / format or control characters, the braille blank U+2800 or a few extender marks such as tatweel U+0640) returns 400 name_required (invalid_name on a rename); a non-string name (number, boolean, object, array) or a JSON null returns 400 invalid_name. Validated fail-closed at the write boundary so a too-long name can never reach the column as an opaque 500. (The API never shortens a name — an over-long one is always rejected. The web app instead shortens an over-long name to at most 255 code points on save (at a grapheme boundary where possible) before sending it, and tells the user.) |
description |
string | no — a short project description. When present it must be valid UTF-8 and at most 2000 characters (Unicode code points); send JSON null or omit it to leave it empty. An over-long value returns 400 description_too_long, a malformed-UTF-8 value or a non-string 400 invalid_description. Validated fail-closed at the write boundary (a too-long or malformed value can never reach the column as an opaque 500). |
instructions |
string | no — project system instructions. When present it must be valid UTF-8 and at most 40000 characters (code points); send JSON null or omit to leave it empty. Rejections: 400 instructions_too_long; 400 invalid_instructions (malformed UTF-8 or a non-string). Fail-closed at the write boundary. |
icon |
string | no — a short icon token (typically a single emoji), at most 8 characters (code points) and valid UTF-8. Absent → the default is applied; send JSON null to clear it to empty (""). An over-long value returns 400 icon_too_long, a non-string or malformed-UTF-8 value 400 invalid_icon. Fail-closed at the write boundary. |
color |
string | no — the project accent shown on the project banner, welcome tile, and folder icon. Accepted shape: a #RRGGBB hex string exactly (e.g. #2563eb); send JSON null to reset it to the default #2563eb (the column always holds a colour). Any other value — CSS keywords, 3-digit hex, url(...) strings, or a non-string type — returns 400 invalid color (the value feeds CSS custom properties in the app, so it is validated fail-closed at the write boundary). In dark mode the app renders an automatically lightened variant of the accent where it acts as a link/border colour, so it stays readable on dark surfaces; the stored value is unchanged. |
permission_tier |
user_configurable | pii_mandatory | local_only |
no — defaults to user_configurable. An unknown value returns 400. |
default_gateway_id |
string | null | no — optional gateway pin. Usually left null: the preferred model (below) routes on a gateway the server derives, so callers need not choose one. A supplied pin must name a live gateway of the project's tenant: a gateway id that does not exist, a gateway of another workspace, or a gateway of a deleted workspace returns 404 { "error": "gateway not found", "code": "gateway_not_found" } (identical for all of them, so a gateway id cannot be probed across tenants; a probe is audited as access.denied); a value that is not a gateway id (non-string, empty, over-long or malformed) returns 400 { "error": "default_gateway_id must be a gateway id", "code": "invalid_default_gateway_id" }. Absent or JSON null means no pin. A gateway-only pin (no default_model) is checked too. A gateway id is accepted in any letter case; the project stores the gateway's own id (as returned by the gateways API), never the spelling sent. |
default_model |
string | null | no — the project's preferred/default model. A soft preselect: new conversations in the project open with this model chosen; a member can still switch model per chat. Send null to clear. Set stand-alone (model only, default_gateway_id omitted or null) — the routing gateway is derived from the model. When both default_gateway_id and default_model are set, every project conversation routes to that pair; see the offer validation below. |
tenant_id |
string | required for admin callers placing the project in a different tenant; ignored for non-admin callers (the caller's tenant is used). An admin who omits the key gets their own tenant; an admin with no own tenant gets 400 { "error": "tenant_id is required", "code": "tenant_id_required" }. A key that is present follows the same naming rule as the other routes that name a target tenant: "" is 400 tenant_id_required; JSON null, a non-string or a value that is not a tenant UUID is 400 invalid_tenant_id; a well-formed id of no live tenant (unknown or deleted) is 404 tenant_not_found; a tenant lookup failure is 503. An upper-case UUID is accepted and the project is stored under the lower-case id. (Earlier releases answered bad_param for a malformed value and treated null like an omitted key; a client that checked for bad_param on this route must now handle invalid_tenant_id.) A non-admin caller whose account has no tenant is refused 403 { "code": "caller_has_no_tenant" }. |
The permission_tier is the project's access tier: local_only restricts the project to local Myra models (no cloud egress; the in-estate code-interpreter sandbox stays available), pii_mandatory forces PII masking on — and, on a gateway with no reversible masker, withholds the third-party tool egress the masking cannot cover (the web search; a fetched document bound for a non-local inner agent model) and refuses a URL or MCP argument carrying protected structured PII — and user_configurable (the default) leaves the PII choice per chat with all models available.
Project default pin offer validation. When a request sets both default_gateway_id
and default_model, the server validates that pair against the pinned gateway's dispatch
gates — the same EU data-residency and provider-allowlist checks the inference path enforces —
evaluated on the gateway's resolved (tenant-floor-folded) config. A pin the gateway would
refuse at dispatch is rejected here rather than accepted and then failing every conversation:
- The model resolves to a provider the gateway's EU data-residency enforcement blocks →
400withcode: "data_residency_blocked". - The model resolves to a provider not on the gateway's approved provider allowlist →
400withcode: "provider_not_allowed". - The pair cannot be judged because a read it depends on failed (the model catalogue, the gateway's
routing rules or its provider opt-in set) →
503 { "error": "temporarily unavailable; retry later" }(nothing written — retry). A read fault never turns into a400verdict, nor into an accepted pin.
Local-only access tier — the default must be a local model. A project whose permission_tier
is local_only may only route to local Myra models, so its stored default must resolve to a
local provider. This is checked at save time for both pin shapes (unlike the residency /
allowlist check above, which is both-pin only):
- A both-pinned default whose resolved dispatch provider is not local →
400withcode: "model_not_allowed_for_project". Without this the pin would be honoured verbatim and then refused on every conversation with no Auto fallback — a hard dead-end. - A model-only default whose model is served only by cloud providers (no local
model_priceprovider) →400with the same code. The model would otherwise be stored but never honoured (the resolver falls back to a local Auto pick). - Changing a project's access tier to
local_onlywhile it still holds a non-local default is rejected the same way — clear or replace the default first.
An unknown model (no model_price row) is tolerated on a local_only project: it is not
provably cloud, and the resolver simply falls back to the local Auto pick. A model served by at
least one local provider is accepted even if a cloud provider also serves it (it can run
locally). pii_mandatory and user_configurable projects are not constrained by this check —
they may pin a cloud model.
A pin with only one of the two fields set is not offer-validated (a lone pin falls back to the
normal Auto pick, which is itself offer-filtered). If the pinned gateway (or the model's providers)
cannot be read at save time (a transient database error), the save fails closed with
503 { "error": "temporarily unavailable; retry later" } (nothing written — retry); a gateway whose
configuration is stored corrupt fails with the sanitised 500 { "error": "internal error", "request_id": "…" } (permanent; a held four-eyes change fails apply_failed internal). Neither silently stores an
unvalidated pin. The same permanent 500 is answered when the server cannot establish the project's tenant for the check; a retry does not help.
Model-only preferred model (soft default). Setting default_model alone is the common
case (the UI stores the model only). On a user_configurable or pii_mandatory project it is
accepted without offer-validation — an unroutable value is not rejected; it simply has no
effect (a conversation whose preferred model cannot be routed falls back to the normal Auto
pick). On a local_only project it IS validated (see Local-only access tier above): a
model-only default served only by cloud providers is rejected 400. On a self-serve workspace
a created or changed model-only default is also judged against the plan and the EU-Gov
add-on: a model outside the plan → 400 plan_model_not_allowed; a Myra-hosted model without EU-Gov →
400 eu_gov_model_not_allowed (an unchanged stored default stays editable). Accepted shape: any string
(subject to the local-only rule), or null to clear. When the preferred model can be routed, the server derives a gateway that serves it
(offer-filtered, PII-twin-aware) both for the composer's preselect and for conversation routing,
so callers never have to understand gateways. Saving a preferred model normalises the row to
model-only (any previously stored default_gateway_id is cleared).
A local preferred model is routable like any other: the local fleet needs no provider key and is served by every gateway, so pinning one now takes effect (it was previously accepted and then silently ignored). When the request wants or requires personal-data protection, the server derives a gateway that actually masks personal data and serves the pinned model; if no such gateway serves it, the pin is still honoured on another gateway and the normal PII-twin selection applies. On a subscription plan with a model list, a preferred model outside that list is not adopted.
Account deactivated mid-request. A create whose acting user is disabled or erased while the write runs answers 401 { "error": "unauthenticated" } — nothing is created; a four-eyes-held create whose requester is gone by approval time ends apply_failed / requester_unauthorized.
Getting a project
GET /admin/v1/projects/<ID>
Required role: project member or admin.
Who can see the project. The response carries three parallel access views so
"who has access?" is complete: members (direct chat_project_member rows),
groups (user groups granted access), and org_access — the
organization-wide grant. org_access is { "role": "editor" | "viewer" } only
when an org grant resolves to real access (a grant row exists and the tenant
capability org_share_enabled is on); it is absent otherwise, including when a
grant row exists but the capability is off (fail closed — see the org-share section
in groups, which also documents the raw org_grant
toggle field). member_count (and the members array length) counts named
(direct) members only — it deliberately does not fold in an org-wide grant,
since org size is not a project fact; the org grant is surfaced explicitly via
org_access instead.
members[].effective. Each members entry carries a boolean effective:
true when that member can actually open the project (the member's account is live
and belongs to the project's tenant; platform admins are exempt from the tenant
check), false for a stale row, for example a member of another tenant. Stale rows
are still listed so a project owner can remove them (DELETE
/projects/<ID>/members/<UID> works on them, including a stale creator row), but
clients must not treat them as people with access, for example as @mention
candidates. The flag is computed server-side from the same rule that gates project
access, and it fails closed: anything other than a definite true means no access.
If the members read itself fails, members degrades to an empty array.
members[].account_blocked. Each members entry also carries a boolean
account_blocked: true when the member's account is disabled or deleted, and
true for any row that is not effective; false otherwise. It is independent of effective (a disabled member of the project's own
tenant keeps its effective value) and is visible to every caller who can read the
project, the same audience as effective. A blocked member cannot be @mentioned
(see the conversation comments reference); clients should offer a member as a mention
candidate only when effective is true and account_blocked is false, and treat
anything other than a definite false as blocked.
conversation_count. An integer: the exact number of the calling user's own conversations in the
project — the same set Listing project conversations returns (own,
not deleted), counted without its page limit, so it never counts a conversation that list would not show
(other members' conversations included, admins too). 0 is a real zero. The create (POST) and update
(PATCH) responses carry it as well. The project is never returned without the count or with a guessed
one: a database fault while counting on GET answers 503 { "error": "temporarily unavailable; retry later" };
on POST / PATCH the write is already committed when the response is assembled, so a fault there answers
the sanitised 500 { "error": "internal error", "request_id": "…" } like a failed re-read of the knowledge
list — re-read the project with GET before retrying the write.
The response's knowledge list is source-ACL filtered, identical to retrieval: a
connector-synced document is included only if the requesting user is permitted to read
it at the source (SharePoint per-item ACL, or a Confluence or Jira source the user created or a
tenant admin published org-wide). A member — or an admin — never sees the filename of
a creator-only synced document they cannot open, matching the file browser, item preview,
download, and chat retrieval. Manual uploads are always listed to project members. See
connector sync — access control.
write_file filenames — accepted and rejected shapes. The chat write_file tool
stores text only. Accepted: any validated basename (no path separators, no control
bytes, ≤ 255 chars, no leading dot) whose extension is a text/code format or a
renderable document format (.docx, .pdf, .pptx, .xlsx, .odt, .odp, .ods) —
document-named text is rendered into the real binary at download time via the
/chat/export-* pipeline, so the name's promise is kept. Rejected (tool error steering
the model to a renderable or plain-text name): binary extensions with no renderer —
legacy Office (.doc/.xls/.ppt), archives (.zip/.gz/.tar/.7z/.rar), images
(.png/.jpg/.gif/…), executables/libraries (.exe/.dll/.so/.wasm/.jar),
audio/video, and fonts. A rejected write persists nothing. Content is rejected too — by write_file,
edit_file and the code interpreter's text outputs alike, nothing stored — when it carries an aig-elided-…
placeholder, the shortened form in which read_file shows a file's large embedded fonts and images (the
stored file is the one source of those bytes); see
Embedded resources in HTML and SVG files.
Chat-generated files follow the source chat's share gate. A file produced by a chat
tool (write_file / edit_file / the code interpreter) inside a project chat is stored as project
knowledge, but it is not auto-published to the other members. edit_file changes only a file the
caller wrote (a member who can read it through a shared chat cannot edit it in place), and a file the
caller cannot read is answered as if no file of that name existed (and is never overwritten by it). A chat
tool only ever overwrites the caller's own text file under that name (a code run can also update the caller's own generated office or PDF file, see below) — visible to the caller, written
by the caller, inside the request's file selection. When write_file names a file held by anything else —
a file the caller cannot see, a file another member wrote (even one shared with the caller), an uploaded or
synced document, a generated binary — the new file is stored under the next free name (report-2.md,
report-3.md, …, the same rule as code-interpreter outputs) and the assistant is told that name; nothing
is overwritten. The next call in the same conversation reuses that copy: a held name resolves to this conversation's most recently written chat-generated numbered variant, by id, and write_file overwrites it as a full rewrite (a file the model deliberately wrote as deck-2.html counts as the copy of deck.html); another conversation's or another member's copy is never reused, and a numbered file not written by a chat tool is never taken for it. edit_file from an attachment does the same when the name belongs to a file the caller
cannot see; a file the caller can see but may not change is refused, as above. (The renamed result shows that the name is in use —
the same signal a code-interpreter output or a create of a taken name gives.) The rule the assistant is given and the chat shows: the exact name of the caller's own text file saves a new version of that file (same row, same id), any other name creates a separate new file; the tool result tells the assistant which of the two happened, and a second stored write of the same file within one turn is reported neutrally.
Code-interpreter outputs: in place or as a copy. A code run's output file — text, or a generated binary file (for example Word, PowerPoint, Excel, PDF or OpenDocument files) — overwrites an existing file in place (same file, new version) only when all of
these hold: the existing file was generated by a chat tool (not uploaded or synced); the run loaded that
file; the output has the same name and, for a generated binary file, the same file type; the caller
created it; it is visible to the caller and inside the request's file selection; and it is still at the
version the run loaded. In every other case the output is saved as a new numbered copy (report-2.xlsx)
and nothing existing is changed: an uploaded or synced file, a file another member created (even one shared
with the caller), a name redirected to the next free one, a different file type, a file somebody else changed
since the run loaded it (that other change is kept), and a file that was deleted or can no longer be
stored. In a project chat the caller's own generated office and PDF files of the project that are inside the
selection are loaded for the run automatically and can therefore be updated in place; another member's
generated file is never touched. Like the conversation
that produced it, it is visible only to its creator until that conversation is
shared into the project (shared_in_project); once the chat is shared, its generated
files become visible to all members (and un-sharing hides them again). This applies to
every project-knowledge surface — the file list, item preview, download, the card count,
and chat/inference retrieval. Manual uploads and admin-added notes are unaffected (always
member-visible). Note: files generated before this control shipped that cannot be traced
to a source conversation remain member-visible (a deliberate backward-compatibility
grandfather — existing shared files are not retroactively removed).
This gate is now surfaced so a member is never left with a silently shorter list.
Each knowledge row carries an advisory, read-only member_visible boolean — false
marks a chat-generated file the caller can see only because they are its creator (its
chat isn't shared yet), which the UI badges "Only you". A separate endpoint reports how
many files are hidden from the caller by this gate (see Hidden knowledge count
below). Both are display hints only — enforcement remains the server-side gate; the
hidden count is a deliberate, bounded cross-user disclosure (a number of other members'
private generated files, never their names or content).
In addition to the stored fields, the response includes the writable permission_tier enum and a server-derived, read-only permission object:
{
"permission_tier": "local_only",
"permission": {
"tier": "local_only",
"allows_cloud": false,
"pii_mandatory": false,
"user_configurable": false
}
}
The permission object is computed from permission_tier on every read; it is never persisted and is never accepted as input. allows_cloud is false only for local_only, pii_mandatory is true only for pii_mandatory, and user_configurable is true only for user_configurable.
Updating a project
PATCH /admin/v1/projects/<ID>
Required role: owner or editor. Changing permission_tier (the project's PII/residency policy) or conversation_retention_days requires the project owner or a platform admin — an editor may edit every other field, but a 403 is returned if an editor attempts to change either of those to a new value.
A body that is valid JSON but not an object ([], "x", 7, true, null) is 400 malformed_body on create and update; only an absent or blank body is read as no fields.
Patchable fields: name, description, instructions, icon, color, permission_tier, default_gateway_id, default_model, conversation_retention_days (an integer 30–3650, or null/0 to clear; a bad value returns 400). A name supplied on PATCH is validated exactly as on create (non-empty, ≤255 code points, valid UTF-8 — otherwise 400 name_too_long / invalid_name); it may not be cleared: an empty string or null returns 400 invalid_name. A supplied description, instructions or icon is validated exactly as on create (code-point cap + valid UTF-8, fail-closed 400 <field>_too_long / invalid_<field>). description and instructions accept an explicit null to clear; an icon null resets it to empty ("") — the icon column is NOT NULL, so a null is never forwarded as SQL NULL.
When a PATCH touches default_gateway_id or default_model, the resulting effective pin
(the new value where supplied, else the project's stored value; an explicit null clears it) is
run through the same offer validation as create — so pinning a model the
gateway would residency/allowlist-block returns 400 with the corresponding code. A PATCH that
does not touch either pin field (e.g. a rename) is never offer-validated, so an unrelated edit
on a project that already carries a pin is unaffected. The project UI saves the preferred model
as default_model with default_gateway_id: null (model-only normalisation); patching only
non-pin fields leaves any stored pin untouched.
A model-only PATCH that leaves a previously stored pin in place re-checks that stored pin
against the tenant too: a stale pin naming a gateway that is no longer the tenant's answers
404 gateway_not_found (send "default_gateway_id": null to clear it). On PATCH, as on create, a gateway id is accepted in any letter case and the project stores the gateway's own id, never the spelling sent.
permission_tier may be changed but never cleared: it is NOT NULL, so sending an explicit null (or an unknown value) returns 400. Omit the field to leave the tier unchanged.
Write failures (create, update, delete). A write that rolled back on a transient database
conflict, or found no database connection, changed nothing and answers 503 { "error": "temporarily unavailable; retry later" } — send
it again. A project deleted between the access check and the update answers 404 { "error": "project
not found" } (it used to answer 200 for an update that never happened). Any other database fault
answers the opaque 500 { "error": "internal error", "request_id": "<id>" } — never the database's own text (see Storage faults). A create stores the project
and its creator's owner membership together or not at all (a failure can no longer leave a project
without an owner). The same classification decides a four-eyes approval: a
transient conflict leaves it pending, any other fault fails it with reason db.
Departments. A project carries department_id (the owning department, or null) and gateway_locked (0/1), returned by GET and the list. Both are changed only through PUT /projects/<ID>/governance. On a PATCH that changes default_gateway_id: a locked project refuses it with 409 project_gateway_locked (unlock first); a department-owned project refuses a gateway outside its department's set with 422 project_gateway_outside_department. Both checks are repeated inside the write, so a concurrent lock or department change cannot be bypassed. These two answer before the ownership check above. A governance change (PUT /projects/<ID>/governance) that would leave a pin the tenant does not own is refused with the same 404 gateway_not_found and writes nothing; a four-eyes replay of a stale foreign pin fails as apply_failed and writes nothing.
Deleting a project
DELETE /admin/v1/projects/<ID>
Required role: owner (or platform admin); an editor or viewer gets 403 only project owners may delete a project. On success the response is 200 {"ok": true}. A project whose gateway is locked can be deleted only by someone who may govern it — its owner (an authoring platform role, not in an impersonation session) or department administration (403 project_gateway_locked otherwise; a failure to read the caller's project role is 503) — deleting it would release its conversations from the lock. The check is repeated against the project's current lock when a four-eyes-held delete is applied; an unlocked project's delete never depends on it.
The conversations attached to the project are detached but not deleted. The project's persistent
code-interpreter sessions (the live Python state of its conversations) are ended right away, freeing
the members' session slots; a detached conversation's next code run starts a fresh session. This
runs in the background after the delete has succeeded and never fails it. Any of the project's
documents still queued for ingestion (status uploading or pending) are cancelled, so no
further processing is started, and no embedding runs, for the deleted project.
Detaching lifts a residency restriction. If the project's access tier was Local only or
PII mandatory, the conversations it held carried that restriction only through their binding
to it — so once they are detached, their future turns may route to a cloud model, or egress
without a masking mandate, like any unbound conversation. This includes conversations owned by
other members. The delete is authorised (it requires owner rank, the same rank that could set
the tier to user configurable and release everything anyway) and is therefore not blocked,
but it is recorded: the audit log gets a project.conversations_released row carrying the
project's tier and the number of conversations released, and the delete dialog states the
consequence before the click. The detach and this audit row are one transaction, and so is the whole delete: if releasing the conversations fails, the project is not deleted (retryable 503 when nothing was stored, otherwise the sanitised 500). Releasing a single conversation is gated separately — see
Updating a conversation.
Audit atomicity. Every project mutation on this page (create, update, delete, governance change, adding a member) is committed together with its audit entry in one database transaction: there is never a change without its entry or the reverse. If the transaction fails, nothing is stored; the answer is a retryable 503 { "error": "temporarily unavailable; retry later" } when nothing was written, otherwise the sanitised 500 { "error": "internal error", "request_id": "..." }. A request refused by the domain rules (duplicate member, locked project, unknown user) writes no audit entry. Sharing the owner's conversations runs in its own transaction together with its audit entry; if it fails, the member add still stands and the answer is 201 with "shared_count": null, "share_failed": true.
Listing add-member candidates
GET /admin/v1/projects/<ID>/members/candidates
Returns the users of the project's tenant who are not already members — the
data source for the invite dialog's browsable email typeahead. Each entry is
{ id, email, name } (no role/login/status metadata). The server excludes, and
the client cannot broaden: soft-deleted users and existing members.
Unlike the groups variant, platform admins are included — the add-member
mutation accepts any same-tenant user, so an admin colleague is a valid,
offerable target. The result is capped at 1000 rows (ordered by email);
anyone beyond the cap is still addable through the exact-email path.
Authorized like the add-member mutation: project owner (or platform admin).
An under-rank member (editor/viewer) → 403; an unknown project, a foreign
tenant, or a non-member → 404 (no existence oracle). A database fault while
reading the roster → 503 (retryable; the 403/404 authz stage precedes it).
Exposure note (deliberate): this is the first tenant-roster enumeration surface
below the groups (GROUPS_MANAGE) tier — any project owner reads the tenant's
user emails and names. In this pure-B2B product a tenant is one organisation,
so the roster is the inviter's own colleagues; every other picker
(agent/prompt sharing) stays exact-email only. The workflow approver box is the one other
picker that searches the roster (POST /users/roster/search, see
Searching the roster); it is open to exactly the same
callers (anyone except a viewer or the demo identity), so it adds no new exposure.
Adding a project member
POST /admin/v1/projects/<ID>/members
Required role: project owner (or platform admin).
| Field | Type | Required |
|---|---|---|
user_id |
string | yes — an existing, non-deleted user of the project's tenant. Absent → 400 { "code": "user_id_required" }; present but not 1–36 printable ASCII characters, no spaces (0, true, null, "", an object, over 36 bytes, a space, a non-ASCII character) → 400 { "error": "invalid user_id", "code": "invalid_user_id" }, checked before any lookup. A well-formed id that is unknown, in another tenant or a deleted user is 404 { "error": "user not found", "code": "user_not_found" }, recorded as one access.denied security event. |
role |
owner | editor | viewer |
no — defaults to viewer |
share_existing |
boolean | no — defaults to false |
The new member receives a push notification on the project.
share_existing (bulk-share at invite). When set to boolean true, every conversation the
calling user currently owns in this project that is still private is shared into the project
Feed (shared_in_project), so the newly-added member can see them. This is a convenience for
the existing per-conversation share to project action, not a new capability:
- Authorization is server-side and fail-closed. The endpoint already requires the caller to
be the project owner (or a platform admin); the bulk-share is additionally scoped to the
caller's own conversations (
WHERE user_id = <caller>), so it can never expose another member's private conversation — only that conversation's own creator may share it. The client cannot widen this scope. - Input validation. Only a real JSON boolean
truetriggers the share. Any other value —"true"(string),1,null, an object/array, or the field's absence — is treated asfalse(no share). Theshare_existingflag is never the authorization boundary; the role gate and the owner-scoped query are. - Feed-wide, not per-invitee. Sharing to the Feed makes a conversation visible to every
current and future project member, exactly like the per-conversation share action — not only
to the invited member. Un-sharing is per-conversation (
DELETE …/conversations/<ID>/share-project). - Idempotent. Already-shared conversations are skipped, so re-inviting (or a repeated call) shares nothing further.
- Audited. The membership grant (
project.member_added) is always written to the audit log; a successful bulk-share additionally writesproject.member.share_existing(with the target user and the number of conversations shared). If the bulk-share hits a database fault nothing is shared and no share audit row is written — the fault is logged server-side and reported to the caller (see the response below).
Response. 201 with { "ok": true, "shared_count": <N> } — the number of conversations
newly shared (0 when share_existing was not set or nothing was eligible). If the membership
was added but the bulk-share hit a database fault, the response is still 201 (the member was
added) with "shared_count": null and "share_failed": true, so the outcome is never silently
swallowed.
Rejected (validated server-side; the client is never the authz boundary):
409—user_idis already a member. The add is a plain insert; it never rewrites an existing member's role — role changes go through the PATCH below, where the last-owner guard applies. (Previously a re-add silently overwrote the role, which could demote the last owner.)404— two distinct shapes, told apart by the typedcode:- target user: unknown user, a user of another tenant, or a soft-deleted user (no deletion
oracle: same status and body as unknown) →
{"error":"user not found","code":"user_not_found"}; recorded as oneaccess.deniedsecurity event (status404, no entity), whoever the caller is, platform admins included. A malformeduser_idstays400and a storage fault stays503; neither is recorded. The same answer is given when the user is deleted or moves workspace between the up-front check and the insert: the check is repeated inside the insert itself (the user row is read under a shared lock, so a concurrent account deletion either finishes first and the add is refused, or runs after and removes the new membership). A project or user without a workspace id is never "in the same workspace" as anything, so it cannot be a member target. Disabled (not deleted) users can still be added. - the project itself: the caller can no longer see it (removed from it, or it was deleted) →
{"error":"not found"}with nocode; recorded as anaccess.deniedsecurity event.
- target user: unknown user, a user of another tenant, or a soft-deleted user (no deletion
oracle: same status and body as unknown) →
403— the caller can see the project but is below the owner role (for example demoted while an invite dialog was open) →{"error":"forbidden"}; an impersonation session is refused with{"error":"…","code":"impersonation_forbidden"}.400— missinguser_idor an invalidrole.503{ "error": "temporarily unavailable; retry later" }— the user lookup failed (a database read fault; nothing added — retry).500— a storage fault on the write (the member was NOT added).
A rejected request (409/404/400) performs no membership audit entry,
no push notification, and no share_existing bulk-share — those run only after
a successful insert.
Updating a member role
PATCH /admin/v1/projects/<ID>/members/<USER_ID>
Required role: project owner (or platform admin).
| Field | Type | Required |
|---|---|---|
role |
owner | editor | viewer |
yes |
Returns 409 { "error": "cannot demote the last owner", "code": "last_owner" } when the change would demote the last effective owner of the project; clients should branch on code, not the message. Stale owner rows (effective: false) are not counted. Ownership is counted per person: a direct owner who is the only owner of the project and is also a member of an owner group is still refused (409) when their direct owner row is demoted or removed, even though the group grant would keep them an owner. The last-owner check and the write run in one transaction that first locks the project row, so two concurrent demotions/removals of the two remaining owners cannot both succeed: exactly one gets 409, and the project always keeps an owner. Rejected: a project deleted concurrently is 404; a request may block, behind a long concurrent ownership transaction on the same project, for up to the database lock-wait timeout before it is answered; a lock wait (after one lock-wait timeout) or a deadlock that persists through the retries is 503 { "error": "temporarily unavailable; retry later" } with nothing written (retry the request).
This guarantee covers the member routes, account erasure, user soft-delete (including self-delete and moving a user to another tenant), tenant deletion with its users, SCIM deprovisioning and the four group writes (revoking or downgrading an owner grant, removing a member of an owner group, deleting an owner group; see groups). Soft-delete paths hand an owned project to a live admin of the project's tenant (audit action project.owner_handed_over); with no live admin the project is kept ownerless, a warning is logged and a project_without_owner alert fires after the commit. Identity-provider group sync (SCIM group member remove / replace / unlink, SAML and OIDC claim sync, SCIM department sync) is covered the same way as a soft-delete path: a project the sync would leave ownerless is handed to a live admin of the project's tenant (reason scim_group_member_removed, scim_group_members_replaced, scim_group_unlinked, saml_claim_sync, oidc_claim_sync or scim_attr_sync), and the sync itself is never refused, and it also covers projects in the trash (a trashed project is handed over too), while the admin-route refusal covers live projects only; the sync takes the project lock for the projects the affected group owns. The locking owner count locks the user rows of the owners it counts; a deadlock is resolved by an internal retry, so an admin-route caller still sees 200 or 409 (an identity-provider sync never answers 409), a lock wait is not retried and answers 503 after one lock-wait timeout, with nothing written, and a deadlock that persists through the retries is 503 too.
Removing a member
DELETE /admin/v1/projects/<ID>/members/<USER_ID>
A member may remove themselves (USER_ID equals the caller). Removing other members requires the project owner role (or platform admin). The last owner cannot be removed: the response is 409 { "error": "cannot remove the last owner", "code": "last_owner" }. Stale owner rows (effective: false) are not counted, so they can always be removed. The check and the delete are one transaction under the project row lock (same guarantee, 404 and 503 behaviour as "Updating a member role").
Listing knowledge attachments
GET /admin/v1/projects/<ID>/knowledge
Required role: project member.
Returns a JSON array of knowledge rows (source-ACL and share-gate filtered for the
caller). Each row carries the stored fields plus a read-only member_visible boolean:
false means this is a chat-generated file the caller sees only as its creator (its chat
isn't shared into the project yet). A chat-generated row also carries
source_conversation_id — the id of the conversation that produced the file (absent/null
for an uploaded file, which has no source chat). It is derived from the same
chat_message_file → chat_conversation link the member_visible gate uses, so the two
never disagree on which conversation governs a file. Each row also carries a read-only
chat_generated boolean: true when the file was made in a chat (write_file /
code_interpreter), false for an upload or note. The UI uses it to offer a "Share this
chat" action on an "Only you" row: sharing that conversation (POST
/conversations/<id>/share-project) un-hides the file to project members. Rejected: a
non-member is refused by the access gate with the audited 404 (a member below editor gets 403). A DB error — including one in the access gate itself — is 503 { "error": "temporarily unavailable; retry later" }, never a 403, a null or
false-empty 200.
A row whose ingest_status is extracting and whose scanned PDF is being read page by page also carries
ocr_progress: { "page": 3, "total": 10 } (1 <= page <= total <= 1000000, whole numbers). The key is
omitted (never sent as null) for every other row, for a row that has not reported a page yet, and whenever the stored
pair would not satisfy that rule, so a client never has to guess: show "page 3 of 10" when it is there, the
plain "Processing" otherwise. It is a display hint only. Every request returns the same value, whichever server answers it; it never
changes the file's version (updated_at) and starts over when the file is processed again. The web app polls this list every few seconds while a file
is processing and shows "Reading: page 3 of 10…" on the file card.
Hidden knowledge count
GET /admin/v1/projects/<ID>/knowledge-hidden-count
Required role: project member.
Returns { "hidden_count": N } — how many of the project's files are hidden from the
calling user by the chat-generated share gate (chat-generated, unshared, not their own).
Backs the UI hint "N files are only visible to their creator". The count is a deliberate,
bounded cross-user disclosure: it reveals only the number of other members' private
generated files, never their filenames or content. A DB error is 503 { "error": "temporarily unavailable; retry later" } (fail-closed —
never a misleading 0). The path is hyphenated (not /knowledge/hidden-count) so it can
never be mistaken for a single knowledge item id.
Knowledge folders
A folder normally exists only while a file's leading path names it. An explicit folder is a stored folder row that exists even when it holds no file; the web client shows the explicit folders together with the folders derived from file names.
GET /admin/v1/projects/<ID>/knowledge-folders
Required role: project member (a viewer can read). Returns a JSON array of { "id", "path", "created_at" } rows sorted by path (byte order); [] when the project has none. Errors: 404 for an unknown or inaccessible project, 503 for a transient storage fault.
POST /admin/v1/projects/<ID>/knowledge-folders
Required role: project owner or editor (or platform admin); a viewer gets 403 { "error": "forbidden" }. Body: { "folder": "<PATH>" }. The path obeys the folder rules of the move endpoint (at most 96 UTF-8 bytes per segment, 200 in all, 12 levels, leading and trailing spaces of a segment are trimmed, no . or .., no control character or backslash) and is stored exactly as the server sanitized it; the response names the stored path, so use it rather than the string you sent. Responses:
| Status | Body | Meaning |
|---|---|---|
200 |
{ "folder": "<STORED_PATH>", "folders": [ … ] } |
The folder exists afterwards. Creating a path that already exists is idempotent and also 200 (no second row). |
400 |
{ "error": "…" } |
A missing, empty or non-string folder, or a path the folder rules refuse. |
409 |
{ "error": "…", "code": "knowledge_folder_limit", "limit": 500 } |
The project already holds 500 explicit folders (limit names the cap) and the path is new. Branch on code. |
403 |
{ "error": "forbidden", "code": "project_role_insufficient" } |
The caller is a project viewer (write needs editor). |
404 |
{ "error": "not found" } |
An unknown or inaccessible project. |
500 |
{ "error": "…" } |
A storage fault, or the row was written but the folder list could not be re-read; retrying is safe (creating an existing path is idempotent). |
503 |
{ "error": "temporarily unavailable; retry later" } |
A transient storage fault; nothing was written, retry. |
Folder paths are case-sensitive: Leer and leer are two folders.
DELETE /admin/v1/projects/<ID>/knowledge-folders/<FOLDER_ID>
Required role: project owner or editor (or platform admin); a viewer gets 403; an unknown or inaccessible project is 404; a storage fault, or a failed re-list after the row was deleted, is 500 (a retry then answers 404, as the row is gone). Deletes only the explicit folder row and returns the refreshed array (200). It never deletes or moves a file: a folder that still holds files keeps showing, derived from those files. An unknown id, or an id of another project, is 404 { "error": "not found" }.
Explicit folders are part of the project only; they are not included in a project export or in retrieval, and they are removed when the project is permanently deleted.
Uploading knowledge
POST /admin/v1/projects/<ID>/knowledge
POST /admin/v1/projects/<ID>/knowledge/upload
Required role: owner or editor.
The first form accepts a JSON body for plain-text knowledge entries. The second form also accepts a JSON body for file uploads:
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 |
|---|---|---|---|
filename |
string | yes | Original file name; a leading path is the file's folder (reports/q1/report.pdf). See the filename rules below. |
data |
string | yes | File bytes, base64-encoded. |
mime_type |
string | no | Defaults to application/octet-stream (null and "" count as absent). Valid UTF-8, at most 128 characters; a non-string, malformed or longer value → 400. A known extension overrides it. |
Filename rules (both forms, the upsert below, and the deprecated PUT …/knowledge/<ENCODED_FILENAME>
path segment). The name is validated once, at the trust boundary, before any processing or storage
call. Accepted: a non-empty string of at most 255 characters (code points — a 255-umlaut name is
fine), valid UTF-8, where every /-separated segment is non-empty and is not . or ... Rejected with
400 and a reason: a missing / non-string / empty name, more than 255 characters, malformed UTF-8, a
control character (bytes 0x00–0x1F, 0x7F) or a backslash, a leading or trailing /, an empty
segment (a//b.txt), or a . / .. segment. The leading path is a knowledge folder and obeys the
folder rules of the move endpoint: a folder segment is at most 96 UTF-8 bytes and the whole
folder at most 200 UTF-8 bytes (bytes, not characters — é counts 2, so 49 of them in one segment
are refused), at most 12 levels, and no segment may start or end with a space. The 255-character
limit covers the whole filename. Existing rows are not rewritten: a legacy row whose folder breaks
these bounds answers 400 invalid_filename on a by-name PUT; update it by id (the by-id save does not
re-validate the name) or move it into an allowed folder. Names are never rewritten — what the client sends is
what is stored, byte for byte, including bidirectional-control and zero-width characters (for example U+202E). The web client never rewrites the stored name either: it only changes how the name is displayed (see the Files panel in the workspace guide) and what name a browser download gets. On the JSON-body forms (POST …/knowledge, POST …/knowledge/upload and the upsert)
the two rejections carry a code:
an absent name (missing, "") is filename_required, a malformed one (any other rejected
value, including null, a number or an array) is invalid_filename.
Upload errors (POST …/knowledge/upload). Every refusal of the uploaded content carries a stable top-level code next to the error prose; branch on the code, never on the prose. The access refusals (404 not found from the project-access check, 403 forbidden) are not about the content and still answer the plain {"error": "…"} shape without a code.
| Status | code |
Meaning |
|---|---|---|
| 400 | malformed_body |
The body is not valid JSON or not a JSON object. Defined in Error codes. |
| 400 | data_required |
data is absent, null or "". |
| 400 | invalid_data |
(formerly data_invalid_base64) data is present but is not a base64 string, or does not decode. |
| 400 | invalid_mime_type |
mime_type is not a string, is malformed UTF-8 or is longer than 128 characters. |
| 413 | file_too_large |
The file is over the size limit for its type. |
| 413 | text_too_large |
A plain-text file is over 7.5 MB. |
| 422 | unsupported_file_type |
The bytes match no supported document type and are not text (for example an archive). |
| 422 | pdf_unreadable |
The PDF is corrupt or password-protected. Permanent: retrying the same file cannot help. |
| 503 | pdf_check_unavailable |
The PDF could not be checked right now. Retryable: the response carries Retry-After: 10. |
| 422 | malware_detected |
The malware scan flagged the file. Defined in Error codes. |
| 413 | scan_limit_exceeded |
The scanner reports the file exceeds its size limit. Defined in Error codes. |
| 503 | scan_unavailable |
A file that must be scanned could not be. Defined in Error codes. |
| 429 | ingest_cap |
Too many of the workspace's documents are still being processed. Defined in Error codes. |
| 503 | ingest_busy |
The shared processing pool is saturated. Defined in Error codes. |
| 503 | ingest_unavailable |
Async ingestion is not provisioned on this deployment. Defined in Error codes. |
| 411 | length_required |
The request has no Content-Length. Defined in Error codes. |
Name conflicts (409, code: "knowledge_name_conflict"). A file name is unique per
project, and "the same name" is the database's notion (collation utf8mb4_uca1400_ai_ci): the
comparison ignores case (Notes.txt = notes.txt), accents (Café.txt = Cafe.txt), ß/ss
and ligature folds, and trailing spaces. A write whose name already exists — on either form, or an
upload against a pasted-text row and vice versa — is rejected with 409 and a body naming the
request's spelling: {"error": "A document named \"notes.txt\" already exists in this project.
Delete it first.", "code": "knowledge_name_conflict"}. Branch on code; the prose may change. The
existing row is untouched, sibling uploads in the same batch are unaffected, and no second row is
ever created. (The upload form's extension gate runs first, so notes.txt with a trailing space is
a 422 Unsupported file type there, not a 409.) Any other insert failure is the sanitised
500 { "error": "internal error", "request_id": "…" } — the database error is logged, never returned.
The decoded file size is capped per format at the trust boundary (the browser-supplied
mime_type is advisory — the cap is keyed on the canonical format resolved from the file extension,
so a mislabelled file cannot dodge it). A file over its cap is rejected with 413 and a message that
names the limit, before any processing:
| Format | Decoded size cap |
|---|---|
Office + PDF (.pdf, .docx/.doc/.pptx/.xlsx/.xlsm/.ods/.odt) |
100 MB |
XML (.xml), JSON (.json), HTML (.html/.htm) |
64 MB |
Text (.txt/.md/.markdown/.csv/.yaml/.yml/.rst/.log) |
7.5 MB (must fit the extracted-text storage limit) |
Images (.png/.jpg/.jpeg/.webp) and everything else |
20 MB |
Large uploads are stored chunked internally (a single file may exceed the database packet size); this is transparent and does not change the request shape.
Malware scanning (fail-closed, opt-in per gateway). Malware scanning is enabled per gateway
(av_scan.enabled in a gateway config) and is off by default. A project has no single gateway and
its knowledge blob is persisted and served back raw, so the upload is scanned when the project's
tenant has malware scanning enabled on any of its gateways; otherwise this step is skipped. When it
applies, the decoded bytes are streamed to a self-hosted ClamAV daemon (clamd, INSTREAM) after the
size caps and before the document is staged or stored. An infected verdict rejects the upload
with 422 and code: "malware_detected" (the ClamAV signature is logged operator-side only, never
returned). If clamd is unreachable, times out, or errors, the upload is rejected — not accepted
unscanned — with 503, code: "scan_unavailable" and a short Retry-After. The virus scanner itself is
configured for your deployment by Myra.
PDF, text (.txt/.md/.markdown/.csv/.yaml/.yml/.rst/.log), and Word (.docx, legacy .doc) uploads are processed asynchronously and
segmented. (This ingestion path is deliberately distinct from the synchronous chat/workflow
read of the same .docx: here the file is segmented into char-offset units with a heading trail for
retrieval and citations — a contract the pandoc-to-Markdown chat reader cannot produce — so the two
paths use different extractors and their stored/preview text may differ.) The endpoint validates the file synchronously at upload (a corrupt or password-protected PDF is rejected up front — a PDF whose page tree is merely damaged but which viewers open is repaired and accepted (see PDF extraction failures are classified), and a connector-synced PDF that stays unreadable records a malformed: ingest reason — with 422 "Could not read the PDF (it may be corrupt or password-protected)" — no row, blob, or ingest slot is consumed, so it never stages pending only to terminal-fail later; a PDF encrypted with an owner password but no user password is readable and still ingests; a text
file over 7.5 MB returns 413; a .docx that is not a valid Word zip, or whose XML declares a DTD,
is later marked failed by the worker with a clear reason), stores it, and returns 202 Accepted with the row at
ingest_status: "pending" — extraction + segmentation then run in the background and the status
advances to segmented (or partial for a truncated large PDF). If a PDF or Word document's
extracted text exceeds the 7.5 MB storage limit (the extracted text can be far larger than the
uploaded file), the document is not failed: its text is truncated to the limit on a character
boundary and stored as a doc-level extracted entry (readable in chat up to the doc-level size cap,
without a page/section index), and the truncation is recorded on the document's ingest trace. This
degrade is distinct from the text-file case above, where an over-7.5 MB .txt/.md/.markdown/.csv/.yaml/.yml/.rst/.log upload is
rejected with 413 before processing. A text upload whose content is binary rather
than text — a non-text file renamed to a text extension, detected by a NUL byte in the decoded content —
is marked failed by the worker (it is not silently stored as mojibake); the persist boundary rejects
any text-file extractor output carrying a NUL, so a masquerading binary never reaches project knowledge.
PDF and image (OCR) extraction is different: those formats have an OCR fallback, so their extractor
scrubs NUL/control bytes (rather than failing the document) and, for a PDF, routes a garbage or
broken-font text layer to OCR — see the note on the PDF text-quality gate under
Managing knowledge files. A stray control byte in a
PDF's text layer therefore ingests cleanly instead of losing the document. The file
extension determines the format (the browser-supplied MIME is overridden — .md/.csv/.yaml/.yml/.rst/.log/.docx are
canonicalized regardless of what the browser sends; .yaml/.yml/.rst/.log are treated as plain
text and line-segmented like .txt). Note: .yaml/.yml/.rst/.log files uploaded before this
became searchable are stored doc-level and are not retroactively indexed — re-upload them to make
them searchable. Poll GET …/knowledge (or the item endpoint) until the status leaves
pending/extracting. If too many of the tenant's documents are still processing, a further upload
returns 429 with code: "ingest_cap" and Retry-After: 5 (retry once some finish). The check runs before the body is read, so a refused upload costs no decoding; the web app retries it by itself. Because of that order, at the cap any upload first gets 429 ingest_cap, even one whose name or body would be refused with 400/422; a client that retries sees that permanent refusal only once the cap has cleared. Text files gain a line segment index (L.n
locators, or L.a–b for a range; Markdown carries the heading trail, CSV carries the header as
section context). A very long text file — more paragraphs, headings or row groups than the index
holds — is indexed with each entry covering a RANGE of lines rather than a single unit, so the
index still reaches the document's last line and every part of it stays citable; .docx
gains a para index (¶N locators + the Word heading trail as section context). Legacy Word 97-2003 (.doc) gains a line index (L.N locators, like a text file; the 100 MB cap above applies). A .doc that is
corrupt, truncated, password-protected, or not actually a Word binary (for example RTF or HTML saved with a .doc name) is not rejected at
upload: it is accepted with 202 and later marked failed by the worker with a reason (malformed: or password-protected:), never ingested
as text. All become
page/section-citable and RAG-narrowable like PDF. PowerPoint (.pptx) gains a slide index (slide N locators + the
slide title as section context) and Excel (.xlsx/.xlsm) gains a sheet index (sheet N
locators + the sheet name as section context), also async. Each sheet's name also heads its own block in
the extracted text (a plain header line, the same way a heading heads a .docx paragraph block), so the
model can name the workbook's tabs and attribute rows to the right one — not just read anonymous cells. Images (.png/.jpg/.jpeg/.webp) are OCR'd asynchronously (on-prem qwen vision model) into a region-segmented
doc with ocr confidence — the transcribed text is retrievable and RAG-searchable like any other
document. Its segments are cited under Sources but marked confidence: "ocr" (OCR offsets are
best-effort, not verbatim page citations), and figures/numbers should be verified against the original. Same async staging as PDF
(202 → pending → extracted/segmented). An image or PDF with no readable text (a photo, a
blank scan, or an OCR that returned nothing usable) is stored non-terminally with a short
"no readable text" marker and is served (never failed) — the row lands segmented with an empty
index, not extracted; its ingest trace then ends embed_empty and it is not semantically searchable. A blank or near-uniform image (all white, a solid colour, scanner dust) is not sent to OCR at all, and an empty OCR answer — including an empty code fence — counts as no readable text, so the model cannot invent text for an image that has none (the result is always the marker, an empty index and embed_empty). A 16-bit / 32-bit greyscale or float image (a scan, a DICOM export) is converted to 8 bit from its own data (never clipped to white) before it is sent, in chat image description as well as ingest. A transparent image is never sent as-is: its transparent area is filled white, or black when white would hide the content (white or light text on a transparent background), and the result is sent as a PNG, so the text stays visible (in chat image description as well as ingest); a fully transparent image counts as blank. An image over 100 megapixels (width × height, read from the file header) is not OCR'd at all — the upload is kept, its text is the marker [Image — no readable text: too_large, over 100 megapixels, not OCR'd] with an empty index (segmented, trace embed_empty); a workflow file read or web fetch of such an image fails with the reason too_large. Only PNG, JPEG and WebP content is decoded for OCR: a file of another format under one of those names (an ICO, ICNS, GIF, BMP or TIFF renamed to .png) is rejected as an unsupported image, never decoded. Very faint text on a near-uniform image, and one-pixel-wide strokes (a thin hand-drawn line or signature on white), can fall below the blank-image threshold and be treated as no readable text. Region locators keep their meaning: r.N is the N-th non-empty region. Unsupported image types (.gif/.bmp/.tiff/.heic/
.svg) return 422. An uploaded image — and a scanned PDF page, which is OCR'd the same way — is
untrusted input (the OCR model's response is untrusted too): the transcription prompt carries the
data-boundary clause described in the
threat model, which instructs
the model to treat text inside the file as data to transcribe rather than as instructions to follow.
As a further guard, if the OCR model echoes the task prompt back verbatim instead of transcribing
(a known failure mode), that echoed output is detected and dropped rather than stored as document
content — a page/image with only an echoed prompt becomes the "no readable text" marker. If the text recognition wraps a ```markdown or ```md code fence around the whole transcription, that fence is removed so the stored text is the page's own content; code blocks that are part of the page are kept as they are. Documents uploaded before this change keep their existing text until they are uploaded again. When an OCR
transcription is truncated because a dense page exceeded the model's output window, the document is
stored partial (its extracted text is real but incomplete) and, when read in chat, carries an honesty
marker so the model does not treat it as complete. A dense page is transcribed in several short
requests that each continue the transcription where the previous one stopped (up to 8 per page), so
a long page no longer has to finish inside one request's time limit; only a page still unfinished
after that bound, or after the extraction's time budget, is stored as truncated. If a continuation
comes back empty, repeats the start of the page, is not a well-formed answer (not valid JSON or the wrong shape), or is rejected with a non-retryable 4xx answer, the
text read so far is kept and the page is marked truncated rather than the upload failing. Documents
ingested earlier keep the transcription they were stored with; re-upload a document to have it read
again with the current method.
Like the other spotlighting markers it reduces, but does not eliminate, the risk. The clause
applies at ingest time going forward; documents ingested earlier keep the transcription they were
stored with. OpenDocument spreadsheets (.ods) are extracted asynchronously
(202 → pending → segmented): the sheets are flattened to CSV and given a line (L.n)
index like a .csv — a multi-sheet .ods is concatenated into one table (no per-sheet names or
sheet N locators, unlike .xlsx). This matches how a connector-synced .ods is ingested.
Legacy .xls is unsupported (422). The JSON
POST …/knowledge form (a JSON body {"filename", "extracted_text", "content_type"?}, no file) stays
for pasted-text entries, which are stored doc-level (no index). Its filename follows the
filename rules above (400 otherwise) and the same per-project uniqueness (409 +
knowledge_name_conflict); its content_type is optional (null / "" = absent → text/plain),
and must be a valid-UTF-8 string of at most 128 characters (400 otherwise — a malformed value is
never read as absent). The extracted_text must be valid UTF-8 (utf8mb4) text of at most
7.5 MB with no NUL byte; a body that is oversize, not valid UTF-8, or contains a NUL byte (the
signature of binary content decoded as text — e.g. an image read client-side) is rejected with 400.
On the project routes an image/* content_type is rejected with 400 except image/svg+xml (SVG
is text) — images belong on the …/knowledge/upload route, not the pasted-text form. size_bytes is
derived server-side from the text; any client-supplied size_bytes is ignored. The same
extracted_text validation (UTF-8 / ≤ 7.5 MB / no NUL) applies to the upsert (PUT …/knowledge,
and its deprecated …/knowledge/<ENCODED_FILENAME> form) and the conversation
PUT …/conversations/<ID>/knowledge/<KID> write-back forms. The content_type
checks differ, though: the conversation write-back inherits content_type from the existing row
(the file was created by write_file) and only nullable-checks a supplied value — it does not apply
the image/* reject or a length cap there.
For an uploaded .docx the extractor accepts a valid OOXML zip containing word/document.xml and
rejects (→ failed, never crashing) a non-zip, a missing/oversized document.xml, or any XML that
declares a DTD/entity (an entity-expansion or external-entity attack is refused at the parser). Only
the document body and its tables are indexed; text in headers/footers, footnotes, and text boxes is
not (the whole document text is still stored and served). A .docx attached in a chat (rather
than a project) is still stored as flat text without the para index.
XML (.xml), JSON (.json), and HTML (.html/.htm) uploads are extracted asynchronously
(202 → pending → segmented), up to the 64 MB per-format cap above. XML is parsed with a
DTD-hardened SAX pass — any DOCTYPE, internal/external entity, or parameter-entity declaration is
refused (billion-laughs / XXE / SSRF-via-DTD are rejected, not expanded); a malformed or empty
document is marked failed, never crashing. JSON is validated and pretty-printed for retrieval;
NaN/Infinity, an overflowing exponent, a huge integer literal, deeply nested input, and non-UTF-8
bytes are all rejected. HTML has its script/style/noscript content stripped — including the
self-closing <script/>/<style/>/<noscript/> forms — so text hidden from a JS-enabled reader
(notably <noscript>) never reaches the searchable index; its visible text is line-segmented. (<head>
is not depth-suppressed — a <title> is human-visible in the browser tab, and suppressing an unclosed
<head> would blank a real page.) For any format, if the extracted text is very large the emitted result is bounded
so the worker never overflows its output pipe — the text is truncated (on a codepoint boundary) and
stored as a doc-level extracted entry with the truncation recorded on the ingest trace, exactly like
the PDF/Word over-7.5 MB degrade above. A file up to 64 MB therefore always ingests (its text
truncated to the indexed ceiling if needed); 64 MB + 1 byte is rejected with 413 at upload.
The upload endpoint returns two distinct coded 503s, told apart by a stable machine-readable code
in the JSON body ({"error": "…", "code": "…"}). A client must branch on code (the error prose is
informational and may change) — never on the message text. A third 503 carries no code: the
storage-fault answer {"error": "temporarily unavailable; retry later"}
(for example the project access check could not be read) — transient, retry the same upload; the web app
retries it like ingest_busy.
code |
Meaning | Nature | Retry-After |
|---|---|---|---|
ingest_busy |
The shared document-processing pool is momentarily saturated (this endpoint and POST /admin/v1/chat/files share one bounded slot budget). |
Transient — retry the same upload shortly. | 10 (seconds) |
ingest_unavailable |
Async ingestion is not provisioned on this deployment (no ingest pipeline configured). | Permanent / config — an operator must enable ingestion. | — |
knowledge_name_conflict (409) |
A knowledge file with this name (case-, accent- and trailing-space-insensitive) already exists in the project — see Name conflicts above. Also returned by the pasted-text form and the move endpoint. | Permanent for this name — delete the existing file or choose another name. | — |
Async ingestion (PDF + text + Office + XML/JSON/HTML + images) requires the deployment to be provisioned for it. When the
ingest pipeline is not configured the upload returns 503 with code: "ingest_unavailable" and a clear error
("Document ingestion is not currently available. Contact your administrator.") instead of accepting a document that could
never be processed — an upload never silently sticks in pending. When ingestion is provisioned but the shared upload
pool is momentarily at capacity, the upload instead returns 503 with code: "ingest_busy" and a Retry-After: 10
header — a transient state the caller resolves by retrying, not by contacting an administrator. An upload that ends without finishing (the client disconnects mid-transfer, or the transfer times out) returns its place in that pool as the request ends. A request that reaches the gateway without a Content-Length (a chunked body, or HTTP/2 without the header — the public hosts buffer the body and add the length) is refused with 411 code: "length_required" before it takes a place in the pool. A pending row that is never picked
up by a worker (for example after an outage) is automatically failed by the background reaper so it
surfaces as failed rather than processing indefinitely. A document whose text recognition (OCR) is temporarily unavailable is not left to wait for that reaper: it is retried on a short, growing schedule (about 1, 2, 4 and 7 minutes between attempts) and, if recognition is still unavailable on the fifth attempt, it ends as failed with failure_code: "attempts_exhausted" after about a quarter of an hour in total. A document that is lost to a crash or restart is still requeued by the reaper, which allows more attempts.
Semantic retrieval for large documents
When the assistant reads a large project document (one whose text exceeds the per-read size
limit and would otherwise be truncated to its opening pages), the gateway returns the passages most
relevant to the user's question — selected by semantic similarity from anywhere in the document —
instead of just the beginning. Each served passage keeps its [file | page | section] citation
anchor, so grounded citations still reference only pages the model actually received. This engages
only once a document has been semantically indexed in the background. Until then the document is
served from its beginning up to the per-read size limit and the remainder is not returned by a read
— a very large document is therefore only partly readable while its index is still being built.
Every document within the upload size limit is indexed in full: the index is built in the
background and switched on in one step, so a re-index never leaves a half-searchable document.
Only a document that would exceed 48,000 passages (not reachable within the upload limit) has its
first 48,000 passages indexed and is logged as partially indexed. A document that fits within the
limit is served in full as before. A scanned (OCR) page is still served
when relevant and is cited, carrying confidence: "ocr" (its page location is best-effort). The
user's question is used solely as a similarity query and never affects which documents are
authorized — the per-request x-aig-knowledge-ids selection and project scope are unchanged.
Verified excerpts in the sources panel
When the assistant supports a point with a verbatim quote from a cited page, the gateway checks deterministically that the quote actually appears on that page and, if so, attaches it to the source as a verified excerpt shown under the page in the sources panel. This is purely additive — the deterministic list of pages the assistant was given is never filtered or removed; a paraphrased or ungrounded quote simply gets no excerpt. "Verified" means the quote is genuinely present on the named page (open the document there to see it in context) — it is a traceability aid, not a guarantee that the surrounding claim is correct. A verified excerpt is real document text, so it is shown only to viewers authorized for that document; a shared-conversation reader without document access sees the page reference without the excerpt.
Saving a text file by name (upsert)
PUT /admin/v1/projects/<ID>/knowledge
Required role: owner or editor. Creates the doc-level text file named filename, or replaces the
text of the file that already has that name (one row per name — the per-project uniqueness above). This
is what the chat's Save to project and the artifact panel's write-back use. A file name is user
content — it can name a person — so it travels in the JSON body, never in the URL: the path holds
only the project id.
| Field | Type | Required | Description |
|---|---|---|---|
filename |
string | yes | The file's name; a leading path is its folder (src/utils.py is saved into folder src), exactly as the file upload stores it, and the / shapes the upload rejects (leading, trailing or double /, a . or .. segment) answer invalid_filename here too. The filename rules above apply. |
extracted_text |
string | yes | The text. Valid UTF-8, at most 7.5 MB, no NUL byte. |
content_type |
string | no | As on the pasted-text form (null / "" = absent → text/plain; at most 128 characters; image/* other than image/svg+xml rejected). |
200 answers the stored row (with its id, ACL-filtered like the list). Rejected with 400, after the
role check (a project member below the required role still gets its 403; a caller with no access to the project gets the audited 404) and before any storage call:
code |
When |
|---|---|
filename_required |
With Content-Type: application/json: no body (or only whitespace), an empty object, or "filename": "". |
invalid_filename |
filename is present but not an accepted name (see the filename rules). |
malformed_body |
The body is not a JSON object (42, null, an array), is not valid JSON, or is not valid UTF-8 anywhere (unlike the deprecated path form, which named the extracted_text field). |
pii_in_query |
filename also appears in the query string — a half-migrated client must notice instead of leaking the name. |
malformed_query |
More than 100 query parameters. |
unsupported_content_type |
The Content-Type is absent or not application/json (error: content type must be application/json). |
The older form with the name as the last path segment is deprecated — see Updating a knowledge entry by name in the path.
An id sent together with filename is refused with 400 invalid_target (it names a second target —
send one or the other; an id alone selects the by-id form).
This upsert follows the same naming rule as the chat's write_file: only the caller's own text
document of that name (one the caller can see and wrote) is rewritten in place. A name held by anything
else — a document the caller cannot see, a document another member wrote, an uploaded / synced document
(whose text comes from its stored original), a generated binary file — is never overwritten: the text is
saved as a new document under the next free name (report-2.md, report-3.md, …; the same name in
another case or with other accents is the same name). The 200 answer is the stored row — its id, its
version (for a later by-id save), its filename (the name
actually used) and renamed_from with the name you sent (absent when nothing was renamed).
Save further changes under the returned name or by its id. A name taken by someone else between the
check and the write is resolved again the same way. Only when the name and all its numbered variants are
taken does the call answer 409 knowledge_name_conflict.
Storage faults: a failed name lookup (nothing written) answers the retry
503 {"error":"temporarily unavailable; retry later"}; a failed write answers the sanitised 500
(with request_id; the database's own text is never in a body). When the write committed but the
re-read of the stored row fails, the answer is still 200 naming the stored row (id, filename,
version as the write reported it, and renamed_from when renamed), so a client never retries a write
that already landed and its next by-id save keeps its
version check.
A base_version on this by-name form is refused with 400 invalid_base_version rather than ignored
(an optimistic-concurrency check that silently did not happen would be worse than none) — use the
by-id form below.
Saving an existing file in place (by id)
PUT /admin/v1/projects/<ID>/knowledge with id instead of filename
Required role: owner or editor. Rewrites the text of the existing file id — the artifact panel's save of
a file it opened. The file must be one the caller can read (the same per-file visibility as
Getting a knowledge entry); an id the caller cannot read answers exactly like
an unknown one (404). Only a text file (source: "text") can be rewritten — an uploaded or synced file,
whose download serves its stored original, answers 409 not_editable (checked before the body is
validated). The rules are the same as for a conversation file
(Saving a conversation file in place) — one shared
save step. Unlike edit_file (which changes only files the caller wrote), an editor may save a file of
another member that they can read through a shared chat — the same rule as the by-name form.
| Field | Type | Required | Description |
|---|---|---|---|
id |
string | yes | The file's id (at most 64 characters, letters, digits and -); a malformed id → 400 invalid_id. Sending filename as well → 400 invalid_target. |
extracted_text |
string | yes | The new text (the rules of the by-name form). |
content_type |
string | no | Absent or null keeps the file's own; otherwise the by-name form's rule. |
base_version |
integer | no | The file version this edit was based on (from Getting a knowledge entry or the previous save). When present the write happens only while the file is still at that version. |
Optimistic concurrency. Every write of a file's text moves its version (a number that only grows —
it is the file's last-write time, moved at least one step per write). With base_version, a file that
changed meanwhile (for example the assistant edited it with edit_file while the panel was open) is not
overwritten: the answer is 409 { "code": "version_conflict", "current_version": <n> } and nothing is
written; saving again with base_version: <current_version> deliberately replaces that version. Without
base_version the write is unconditional (a client that does not opt in). A present base_version that
is not a positive integer — a string, a fraction, 0, a negative number, null, a boolean, an 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). The deprecated path form refuses id (400
invalid_target) and base_version (400 invalid_base_version) instead of ignoring them. A failed read of the
file before the write is 503 { "error": "temporarily unavailable; retry later" }; a failed write is the
sanitised 500 { "error": "internal error", "request_id": "…" } (it may have landed — re-read the file before
saving again).
Getting a knowledge entry
GET /admin/v1/projects/<ID>/knowledge/<KID>
GET /admin/v1/projects/<ID>/knowledge/<KID>/download
Required role: project member.
The JSON entry carries version (a number): the file's current version, which an
in-place save sends back as base_version.
The /download sub-path returns the entry's original bytes with a sanitized
Content-Disposition attachment filename (an ASCII filename="…" fallback plus filename*=UTF-8''…, RFC 6266; / and \ in the name become _, an invalid UTF-8 byte becomes U+FFFD, a leading dot is kept; 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 after cleaning or made only of dots and spaces, for example ., .., . . ., is replaced by the default name file, and so is a name longer than 255 bytes after cleaning). It serves any blob-backed entry — an
uploaded file (source: "upload") or a code-interpreter generated file
(source: "generated", e.g. an .xlsx workbook produced in a project chat). A
text-only entry that has no stored bytes (a pasted-text or write_file row) returns
404; a storage fault reading the entry or its bytes returns 503 { "error": "temporarily unavailable; retry later" }.
Inline preview — ?inline=1. Without the parameter the route is a download (the attachment
disposition above). ?inline=1 returns the same bytes for an in-page preview frame:
Content-Disposition: inline (same sanitized filename form), Content-Type: application/pdf and
X-Content-Type-Options: nosniff. It is granted only for bytes that are a PDF (the %PDF- header within
the first 1 KB, as PDF readers accept it), whatever content_type the entry carries; any other entry returns
415 { "error": "only a PDF can be previewed inline", "code": "inline_not_pdf" }, so a stored HTML or SVG
file is never rendered by the browser. The parameter is strict: any value other than 1 (0,
true, an empty or bare inline, or the parameter given twice) returns
400 { "error": "inline must be one of: 1", "code": "bad_param" }, never a silent download. The web
UI's project file preview reads this inline variant (a credentialed request: every /download response carries the same CORS headers as the route's JSON answers) and shows the bytes only after checking they are a PDF.
The knowledge entry includes, for paged documents:
| Field | Type | Description |
|---|---|---|
page_count |
integer | null | True total number of pages in the source document. null for non-paged formats. |
pages_extracted |
integer | null | Pages actually extracted into the stored text (capped at the extractor's page limit). null for non-paged formats. |
ingest_status |
string | Extraction lifecycle: extracted/segmented = ready; uploading/pending/extracting = still processing; failed = could not be extracted. |
failure_code |
string | Only present when ingest_status is failed and the cause is known. One of page_rejected (a page could not be read, for example a scan the text recognition could not process), time_limit (reading took longer than the time allowed for one file), no_text (no readable text found), password_protected, malformed (damaged or not in the format its name suggests), attempts_exhausted (processing failed repeatedly on the service side), upload_incomplete, worker_unavailable. Absent for every other status and when the cause is not one of these values; clients should treat an unknown value as an unspecified failure. |
failure_page |
integer | Only present together with failure_code: "page_rejected", when the page is known: the 1-based page number. |
failure_code and failure_page are returned by the knowledge list endpoint (GET .../knowledge), not by the single-item endpoint.
When pages_extracted < page_count the document was truncated at the page limit;
the later pages are not yet searchable or citable. Clients should surface this
(the web UI shows a "showing N of M pages" notice).
A document is only readable in chat once its ingest_status is extracted or
segmented. While it is still processing (uploading/pending/extracting) the
read_file tool returns a "still being processed" message instead of its content,
and the document is listed as not-yet-readable in the assistant's file list — so an
in-progress document is never answered over as if it were empty. An HTML or SVG file is read with its
large embedded fonts and images shown as aig-elided-… placeholders (payloads of 2,048 base64
characters or more), so a slide deck's slides fit the tool-result cap instead of its fonts; the view is
never written back — see
Embedded resources in HTML and SVG files.
Page-anchored retrieval
For a document that has a page/section index (ingest_status segmented or partial — PDF by
page, .txt/.md/.markdown/.csv/.yaml/.yml/.rst/.log by line, .docx by paragraph, .pptx by slide, .xlsx/.xlsm by sheet), the read_file tool returns the document
text annotated with anchors. Each boundary is marked inline with an anchor label of the form
[<filename> | <locator> | <section>], for example [report.pdf | p.12 | Introduction],
[notes.md | L.40–58 | Overview], or [memo.docx | ¶12 | Methods] (the section part is omitted when the extractor found no
heading/header). The full document text is always returned — the anchors are inserted between the
text, never in place of it, so no content is dropped. This gives the assistant an explicit,
line- or page-level reference it can cite when answering from your own documents. A document with no
index (a doc-level extracted row — a pasted-text entry, a document whose segmentation degraded, or
one whose oversize extracted text was truncated to the storage limit) is returned as-is, with no anchors.
Getting the ingest trace
GET /admin/v1/projects/<ID>/knowledge/<KID>/trace
Required role: project member (viewer or above). The <KID> must belong to <ID>;
a knowledge id from another project returns 404 (it is never resolved outside the
project you can access).
Returns the append-only timeline of a document's ingest lifecycle — one event per state transition — to diagnose a document that is stuck or degraded:
{
"knowledge_id": "abc123",
"events": [
{ "id": 1, "ts": 1751700000, "stage": "pending", "detail": null },
{ "id": 2, "ts": 1751700003, "stage": "extracting", "detail": "application/pdf" },
{ "id": 3, "ts": 1751700009, "stage": "segmented", "detail": "pdf-qwen-1" }
]
}
| Field | Type | Description |
|---|---|---|
id |
integer | Monotonic event id; events are returned oldest-first. |
ts |
integer | Unix timestamp (seconds) the event was recorded. |
stage |
string | Lifecycle stage: pending, extracting, segmented, partial, extracted, embedded, embedded_partial, embed_empty, deferred, failed. deferred means text recognition was temporarily unavailable and the document was scheduled for another attempt after a short wait; it stays in progress, and failed with failure_code: "attempts_exhausted" can follow once the retries are used up. Only embedded shows that all of the file's vectors are stored (the asynchronous embed step); embedded_partial means the first 48,000 passages are indexed and the rest of the document is not; segmented/extracted mean the text is readable, not yet semantically searchable. embed_empty is terminal: the text yields no indexable passage (for example a blank image), so it stays readable but is never semantically searchable; the backfill does not retry it, unlike an embed that failed (no terminal event, retried). It is normally written once per document by the embed timer and the selector-driven backfill (if both race, a duplicate event is harmless: the trace is diagnostic only); a targeted --kid backfill re-records it. |
detail |
string | null | Free-text context: the content type at claim, the extractor version at completion, or the failure reason. |
events is always a JSON array (empty [] for a document with no recorded events —
e.g. one attached before tracing existed). The trace is a diagnostic aid, not the
source of truth: the authoritative state is the entry's ingest_status field. A
missing or partial trace never implies a document failed.
Updating a knowledge entry by name in the path (deprecated)
PUT /admin/v1/projects/<ID>/knowledge/<ENCODED_FILENAME>
Required role: owner or editor.
Deprecated — use Saving a text file by name
(PUT …/knowledge with filename in the body), which also accepts a name with a folder. In the
path, a file name reaches the web server's access log, the request line it appends to every
error-log entry, and the admin audit trail's request path. Until the sunset this form keeps working.
Every answer the route itself gives carries Deprecation: @1791676800 and
Sunset: Mon, 11 Jan 2027 00:00:00 GMT, including its 400 (code: "invalid_filename") and 403;
a 401 or a size refusal that the web server sends before the route runs does not. These are
deliberately the same dates as the other personal-data carriers retired in this round (see
error codes). After the sunset
the route is removed (404).
<ENCODED_FILENAME> is the stored name, percent-encoded once by the client (it is decoded
once, by the web server — a name containing a literal % is sent as %25 and stored as %, and
a + is a literal plus, never a space); it is validated by the same filename rules as the upload
forms (400 for an over-long name, malformed UTF-8, a control character or a backslash such as
%5C). This form reaches top-level names only: a folder separator is decoded from %2F into a
real / before routing, so reports%2Fq1%2Fx.md matches no knowledge route (404) — a foldered
file is written through the upload form and re-filed with the move endpoint. Likewise a .. or
// in the URL is normalized by the web server before routing and a trailing / matches no
knowledge route, so those shapes never reach this handler (they answer 404, or whatever
unrelated route the normalized path lands on). The body follows the pasted-text form (extracted_text required,
optional content_type with the same rules). It follows the same naming rule as the body form above:
only the caller's own text document of that name is rewritten in place; a name held by anything else is
saved under the next free name, and 409 knowledge_name_conflict answers only when every numbered
variant is taken. Storage faults answer as on the body form: a failed name lookup is the retry 503, a
failed write the sanitised 500 { "error": "internal error", "request_id": "…" } (the database error is
logged, never returned), and a failed re-read after the committed write still a 200 naming the stored
row. A storage failure on DELETE …/knowledge/<KID> is the same sanitised 500.
Deleting a knowledge entry
DELETE /admin/v1/projects/<ID>/knowledge/<KID>
Required role: owner or editor.
Moving a knowledge entry into a folder
PATCH /admin/v1/projects/<ID>/knowledge/<KID>/move
Required role: owner or editor.
Knowledge attachments are organized into a folder hierarchy. A file's folder is
the leading path of its name — reports/2024/summary.pdf lives in folder
reports/2024 — so a folder exists exactly while at least one file references it
(there is no separate empty folder to create or delete). This endpoint changes a
file's folder while keeping its own name.
Request body:
| Field | Accepted shape |
|---|---|
folder |
A /-separated relative path, or "" / omitted for the top level. Segments are trimmed of surrounding spaces; leading, trailing and duplicated / are normalized away. |
The folder is sanitized at the trust boundary and the request is rejected with
400 when it contains:
- malformed UTF-8;
- a control character (bytes
0x00–0x1F,0x7F) or a backslash; - a
.or..path segment (no traversal); - a segment longer than 96 UTF-8 bytes, more than 12 nesting levels, or a total path longer than 200 bytes.
Responses:
200with the refreshed knowledge list on success (a no-op move — same target folder — also returns200).400when the folder is invalid (see above), or when the joinedfolder/namewould exceed 255 characters (counted in characters, not bytes). Only the width is checked here — the file's own name is the stored one and is not re-validated by a move.404when the knowledge id does not belong to this project.409withcode: "knowledge_name_conflict"when a file with the same name (per the collation rules under Name conflicts) already exists in the target folder.503 { "error": "temporarily unavailable; retry later" }when the knowledge entry cannot be read (or, for a no-op move, the list); the sanitised500 { "error": "internal error", "request_id": "…" }when the move itself fails, or when the list cannot be read back AFTER the move landed (re-read the list; the error is logged, never returned).
Setting corpus provenance metadata
PUT /admin/v1/projects/<ID>/metadata — set a project's provenance metadata.
Used to record where a project's content came from (product, source, commit). Requires
editor (or owner/admin) on the project. The stored values are not returned by any project read
endpoint; they are only used by Myra-internal tooling.
Request body — only these three optional string fields; at least one is required:
Validated at the trust boundary and fails closed: an unknown key, a non-string value, a non-object
body, or an empty body is rejected 400. The stored value is JSON-encoded and the write is tenant-scoped.
200 { "ok": true }on success.400 { "error": "<reason>" }on a bad body (unknown field / non-string value / empty).403 { "error": "forbidden" }for a project viewer (below editor);404 { "error": "not found" }for a caller with no access to the project (see a project you cannot see).- the sanitised
500 { "error": "internal error", "request_id": "…" }if the write fails.
Listing project conversations
GET /admin/v1/projects/<ID>/conversations
Returns only the calling user's own conversations in the project, not every member's (a privacy boundary). Required role: project member. Optional ?limit (default 50, capped at 200); anything but a plain integer ≥ 1 is 400 {"code": "invalid_limit"}. The total of this set, unpaged, is the project's conversation_count.
Listing the project feed
GET /admin/v1/projects/<ID>/feed
Returns the project's shared conversations, newest first (the rows where shared_in_project = 1). Despite the name it does not include knowledge or membership events. Required role: project member. Optional ?limit (default 20, capped at 100) and ?offset (default 0); anything but a plain integer (≥ 1 for limit, ≥ 0 for offset) is 400 {"code": "invalid_limit"} / {"code": "invalid_offset"}.
Content provenance
Each knowledge entry records whether its content came from the tenant or from outside. The marker is set by the server at ingest and cannot be set from a request: a provenance field in a request body is ignored.
- Tenant content: files and text added by a person, or by the tenant's own API token through the admin API (uploads, by-name saves, in-place saves from the artifact panel, organisation-library items).
- Outside content: everything that came in another way. Connector and crawler syncs, and every file an agent or tool writes (
write_file,edit_file, delivered and code-interpreter files). - Copies: a conversation fork carries each copied file's marker unchanged.
An update never lowers the marker. If an agent edits a file a person uploaded, the file becomes outside content from then on. A person editing an outside file leaves it outside; uploading the content as a new file creates a tenant entry.
This release only records the marker; it does not change what any read returns. Entries that existed before the marker was introduced are classified once, and only toward tenant when that is safe. A row counts as tenant content only if it has no connector source, is not flagged as generated, and has never been rewritten since it was created. Every other row counts as outside content, including every row whose text was rewritten at least once. Residuals of this classification:
- A file a person edited in place after upload is counted as outside content, because an earlier rewrite cannot be told apart from a rewrite by an agent.
- Rows created before row versions were tracked and rewritten since carry no trace of the rewrite; they are classified by the generated flag alone.
- Very old generated files that have no link to a conversation message are counted as tenant content, as the earlier generated-flag backfill (migration 0175) could not mark them either.
- Conversation forks made earlier carry the generated flag, so they stay outside content.
From this release on, a file whose content an agent tool (edit_file and similar) has replaced is marked as outside content, because the content is now model output. This does not change who can see the file.
Reading the combined knowledge text
GET /admin/v1/projects/<ID>/knowledge-text
Required role: project member (viewer or above). Connector-synced entries the caller cannot read at the source are left out. Returns a JSON array of per-entry objects — each { id, filename, token_count, extracted_text, ingest_status } — one per knowledge entry (not a single concatenated blob). Used by the chat UI for context injection.