agent-sessions

10 endpoints.

GET/api/agent-sessions Bearer token
Scopeagent-sessions:read

List 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

NameInTypeRequiredDescription
include_archivedquerystringnoInclude archived rows. Defaults to false.

Responses

StatusDescriptionBody
200The caller's sessions.AgentSessionList
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:read` (`insufficient_scope`).object
404The AI agents feature is switched off on this deployment.ErrorResponse
500The sessions could not be read.ErrorResponse
POST/api/agent-sessions Bearer token
Scopeagent-sessions:write

Start 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.

Request body

application/jsonrequiredCreateAgentSessionRequest
FieldTypeRequiredDescription
titlestringyes

1–200 characters

model_idstringno

A model the caller's role limits allow; the deployment's default when left out.

at least 1 character

scopesarray of stringno

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

StatusDescriptionBody
201The new session.AgentSession
400The 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
401The access token is missing or invalid.ErrorResponse
403The 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
404The AI agents feature is switched off on this deployment.ErrorResponse
409The caller already has as many open sessions as their role limits allow.ErrorResponse
500The session could not be saved.ErrorResponse
GET/api/agent-sessions/allowance Bearer token
Scopeagent-sessions:read

Read 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

StatusDescriptionBody
200The caller's allowance.AgentAllowance
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:read` (`insufficient_scope`).object
404The AI agents feature is switched off on this deployment.ErrorResponse
500The allowance could not be read.ErrorResponse
GET/api/agent-sessions/{session_id} Bearer token
Scopeagent-sessions:read

Read 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Responses

StatusDescriptionBody
200The session and its messages.AgentSessionDetail
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:read` (`insufficient_scope`).object
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
500The session could not be read.ErrorResponse
PATCH/api/agent-sessions/{session_id} Bearer token
Scopeagent-sessions:write

Rename an agent session

Gives one of the caller's sessions a new title.

Parameters

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Request body

application/jsonrequiredRenameAgentSessionRequest
FieldTypeRequiredDescription
titlestringyes

1–200 characters

Responses

StatusDescriptionBody
200The renamed session.AgentSession
400The body failed validation.ErrorResponse
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:write` (`insufficient_scope`).object
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
500The session could not be saved.ErrorResponse
DELETE/api/agent-sessions/{session_id} Bearer token
Scopeagent-sessions:delete

Permanently 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Responses

StatusDescriptionBody
204The session is gone.—
401The access token is missing or invalid.ErrorResponse
403The caller is not a superuser. Also when the access token lacks `agent-sessions:delete` (`insufficient_scope`).ErrorResponse
404No session has that id, or AI agents are switched off.ErrorResponse
500The session could not be deleted.ErrorResponse
POST/api/agent-sessions/{session_id}/archive Bearer token
Scopeagent-sessions:archive

Archive 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Responses

StatusDescriptionBody
200The archived session.AgentSession
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:archive` (`insufficient_scope`).object
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
500The session could not be archived.ErrorResponse
POST/api/agent-sessions/{session_id}/restore Bearer token
Scopeagent-sessions:archive

Restore 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Responses

StatusDescriptionBody
200The restored session.AgentSession
401The access token is missing or invalid.ErrorResponse
403The access token lacks `agent-sessions:archive` (`insufficient_scope`).object
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
409The caller already has as many open sessions as their role limits allow.ErrorResponse
500The session could not be restored.ErrorResponse
POST/api/agent-sessions/{session_id}/attachment-uploads Bearer token
Scopeagent-sessions:write

Request 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Request body

application/jsonrequiredCreateAgentAttachmentUploadRequest
FieldTypeRequiredDescription
file_namestringyes

1–255 characters

content_typestringyes

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_bytesintegeryes

The file's exact size: at most 10 MB for an image, 20 MB for a PDF.

minimum 1 · maximum 20971520

Responses

StatusDescriptionBody
201Where to PUT the file, and the attachment id minted for it.AgentAttachmentUploadTicket
400The body failed validation, or the file is too large for its type.ErrorResponse
401The access token is missing or invalid.ErrorResponse
403The caller's roles do not allow AI agents. Also when the access token lacks `agent-sessions:write` (`insufficient_scope`).ErrorResponse
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
409The session is archived.ErrorResponse
500The upload URL could not be signed.ErrorResponse
503File storage is not configured on this deployment.ErrorResponse
POST/api/agent-sessions/{session_id}/turns Bearer token
Scopeagent-sessions:write

Send 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

NameInTypeRequiredDescription
session_idpathstring (uuid)yese.g. 8d3f2c3e-0c4b-4f8e-9a51-2d8c6f0b1a7e

Request body

application/jsonrequiredAgentTurnRequest
FieldTypeRequiredDescription
promptstringyes

What the person asks the agent.

1–20000 characters

attachmentsarray of AgentAttachmentInputno

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

StatusDescriptionBody
200The turn's events, streamed.—
400The 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
401The access token is missing or invalid.ErrorResponse
403The 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
404The caller has no session with that id, or AI agents are switched off.ErrorResponse
409The session is already taking a turn, or is archived.ErrorResponse
429The caller has used today's turns or tokens.ErrorResponse
500The turn could not be started.ErrorResponse
503The session's model is not configured on this deployment, or the message carries attachments and file storage is not configured.ErrorResponse