Endpoint reference¶
Generated from the API contract of this release. Every call needs Authorization: Bearer <token>; see the overview for errors and polling.
Chats and messages¶
GET /api/v1/threads¶
List Threads
The caller's chats, the one with the latest message first.
| Parameter | In | Description |
|---|---|---|
limit |
query | |
cursor |
query | |
q |
query | Only chats whose title contains this text. |
Responses:
200ThreadPage
Response fields:
| Field | Type | Description |
|---|---|---|
items (required) |
list of ThreadView |
|
next_cursor |
string |
Pass as cursor for the next page. Absent on the last page. |
curl $BASE/api/v1/threads -H "Authorization: Bearer $TOKEN"
POST /api/v1/threads¶
Create Thread
Start an empty chat of the caller's. Send messages to it with POST /threads/{thread_id}/messages.
Request body:
| Field | Type | Description |
|---|---|---|
title |
string |
Leave it out and the first message names the chat. |
Responses:
201ThreadView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
thread_id (required) |
string |
|
title (required) |
string |
Set by the user, or taken from the first message. Absent until there is one. |
updated_at (required) |
string |
When the last message was sent. |
curl -X POST $BASE/api/v1/threads -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
PATCH /api/v1/threads/{thread_id}¶
Rename Thread
Set the chat's title. It keeps its place in the list: renaming is not a message.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Request body:
| Field | Type | Description |
|---|---|---|
title (required) |
string |
Responses:
200ThreadView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
thread_id (required) |
string |
|
title (required) |
string |
Set by the user, or taken from the first message. Absent until there is one. |
updated_at (required) |
string |
When the last message was sent. |
curl -X PATCH $BASE/api/v1/threads/$THREAD_ID -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
DELETE /api/v1/threads/{thread_id}¶
Delete Thread
Delete the chat, its messages and the assistant's saved state of the conversation. A chat with a message being answered right now answers 409: wait for the answer (a run that waits for the user does not count: it is deleted). What the user has used stays counted. Passages the assistant retrieved are deleted with the chat, and so are the files attached to it, with what was read from them. If the call fails, repeat it.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Responses:
204
curl -X DELETE $BASE/api/v1/threads/$THREAD_ID -H "Authorization: Bearer $TOKEN"
GET /api/v1/threads/{thread_id}/messages¶
List Messages
The chat's messages, a question and its answer at a time, the latest ones first. Pages go backwards: without cursor you get the end of the chat, in reading order, and next_cursor leads to what came before. Every question has an answer entry: while the run is still going its status says so and it has no content yet.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
limit |
query | How many questions, each with its answer. |
cursor |
query |
Responses:
200MessagePage
Response fields:
| Field | Type | Description |
|---|---|---|
items (required) |
list of MessageView |
|
next_cursor |
string |
Pass as cursor for the messages before these. Absent at the start. |
curl $BASE/api/v1/threads/$THREAD_ID/messages -H "Authorization: Bearer $TOKEN"
POST /api/v1/threads/{thread_id}/messages¶
Post Message
Send a message. The assistant answers in the background: poll GET /runs/{run_id}. A chat takes one message at a time, so a second post answers 409 until the first is over. An optional Idempotency-Key header makes a retry return the same run. attachment_ids name the chat's files the assistant may read for this question; each must be the caller's and ready, else 404 or 409 attachment_not_ready (the body names the attachment_id). Attachments are not read unless named.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
idempotency-key |
header |
Request body:
| Field | Type | Description |
|---|---|---|
attachment_ids |
list of string |
Files attached to this chat that the assistant may read for this question. Each must be the caller's, in this chat and ready: an unknown id answers 404 and one that is not ready 409 attachment_not_ready, naming it. A question that lists none cannot read any file, whatever the chat holds. |
client_tools |
list of ClientTool |
The tools this page or app runs itself, such as changing a view, for this run. They are not part of the deployment's tools config: the assistant is offered what is listed here, and a run that lists none has none. A tool that writes asks the user to confirm unless it says otherwise. |
message (required) |
string |
Responses:
202RunStarted
Response fields:
| Field | Type | Description |
|---|---|---|
poll_after_ms |
integer |
|
run_id (required) |
string |
|
status (required) |
string |
|
thread_id (required) |
string |
curl -X POST $BASE/api/v1/threads/$THREAD_ID/messages -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
Runs¶
GET /api/v1/runs/{run_id}¶
Get Run
The run's status and, once completed, its answer and citations. Only the caller's own. While it is requires_action it carries what the user is asked: answer it with POST /runs/{run_id}/resume. Poll again after poll_after_ms.
| Parameter | In | Description |
|---|---|---|
run_id (required) |
path | The run's id. |
Responses:
200RunView
Response fields:
| Field | Type | Description |
|---|---|---|
answer |
string |
|
best_score |
number |
Diagnostic, not part of the stable contract: cosine similarity of the closest passage the knowledge search found, before the minimum score was applied. Null if the run did not search. Used by the eval to calibrate AIA_KNOWLEDGE_MIN_SCORE; may be removed once that is done. |
citations |
list of CitationView |
The passages the answer cites, numbered as in the text. |
error |
string |
|
poll_after_ms |
integer |
Poll again after this long. Absent once the run is over. |
required_action |
RequiredActionView |
Set while the status is requires_action. |
run_id (required) |
string |
|
status (required) |
string |
|
thread_id (required) |
string |
curl $BASE/api/v1/runs/$RUN_ID -H "Authorization: Bearer $TOKEN"
POST /api/v1/runs/{run_id}/resume¶
Resume Run
Answer the action the run waits for, and the run goes on. Poll it as before. Send approve for a confirm action, result or error for a client_tool one. Only the first answer to an action counts: a second one, or one for an action that has expired, answers 409.
| Parameter | In | Description |
|---|---|---|
run_id (required) |
path | The run's id. |
Request body:
| Field | Type | Description |
|---|---|---|
action_id (required) |
string |
The required_action.id being answered. |
approve |
boolean |
For confirm: true to run the tool, false to decline. |
error |
string |
For client_tool: why it could not run. |
result |
any |
For client_tool: what the tool returned, as JSON (null too). Its size is limited; send a summary of a large result. |
Responses:
202RunStarted
Response fields:
| Field | Type | Description |
|---|---|---|
poll_after_ms |
integer |
|
run_id (required) |
string |
|
status (required) |
string |
|
thread_id (required) |
string |
curl -X POST $BASE/api/v1/runs/$RUN_ID/resume -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
Chat attachments¶
GET /api/v1/threads/{thread_id}/attachments¶
List Attachments
The files attached to this chat, oldest first, with where each is in indexing.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Responses:
200AttachmentList
Response fields:
| Field | Type | Description |
|---|---|---|
items (required) |
list of AttachmentView |
curl $BASE/api/v1/threads/$THREAD_ID/attachments -H "Authorization: Bearer $TOKEN"
POST /api/v1/threads/{thread_id}/attachments¶
Start Attachment
Record a file for this chat and return a URL to PUT it to. Any user may attach files to their own chats. Supported files: PDF, DOCX, Markdown and plain text. After the PUT, call POST /threads/{id}/attachments/{attachment_id}/complete to have the file read. The URL accepts a file of exactly size_bytes and no other length. The file belongs to the user and to this chat alone: other users, other chats and the company's document search never see it. An upload that is not completed is deleted after a while, and until then it counts toward the chat's limit (409 attachment_limit_reached). Declaring only ever adds a file: it never changes or deletes another one, so two tabs declaring the same name get two files. Delete a failed file with DELETE /threads/{id}/attachments/{attachment_id}. The upload must send a Content-Length (no chunked transfer), and its Content-Type is not checked: the file is read by its name.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Request body:
| Field | Type | Description |
|---|---|---|
filename (required) |
string |
The file's name, with its extension. |
size_bytes (required) |
integer |
The file's size in bytes. |
Responses:
201AttachmentTarget
Response fields:
| Field | Type | Description |
|---|---|---|
attachment_id (required) |
string |
|
expires_in_seconds (required) |
integer |
|
upload_method |
string |
|
upload_url (required) |
string |
curl -X POST $BASE/api/v1/threads/$THREAD_ID/attachments -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
GET /api/v1/threads/{thread_id}/attachments/{attachment_id}¶
Get Attachment
The attachment and its indexing status.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
attachment_id (required) |
path |
Responses:
200AttachmentView
Response fields:
| Field | Type | Description |
|---|---|---|
attachment_id (required) |
string |
|
content_type (required) |
string |
|
created_at (required) |
string |
|
error |
string |
Why indexing failed, when it did. |
filename (required) |
string |
|
size_bytes (required) |
integer |
|
status (required) |
string |
awaiting_upload, queued, processing, ready (the assistant can read it) or failed. A message is refused while an attachment is queued or processing. |
thread_id (required) |
string |
|
updated_at (required) |
string |
curl $BASE/api/v1/threads/$THREAD_ID/attachments/$ATTACHMENT_ID -H "Authorization: Bearer $TOKEN"
DELETE /api/v1/threads/{thread_id}/attachments/{attachment_id}¶
Delete Attachment
Delete the file, the passages indexed from it and the record. What it does not delete: what the assistant already read from the file stays in the chat. A short file is read whole, so its text sits in the chat's saved state until the chat is deleted, answers keep the excerpts they cited, and a tenant that turned on trace content has up to 4000 characters of each read in its traces. The assistant can still use that text in this chat. Delete the chat to remove it all (traces expire as the operator sets). If the call fails, repeat it until it answers 204 or 404: the record goes last, so a half-done delete can always be finished.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
attachment_id (required) |
path |
Responses:
204
curl -X DELETE $BASE/api/v1/threads/$THREAD_ID/attachments/$ATTACHMENT_ID -H "Authorization: Bearer $TOKEN"
POST /api/v1/threads/{thread_id}/attachments/{attachment_id}/complete¶
Complete Attachment
Check the file arrived and queue it for reading. Poll GET /threads/{id}/attachments/{attachment_id} until its status is ready or failed. Calling this again for a file that is already queued is harmless; one already being read, ready or failed answers 200 with where it is. A file over the size limit answers 413 and the attachment is deleted.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
attachment_id (required) |
path |
Responses:
202AttachmentView
Response fields:
| Field | Type | Description |
|---|---|---|
attachment_id (required) |
string |
|
content_type (required) |
string |
|
created_at (required) |
string |
|
error |
string |
Why indexing failed, when it did. |
filename (required) |
string |
|
size_bytes (required) |
integer |
|
status (required) |
string |
awaiting_upload, queued, processing, ready (the assistant can read it) or failed. A message is refused while an attachment is queued or processing. |
thread_id (required) |
string |
|
updated_at (required) |
string |
curl -X POST $BASE/api/v1/threads/$THREAD_ID/attachments/$ATTACHMENT_ID/complete -H "Authorization: Bearer $TOKEN"
Feedback¶
GET /api/v1/threads/{thread_id}/feedback¶
Get Feedback
The caller's rating of the chat. 404 if the chat is not theirs or is not rated.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Responses:
200FeedbackView
Response fields:
| Field | Type | Description |
|---|---|---|
comment (required) |
string |
The user's own words. |
created_at (required) |
string |
When the user first rated the chat. |
rating (required) |
string |
|
reason (required) |
string |
Why, when the user said: a fixed list, so ratings can be counted by reason. |
thread_id (required) |
string |
|
updated_at (required) |
string |
When the rating last changed. |
curl $BASE/api/v1/threads/$THREAD_ID/feedback -H "Authorization: Bearer $TOKEN"
PUT /api/v1/threads/{thread_id}/feedback¶
Put Feedback
Rate the chat: bad, fine or awesome, and optionally why and in the user's own words. A chat has one rating per user, so rating again replaces the earlier one whole: a field left out is cleared. Only the chat's owner can rate it. The rating is shown in Langfuse as scores on the trace of the answer the chat was first rated on (the reason as a category), with the comment only if the tenant traces content.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Request body:
| Field | Type | Description |
|---|---|---|
comment |
string |
The user's own words. |
rating (required) |
string |
|
reason |
string |
Why, from a fixed list. |
Responses:
200FeedbackView
Response fields:
| Field | Type | Description |
|---|---|---|
comment (required) |
string |
The user's own words. |
created_at (required) |
string |
When the user first rated the chat. |
rating (required) |
string |
|
reason (required) |
string |
Why, when the user said: a fixed list, so ratings can be counted by reason. |
thread_id (required) |
string |
|
updated_at (required) |
string |
When the rating last changed. |
curl -X PUT $BASE/api/v1/threads/$THREAD_ID/feedback -H "Authorization: Bearer $TOKEN" -H 'content-type: application/json' -d '{...}'
DELETE /api/v1/threads/{thread_id}/feedback¶
Delete Feedback
Remove the caller's rating of the chat, and its scores in Langfuse. Repeatable: a chat without a rating is not an error.
| Parameter | In | Description |
|---|---|---|
thread_id (required) |
path | The thread's id. |
Responses:
204
curl -X DELETE $BASE/api/v1/threads/$THREAD_ID/feedback -H "Authorization: Bearer $TOKEN"
Knowledge documents¶
GET /api/v1/documents¶
List Documents
The tenant's documents, newest first, whatever their role tags (for admins).
| Parameter | In | Description |
|---|---|---|
limit |
query | |
cursor |
query |
Responses:
200DocumentPage
Response fields:
| Field | Type | Description |
|---|---|---|
items (required) |
list of DocumentView |
|
next_cursor |
string |
Pass as cursor for the next page. Absent on the last page. |
curl $BASE/api/v1/documents -H "Authorization: Bearer $TOKEN"
GET /api/v1/documents/{document_id}¶
Get Document
The document and its ingestion status.
| Parameter | In | Description |
|---|---|---|
document_id (required) |
path |
Responses:
200DocumentView
Response fields:
| Field | Type | Description |
|---|---|---|
chunk_count |
integer |
Passages indexed, once ready. |
content_type (required) |
string |
|
created_at (required) |
string |
|
document_id (required) |
string |
|
error |
string |
Why ingestion failed, when it did. |
filename (required) |
string |
|
role_tags (required) |
list of string |
Users holding any of these roles may read the document. Empty: every user. |
size_bytes (required) |
integer |
|
status (required) |
string |
awaiting_upload, queued, processing, ready (searchable) or failed. |
updated_at (required) |
string |
curl $BASE/api/v1/documents/$DOCUMENT_ID -H "Authorization: Bearer $TOKEN"
Privacy requests¶
GET /api/v1/privacy/jobs¶
List Privacy Jobs
The tenant's jobs, newest first, so a receipt can be found again without its id. Filter by kind (erase, export) and status. A full page carries next_cursor: pass it as cursor for the next one. Download links are only on GET /privacy/jobs/{id}.
| Parameter | In | Description |
|---|---|---|
kind |
query | |
status |
query | |
limit |
query | |
cursor |
query |
Responses:
200PrivacyJobPage
Response fields:
| Field | Type | Description |
|---|---|---|
items (required) |
list of PrivacyJobView |
|
next_cursor |
string |
Pass as cursor for the next page. None on the last. |
curl $BASE/api/v1/privacy/jobs -H "Authorization: Bearer $TOKEN"
GET /api/v1/privacy/jobs/{job_id}¶
Get Privacy Job
The job's status. Poll until succeeded or failed; a failed job is repeated. A finished export carries a download_url for the zip, valid for a few minutes: ask again for a fresh one. An erase receipt counts what was removed per store, never the data.
| Parameter | In | Description |
|---|---|---|
job_id (required) |
path |
Responses:
200PrivacyJobView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
download_url |
string |
A finished export: a link to the zip, valid for a few minutes. |
error |
string |
Why it failed. Repeat the request. |
id (required) |
string |
|
kind (required) |
string |
|
mode (required) |
string |
Erase jobs: delete removes usage rows, anonymize keeps them, userless. |
receipt |
object |
When it succeeded: removed (rows and files by store), finished_at, and for an export files and omitted. Counts only: it never holds the data. |
requested_by (required) |
string |
The admin's user id, or erased-... if they were erased since. |
scope (required) |
string |
|
status (required) |
string |
|
updated_at (required) |
string |
curl $BASE/api/v1/privacy/jobs/$JOB_ID -H "Authorization: Bearer $TOKEN"
DELETE /api/v1/tenant/data¶
Erase Tenant Data
Erase everything of the admin's tenant: every user's data, the knowledge base, settings. Admin only. confirm_tenant_id must equal the tenant id the token belongs to. Starts a background job and answers 202; see DELETE /users/{user_id}/data for how it ends. Only the bare tenant id and the job records stay.
| Parameter | In | Description |
|---|---|---|
confirm_tenant_id (required) |
query | Your own tenant id, repeated, to confirm. |
mode |
query | delete removes everything, usage rows included. anonymize removes the same chats, messages and files and only keeps the token usage rows, with the user replaced by a random id, so billing totals stay. It keeps no content. |
Responses:
202PrivacyJobView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
download_url |
string |
A finished export: a link to the zip, valid for a few minutes. |
error |
string |
Why it failed. Repeat the request. |
id (required) |
string |
|
kind (required) |
string |
|
mode (required) |
string |
Erase jobs: delete removes usage rows, anonymize keeps them, userless. |
receipt |
object |
When it succeeded: removed (rows and files by store), finished_at, and for an export files and omitted. Counts only: it never holds the data. |
requested_by (required) |
string |
The admin's user id, or erased-... if they were erased since. |
scope (required) |
string |
|
status (required) |
string |
|
updated_at (required) |
string |
curl -X DELETE $BASE/api/v1/tenant/data -H "Authorization: Bearer $TOKEN"
POST /api/v1/tenant/export¶
Export Tenant Data
Export everything of the admin's tenant: every user's data, documents, settings. Admin only. Starts a background job and answers 202; see POST /users/{user_id}/export.
Responses:
202PrivacyJobView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
download_url |
string |
A finished export: a link to the zip, valid for a few minutes. |
error |
string |
Why it failed. Repeat the request. |
id (required) |
string |
|
kind (required) |
string |
|
mode (required) |
string |
Erase jobs: delete removes usage rows, anonymize keeps them, userless. |
receipt |
object |
When it succeeded: removed (rows and files by store), finished_at, and for an export files and omitted. Counts only: it never holds the data. |
requested_by (required) |
string |
The admin's user id, or erased-... if they were erased since. |
scope (required) |
string |
|
status (required) |
string |
|
updated_at (required) |
string |
curl -X POST $BASE/api/v1/tenant/export -H "Authorization: Bearer $TOKEN"
DELETE /api/v1/users/{user_id}/data¶
Erase User Data
Erase a user's chats, attachments and their passages, saved state, usage rows and traces. Admin only, within the admin's tenant. Starts a background job and answers 202: poll GET /privacy/jobs/{id} for the receipt, which counts what was removed per store and never holds the data. The user's uploads to the knowledge base stay, credited to a random id. Block the user in the identity endpoint first: a run of theirs that is still going makes the job fail until it ends (repeat the request then). Repeating is always safe.
| Parameter | In | Description |
|---|---|---|
user_id (required) |
path | The user id the host app's identity endpoint reports. Slashes are fine. |
mode |
query | delete removes everything, usage rows included. anonymize removes the same chats, messages and files and only keeps the token usage rows, with the user replaced by a random id, so billing totals stay. It keeps no content. |
Responses:
202PrivacyJobView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
download_url |
string |
A finished export: a link to the zip, valid for a few minutes. |
error |
string |
Why it failed. Repeat the request. |
id (required) |
string |
|
kind (required) |
string |
|
mode (required) |
string |
Erase jobs: delete removes usage rows, anonymize keeps them, userless. |
receipt |
object |
When it succeeded: removed (rows and files by store), finished_at, and for an export files and omitted. Counts only: it never holds the data. |
requested_by (required) |
string |
The admin's user id, or erased-... if they were erased since. |
scope (required) |
string |
|
status (required) |
string |
|
updated_at (required) |
string |
curl -X DELETE $BASE/api/v1/users/$USER_ID/data -H "Authorization: Bearer $TOKEN"
POST /api/v1/users/{user_id}/export¶
Export User Data
Export everything kept about a user: chats, messages, usage and their files. Admin only, within the admin's tenant. Starts a background job and answers 202: poll GET /privacy/jobs/{id} until it succeeds, then download the zip from download_url. The file is deleted after a few days, and with the user's data if they are erased.
| Parameter | In | Description |
|---|---|---|
user_id (required) |
path | The user id the host app's identity endpoint reports. Slashes are fine. |
Responses:
202PrivacyJobView
Response fields:
| Field | Type | Description |
|---|---|---|
created_at (required) |
string |
|
download_url |
string |
A finished export: a link to the zip, valid for a few minutes. |
error |
string |
Why it failed. Repeat the request. |
id (required) |
string |
|
kind (required) |
string |
|
mode (required) |
string |
Erase jobs: delete removes usage rows, anonymize keeps them, userless. |
receipt |
object |
When it succeeded: removed (rows and files by store), finished_at, and for an export files and omitted. Counts only: it never holds the data. |
requested_by (required) |
string |
The admin's user id, or erased-... if they were erased since. |
scope (required) |
string |
|
status (required) |
string |
|
updated_at (required) |
string |
curl -X POST $BASE/api/v1/users/$USER_ID/export -H "Authorization: Bearer $TOKEN"
Access¶
GET /api/v1/me¶
Me
Who the token belongs to, as the identity endpoint reported it.
Responses:
200Me
Response fields:
| Field | Type | Description |
|---|---|---|
display_name (required) |
string |
|
metadata (required) |
object |
|
roles (required) |
list of string |
|
tenant_id (required) |
string |
|
user_id (required) |
string |
curl $BASE/api/v1/me -H "Authorization: Bearer $TOKEN"
Health¶
GET /api/v1/health¶
Health
Report that the service is up.
Responses:
200Health
Response fields:
| Field | Type | Description |
|---|---|---|
service (required) |
string |
|
status |
string |
|
version (required) |
string |
curl $BASE/api/v1/health -H "Authorization: Bearer $TOKEN"