Attach a batch
Attach a visible batch as Extract chat context.
Authorizations
Organisation API key from Settings → API / /api/keys/. The secret is
shown once. Send Authorization: Bearer sk-abacus-…. One active key
per organisation. Ingest (/api/v2/ingest/*) refuses API keys — that
surface is Auth0-only with ingest:read / ingest:write scopes.
Path Parameters
Body
Body for POST /api/v2/chats/<thread_id>/batch-attachments/.
Fields:
batch_id: PK of the Batch to attach. The view validates that
the batch is visible to the request user via
:func:documents.views._visible_batch_qs (shared batches via
an approved org-library or active direct-share acceptance
count as visible).
context_mode: Render mode for BatchExtractionProvider.
Defaults to "full" (entire effective grid; batches over
the size limit still downshift to a summary). "summary"
renders schema + a small row sample + a pointer to the
query_batch_data SQL tool; "schema_only" renders
schema + pointer with no rows. All three modes are honored
at render time (AD-351 DuckDB batch analytics).
PK of the Batch to attach to this chat.
x >= 1Render mode for BatchExtractionProvider. 'full' (default) renders the entire grid into chat context (batches over the size limit still downshift to a summary); 'summary' renders schema + a small row sample + a query_batch_data SQL pointer; 'schema_only' renders schema + pointer with no rows.
full- fullsummary- summaryschema_only- schema_only
full, summary, schema_only Response
Response shape for chat <-> batch attachment endpoints.
Surfaces enough metadata for the SPA's "Attached batches" panel to
render without a follow-up /api/v2/batches/ lookup:
batch_name, batch_status, the attaching user's email, and
the render mode.
The model docstring on ChatBatchAttachment documents the unlink
semantics -- the join row CASCADE-deletes with chat or batch but
never deletes the chat/batch itself, so this serializer's view of
batch is always live.
Surface the attaching user's email or None if user was deleted.
attached_by is SET_NULL on user delete -- we keep the join
row alive even after the user is gone, so this returns None
when the attacher account no longer exists.
Render mode for BatchExtractionProvider. 'full' renders the entire grid (batches over the size limit still downshift to summary); 'summary' renders schema + a small sample + a query_batch_data SQL pointer; 'schema_only' renders schema + pointer with no rows.

