agent-sessions
10 endpoints.
/api/agent-sessions Bearer tokenList my agent sessions
The caller's own sessions with an AI agent, most recently active first: the open ones, and with `include_archived=true` the archived ones too. Nobody else's are ever listed, superusers' included. Part of the AI agents feature.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| include_archived | query | string | no | Include archived rows. Defaults to false. |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The caller's sessions. | AgentSessionList |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:read` (`insufficient_scope`). | object |
| 404 | The AI agents feature is switched off on this deployment. | ErrorResponse |
| 500 | The sessions could not be read. | ErrorResponse |
/api/agent-sessions Bearer tokenStart an agent session
Starts an empty session on a model the caller's role limits allow — the deployment's default when none is named — granting its agent the `scopes` named, from those the role limits let agents use (the allowance's `allowed_scopes`; left out, all of them, now and later). Send it a message with `POST /api/agent-sessions/{session_id}/turns`. Needs a role limit that allows agents, and room under its limit on open sessions.
| Field | Type | Required | Description |
|---|---|---|---|
| title | string | yes | 1–200 characters |
| model_id | string | no | A model the caller's role limits allow; the deployment's default when left out. at least 1 character |
| scopes | array of string | no | The scopes to grant the session's agent, from the allowance's `allowed_scopes`; empty grants none, so the agent works in its sandbox alone. Left out, the session follows the role limits: every scope they allow, now and later. at most 100 items |
Responses
| Status | Description | Body |
|---|---|---|
| 201 | The new session. | AgentSession |
| 400 | The body failed validation, the model is not one the caller may use, or a scope is not one their role limits let agents use. | ErrorResponse |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The caller's roles do not allow AI agents, or the caller is sitting a quiz (`quiz_in_progress`). Also when the access token lacks `agent-sessions:write` (`insufficient_scope`). | ErrorResponse |
| 404 | The AI agents feature is switched off on this deployment. | ErrorResponse |
| 409 | The caller already has as many open sessions as their role limits allow. | ErrorResponse |
| 500 | The session could not be saved. | ErrorResponse |
/api/agent-sessions/allowance Bearer tokenRead my agent allowance
What the caller's role limits let them do with AI agents — the models, the daily turn and token allowances and how much of them is used, the session limit — and the scopes an agent's delegated token would be asked for with this token, with those it lacks and whether signing in again would bring them.
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The caller's allowance. | AgentAllowance |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:read` (`insufficient_scope`). | object |
| 404 | The AI agents feature is switched off on this deployment. | ErrorResponse |
| 500 | The allowance could not be read. | ErrorResponse |
/api/agent-sessions/{session_id} Bearer tokenRead an agent session
One of the caller's sessions with its transcript, oldest message first. The files attached to its messages and the images its agent showed come with presigned URLs good for an hour, minted for this read.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The session and its messages. | AgentSessionDetail |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:read` (`insufficient_scope`). | object |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 500 | The session could not be read. | ErrorResponse |
/api/agent-sessions/{session_id} Bearer tokenRename an agent session
Gives one of the caller's sessions a new title.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
| Field | Type | Required | Description |
|---|---|---|---|
| title | string | yes | 1–200 characters |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The renamed session. | AgentSession |
| 400 | The body failed validation. | ErrorResponse |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:write` (`insufficient_scope`). | object |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 500 | The session could not be saved. | ErrorResponse |
/api/agent-sessions/{session_id} Bearer tokenPermanently delete an agent session
Deletes a session — anyone's — with its transcript, the files attached to it and the images its agent showed, and destroys its sandbox. It cannot be undone; people archive their own sessions instead (`POST …/archive`). Superusers only, and the token must carry `agent-sessions:delete`, a scope separate from `agent-sessions:archive`. The turns the session took still count toward its owner's allowance for the day, and anything the agent changed in the learning records stays changed.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
Responses
| Status | Description | Body |
|---|---|---|
| 204 | The session is gone. | — |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The caller is not a superuser. Also when the access token lacks `agent-sessions:delete` (`insufficient_scope`). | ErrorResponse |
| 404 | No session has that id, or AI agents are switched off. | ErrorResponse |
| 500 | The session could not be deleted. | ErrorResponse |
/api/agent-sessions/{session_id}/archive Bearer tokenArchive an agent session
Puts one of the caller's sessions away: it keeps its transcript, leaves the session list (unless archived sessions are asked for), takes no new messages and no longer counts against the limit on open sessions. Its sandbox is stopped, keeping its files. Idempotent. The token must carry `agent-sessions:archive`.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The archived session. | AgentSession |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:archive` (`insufficient_scope`). | object |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 500 | The session could not be archived. | ErrorResponse |
/api/agent-sessions/{session_id}/restore Bearer tokenRestore an archived agent session
Brings one of the caller's archived sessions back: it is listed again and takes messages, its sandbox waking with the next one. Needs room under the caller's limit on open sessions. Idempotent. The token must carry `agent-sessions:archive`.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The restored session. | AgentSession |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The access token lacks `agent-sessions:archive` (`insufficient_scope`). | object |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 409 | The caller already has as many open sessions as their role limits allow. | ErrorResponse |
| 500 | The session could not be restored. | ErrorResponse |
/api/agent-sessions/{session_id}/attachment-uploads Bearer tokenRequest an upload URL for a file to give the agent
Issues a presigned URL to PUT one file — a PNG, JPEG, WebP or GIF image of at most 10 MB, or a PDF of at most 20 MB — straight to private file storage, before the message that carries it is sent. Pass the pathname back in that turn's `attachments` (`POST /api/agent-sessions/{session_id}/turns`): the agent then finds the file in its sandbox, and is shown it when it is an image. The pathname is good for this session alone.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
| Field | Type | Required | Description |
|---|---|---|---|
| file_name | string | yes | 1–255 characters |
| content_type | string | yes | The type the file will be PUT with: a PNG, JPEG, WebP or GIF image, or a PDF. one of "image/png" | "image/jpeg" | "image/webp" | "image/gif" | "application/pdf" |
| size_bytes | integer | yes | The file's exact size: at most 10 MB for an image, 20 MB for a PDF. minimum 1 · maximum 20971520 |
Responses
| Status | Description | Body |
|---|---|---|
| 201 | Where to PUT the file, and the attachment id minted for it. | AgentAttachmentUploadTicket |
| 400 | The body failed validation, or the file is too large for its type. | ErrorResponse |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The caller's roles do not allow AI agents. Also when the access token lacks `agent-sessions:write` (`insufficient_scope`). | ErrorResponse |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 409 | The session is archived. | ErrorResponse |
| 500 | The upload URL could not be signed. | ErrorResponse |
| 503 | File storage is not configured on this deployment. | ErrorResponse |
/api/agent-sessions/{session_id}/turns Bearer tokenSend a message to the agent
Sends the caller's message to the agent of one of their sessions and streams the agent's work back as it happens, one JSON event per line (`application/x-ndjson`): `start` with the reply's message id, `notice`s, `text-delta`s, `tool-call`s with their `tool-result` or `tool-error`, and a final `done` with the turn's status. The agent works in the session's sandbox and reaches the learning records through the MCP server with a token delegated from the caller's for this turn alone, reduced to the scopes the caller's role limits allow — never the caller's own token. Files named in `attachments` (uploaded first through `POST …/attachment-uploads`) are copied into the sandbox, a PDF with its text beside it, and the images are shown to the model. Stopping the request stops the turn. One turn at a time per session; each counts against the caller's daily allowance.
Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| session_id | path | string (uuid) | yes | e.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e |
| Field | Type | Required | Description |
|---|---|---|---|
| prompt | string | yes | What the person asks the agent. 1–20000 characters |
| attachments | array of AgentAttachmentInput | no | Files to give the agent with the message — images and PDFs, at most five — each uploaded first through `POST /api/agent-sessions/{session_id}/attachment-uploads`. The agent gets every one in its sandbox and is shown the images. A file can be attached once. at most 5 items |
Responses
| Status | Description | Body |
|---|---|---|
| 200 | The turn's events, streamed. | — |
| 400 | The body failed validation, or an attachment was not uploaded for this session, is already attached to a message, or is not the image or PDF it was declared as. | ErrorResponse |
| 401 | The access token is missing or invalid. | ErrorResponse |
| 403 | The caller's roles do not allow AI agents, or no longer allow the session's model, or the caller is sitting a quiz (`quiz_in_progress`). Also when the access token lacks `agent-sessions:write` (`insufficient_scope`). | ErrorResponse |
| 404 | The caller has no session with that id, or AI agents are switched off. | ErrorResponse |
| 409 | The session is already taking a turn, or is archived. | ErrorResponse |
| 429 | The caller has used today's turns or tokens. | ErrorResponse |
| 500 | The turn could not be started. | ErrorResponse |
| 503 | The session's model is not configured on this deployment, or the message carries attachments and file storage is not configured. | ErrorResponse |