The session object
The model the latest send picked, which the next turn runs on.
null until a send picks one: the session then runs on its pinned agent version’s model.The deployment that created this session, if any.
The persona this session acts as, or
null when the create call named none.The computer this session last worked on, or
null until something needed one. A session does not choose or own a computer: every session of an agent works on the agent’s computer (GET /v1/agents/{id}/computer) and sees the same files. Creating a session never waits for a machine; the first call that needs a shell or the filesystem takes the agent’s computer, starting or restoring it if needed, and computer_id names it from then on. A session whose turns are all words keeps null. Ending or cancelling a session destroys nothing — the next session of the agent finds the same files.Lifecycle state — see below.
Why the last turn yielded control — see below. Read it whenever the session is not
running; do not treat idle as success.Why the last turn failed: the error code of its last attempt, as its final
session.idle event carries it in code, or internal_error when the platform gave the session up. Set on an idle session whose turn ran out of retries (stop_reason: "error") and on a failed one. null once a later turn runs, and on every turn that did not fail, including one that ends idle with stop_reason: "error" because a required document was not produced. repeat_stopped on a turn that rests end_turn because the same step kept failing: it stopped rather than finished, and it is not a failure. When the turn’s model call failed, rate_limited means the model was busy, feature_not_configured means our model service refused the call (not your request; try again later), validation_failed means the model could not accept the request, and internal_error covers anything else. A code, never a message.Effective completion window for this session.
Per-session cap, in micro-USD. Always set: it falls back to the agent’s
budget.max_task_micro_usd.What the session is parked on. One array, two kinds of row, distinguished by
kind — which defaults to "tool", so a row without it is a held tool call.A kind: "tool" row is resolved with tool confirmations and accompanies stop_reason: "awaiting_approval". A kind: "question" row is resolved with answers and accompanies awaiting_answer. A session parked on both reports awaiting_approval and carries both.JSON Schema the final result must satisfy, inherited from the agent unless overridden at create.
The typed result, populated when the session goes idle satisfying
output_schema. See Structured outputs.The jobs still running at the session’s last rest: each render, clip, edit or skill build it started that has not finished, as
{ job_id, kind }. The same list as the last session.idle event’s background. An idle session with jobs here is still working; the job’s result wakes it. Empty otherwise.Highest event
seq emitted so far. See Events.Lifecycle
A session moves through thesestatus values:
Whenever a turn yields control,
stop_reason is set to one of:
idle is resumable and completed is terminal — both are non-running. Always branch on stop_reason rather than treating idle as success. A failed reply ends the turn, not the session: a turn that runs out of retries rests idle with stop_reason: "error" and stop_code set, and the next message runs a new turn in the same session. Anything worth keeping is written to Files; scratch work stays in the sandbox.Create a session
POST /v1/sessions → 201 Created. Creates and starts the session. Inherits the agent’s configuration; you may override the window, set a per-session budget, and provide an initial message.
Per-session cap in micro-USD, at most the agent’s
cap_micro_usd (validation_failed otherwise). Work pauses at the cap.Attribute this session to a deployment, so its spend shows under that schedule in the ledger. Defaults to
null.The persona this session acts as — an
idn_ id or the persona’s name. The agent must hold a grant to it. Defaults to null.JSON Schema the final result must satisfy. Overrides the agent default. See Structured outputs.
When
true, a session that cannot produce a conforming object goes idle with stop_reason: "error". Overrides the agent default; requires an output_schema on the session or the agent.Retrieve a session
GET /v1/sessions/{id} → 200 OK with the current status, stop_reason, and usage.
Response
List sessions
GET /v1/sessions → 200 OK, cursor-paginated. Filter with ?agent_id=, ?deployment_id=, and ?status=. See Pagination.
?handoff_from=ses_… lists the top-level sessions that root handed off — the room’s member work — newest first. A thread the root delegated to is not a handoff; those are GET /v1/sessions/{id}/threads. ?handoff_key=room:ses_… lists the top-level sessions handed off under that exact key — the room’s seated members, whoever seated them — newest first.
?agent_id=agt_…&first_chat_after=2026-11-21T09:00:00Z answers that agent’s first chat a person started at or after that time, oldest first, and nothing else: never a schedule’s run, a hand-off, a channel’s transcript or a board’s digest. data holds at most that one session, and the answer echoes first_chat_after. Without agent_id it answers 400 validation_failed.
List what waits on you
GET /v1/needs → 200 OK, cursor-paginated. Every session parked on a question (awaiting_answer) or an approval (awaiting_approval), from any live agent of the company, oldest first. A deleted agent’s sessions are left out: they wait on nobody.
Response
Hand off to other agents
POST /v1/sessions/{id}/handoffs → 200 OK. Scope sessions:write. The session {id} — top-level and not yet ended — hands message to one or more agents of your organization, each started as a top-level session of its own marked metadata.handoff: { from_session, from_agent, key, depth }. Who may be reached is the sender’s agent’s handoffs policy, exactly as it governs the model’s own send_to_agent; the receiver’s budget is capped at its agent’s per-task cap.
The task. The receiver sees it prefixed with the sending agent and session, so it can tell a handoff from a person.
De-duplicates per target: a target still working under this key answers
already_running with that session instead of starting another. Under a room’s key (room:<sender id>) the words are delivered into that session for you, and it takes no send of yours — it answers into the room; under any other key, send follow-ups to it yourself.Response
403 forbidden), has ended (409 session_terminal), or is not yours (404 not_found). A chain of handoffs is at most four deep.
Send input
POST /v1/sessions/{id}/messages → 202 Accepted. Sends input to a session and produces events. The reply is the acceptance, not a session snapshot: the turn has not run yet.
The message text to send. It must contain some text: an empty or whitespace-only message is
400 validation_failed naming message, and nothing is sent or billed. The same holds for the first message on create and a message on interrupt.When
true, steer a running session in one call: the model call the current turn has out is stopped at once and the new message is applied by the next turn. A stopped call is billed for what it used: its input plus the output streamed so far. This is the common case. Defaults to false.When
true, a send to a running session is accepted and held: the current turn finishes on its own and the message becomes the input of the turn that follows. On a session that is not running it is an ordinary send. Cannot be combined with interrupt. Defaults to false.A model id from
GET /v1/models. The session runs on it from this message’s turn on, and later turns keep it until another send picks again. The send is quoted on it, so an unknown id is 400 validation_failed and a model that does not serve the session’s completion window is 400 window_unavailable. The agent itself is not changed — update the agent too if new sessions should start on it.plan or build. plan runs the session read-only from this message’s turn on: it can research, ask and write a plan, and builds only after a person approves it. build leaves plan mode. A session whose harness cannot hold a call for approval refuses plan with 400 validation_failed naming mode. Only a person sets it: a send an agent makes through the control-plane tools is 403 forbidden naming mode. See Plan mode.Accepted and ignored. De-duplicate a retried send with the
Idempotency-Key header — see Idempotency; this body field does nothing.interrupt or queue, sending to a running session returns 409 with code session_running — interrupt first, set interrupt: true to steer it, or queue: true to wait for it.
A member’s session in a room — one handed off under the key room:<id> — answers into that room, so a send to it (and an interrupt that carries a message) returns 403 forbidden. Speak in the room instead; stopping it, approving its calls and answering its questions work as on any session.
Response
accepted_seq is the session’s event high-water mark at the moment the send was accepted: every event this turn produces has seq > accepted_seq. That is what to wait on — poll GET /v1/sessions/{id}/events?after_seq=143, or wait for the session’s last_seq to pass it. Do not wait on status alone: the send returns before the first event is committed, so a status read taken immediately after can still describe the previous turn.
A session started for a board card says when that card has moved on. A session the board (or a schedule) started for a card can still be messaged after the card is closed or another session has been started on it. The send goes through as usual and the session acts on it, but it no longer holds that card. The reply then adds a hint naming the card: that it is done, or which session holds it now, so you can send your guidance there or put it on the card. Any other send has no hint.
Response
metadata.room is its own agent’s id is a channel’s transcript. A send to it — and the first message when it is created — is recorded on its log as the person’s message (message.completed with role: "user", under the Idempotency-Key), and no turn follows. Nothing is quoted, interrupt and queue change nothing, and status stays as it was. To ask a member, hand off from it.
Interrupt a session
POST /v1/sessions/{id}/interrupt → 200 OK. Stops the current turn at once (the model call in flight is aborted and billed for its input plus the output streamed so far), preserving history and the sandbox, and returns the session idle with stop_reason: "interrupted". A live session that is not running (idle, or parked on an approval or a question) has no turn to stop: the interrupt changes nothing and answers the session as it was, its stop_reason (end_turn, a pending approval, …) intact. A session that has ended (completed, failed or cancelled) is refused with 409 session_terminal. An optional message is applied as the next input. Unlike cancel, the session stays resumable.
Response
Respond to a tool confirmation
When a tool withpermission: "ask" runs, the session goes idle with stop_reason: "awaiting_approval" and the blocking calls appear in pending_actions. Resolve each with:
POST /v1/sessions/{id}/tool_confirmations → 202 Accepted, carrying the full session object with the resolved call removed from pending_actions. Like a send, the reply is the acceptance: the tool has not run yet.
How far the
allow reaches. call — the default, and what an omitted scope means — approves this one call. session grants the call’s tool for the rest of this session: every later call to that tool name runs without a confirmation. company is “Always allow”: the call runs, and its tool runs without a confirmation in every chat of the company until the rule is removed (always_allowed on the organization). Only a signed-in owner or admin may send it. For a tool that takes an action (apps, browser), the rule covers that one action. It is refused for money, filings, messages to people, installs, the phone, a browser signup, any delete, and calls that grant access or change what an agent may do. allow only; session or company with deny is rejected with validation_failed (400) naming scope.A template install’s answers as the person edited them, keyed by question
key (a string, or a list for a multiple choice), at most four — a template asks at most four questions. allow only, and only for a call that applies a template: the install runs with these answers and every other argument as proposed. Answers the template’s questions refuse, a deny, scope: "session", or any other tool are rejected with validation_failed (400) naming answers or answers.<key>.On an
allow of a list_as_template call: the digest of the listing checks the card showed. It is filed with the approval, and the listing is refused if what it would list has changed since.On an
allow of a list_as_template call by a person who is not yet a creator and has no application in review: their application, { display_name, pitch, links }, in the shape POST /v1/creator/applications takes. The first listing is the application: it is filed with the listing, and the yes is refused validation_failed (param: "application") without it. See listing seller.allow of a parked propose_plan builds the plan at the version the call names. If the plan has
been written since — by the agent, or by you through PUT /plan — it is refused with
version_conflict (409) naming tool_call_id, and the call stays parked: read the plan, then deny
with a reason so the agent proposes the version that is there now.
A session grant is deliberately narrow. It covers one tool name, in one session, and it is
never implied — you ask for it per grant. It lives in that session’s transcript, so it disappears
when the session ends, is invisible to every other session, and is never written onto the agent. It
does not apply to a parked question, and an explicit deny for a particular call still stands even
while its tool is granted.
When the parked call is the platform’s tool invoker (tools_execute, which runs any catalogue tool
named in its tool argument), the grant is for that target tool: later tools_execute calls
with the same tool run without a confirmation, and a different tool through the same invoker is
confirmed as usual. The target is read from the parked call — the body carries nothing extra — and a
grant for the invoker with no target grants nothing.
Response
Operator actions
An agent may propose a wallet or card action it cannot run — open a persona’s wallet, change its limits, freeze or unfreeze it, add the testnet faucet’s test money, retry or refund a card — as a parkedoperator.request. An allow from a signed-in owner or admin runs it, once, before the
reply: the persona must be one the session’s agent acts as, or the agent must be the company’s CEO,
or the allow is refused with forbidden (403) and nothing runs. A refusal from the action itself is
the allow’s refusal, and the call stays parked. A repeated allow of the same call replays the first
answer. The agent reads what the action answered.
GET /v1/sessions/{id}/operator_preview?tool_call_id=… → 200, scope sessions:read: what an
approval card shows for one parked operator.request, read from the account — the persona by name,
current and new limits, a card’s label and what a refund returns — with runnable and, when it is
false, why.
Answer a question
An agent that needs something from a person parks the turn: the session goes idle withstop_reason: "awaiting_answer" and the question appears in pending_actions as a row with kind: "question", carrying a prompt and one to three fields. Answer it with:
POST /v1/sessions/{id}/answers → 202 Accepted, carrying the full session object with the answered question removed from pending_actions. Scope sessions:write.
One entry per field, keyed by
fields[].key. A string, or an array of strings for a choice field with multiple: true. Every field must be answered, except one the question marked optional: true — say “no answer” by leaving that key out of the object. A key that is present is validated either way, so "" and [] are validation_failed, not a way to skip.tool_confirmations, not a variant of it. A held tool call is answered with a verb and no payload; a question is answered with a payload and no verb. Posting an answer for a kind: "tool" row is rejected with validation_failed (400) naming tool_call_id, and points you at the other route.
A choice field accepts anything the person types unless it sets other: false, in which case only its listed options are accepted. The values are read back by the model as words, so send the option text and not an index.
Response
Read the plan
GET /v1/sessions/{id}/plan → 200 OK. Scope sessions:read. The session’s living plan: { "object": "plan", "markdown": "...", "version": 3, "by": "owner" }. version is 0 and markdown empty until one is written; by is agent, owner, or null at version 0.
Edit the plan
PUT /v1/sessions/{id}/plan → 200 OK, carrying the plan. Scope sessions:write. The owner’s edit, a compare-and-set.
The write wakes nothing: the agent reads the edit at its next turn.
Response
version_conflict (409) naming base_version when the plan moved on since you read it; read it again and edit from there. forbidden (403) on a member’s session in a room; session_terminal (409) on an ended session.
Raise the budget
PATCH /v1/sessions/{id}/budget → 200 OK. Scope sessions:write.
A session that hit its cap stops with stop_reason: "budget_paused". Raise the cap and it becomes resumable.
budget_micro_usd.
Errors — validation_failed (400) for a cap that is not a raise, is above the agent’s cap_micro_usd, or is null (a session always carries a cap); session_terminal (409) once the session has ended, with the cap unchanged; not_found (404). The organization’s balance is not checked here: a raise is never refused for credits.
Cancel a session
POST /v1/sessions/{id}/cancel → 200 OK. Terminally stops the session and moves it to cancelled. Any in-flight turn is stopped. Use interrupt instead if you want to keep the session resumable.
On the event stream a cancel ends like an interrupt: a session.usage with the session’s totals, then a session.idle with stop_reason: "interrupted", and the stream closes. No event is named for the cancel. To tell a cancel from an interrupt, read the session’s status, which is cancelled (terminal) after a cancel and idle (resumable) after an interrupt.
Cancel is idempotent. Cancelling a session that is already cancelled answers 200 with the session as it is. A session that ended completed or failed cannot be cancelled and answers 409 session_terminal.
There is no delete. Cancel is how you tidy up: it ends the session, stops its spend and lets go of the agent’s computer, which is kept (delete it under Computers to stop its storage). The session’s record, cost and events are kept for the life of the organization; no sweep removes them. Events are guaranteed replayable for at least 72 hours (see Events).
Response
Download a workspace
GET /v1/sessions/{id}/workspaces/{phase} → 200 OK with the archived working directory of a session’s sandbox, as it was at one boundary of its work: end (the session finished, or its idle sandbox was reclaimed), or card_start / card_end (it moved a board card to doing / done). start has none — a fresh sandbox’s disk is its base image. The body is a tar.gz; its sha-256 is in the x-workspace-sha256 header, and an unchanged workspace archives to the same hash. ?kind=diff returns the git diff HEAD of the repository in the workspace instead, when there was one. ?card_id=crd_… picks that card’s boundary; without it the newest one of the phase answers. Credential files (.env* and the platform’s own) and re-derivable caches such as node_modules are never archived.
Needs audit:read, like stored proxy calls: it is captured content. A boundary with nothing stored — or a session in another organization — is 404 not_found.
Stream events
List and stream a session’s events, resumable by
seq.