Skip to main content
Agent sessions are in early access, like the rest of API v2.
A session is a conversation with Argil’s agent, the same one people see in the Argil app. You send a brief, the agent works on its own, and it either finishes or asks a question. The same session is visible in the app, and every client sees every message.

Start a session

With the agent alone, send a first message; with an app, send its inputs.
GET /v2/apps/{id} gives an app’s inputs as a JSON Schema and its settings with their defaults. The server checks the inputs before anything starts: 400 parameter_invalid points at the input it refuses. An [App setup] block typed in your text is removed, so a brief cannot override an app’s settings. attachments take files (asset_…) and elements (elm_…) of your library. The session answers running. Follow it with the live events, a webhook, or GET /v2/sessions/{id}.

Status and stop reasons

A session is running or idle. When it goes idle, stop_reason says why: New stop reasons can appear: show a session with one you do not know as idle, with its messages and questions. POST /v2/sessions/{id}/stop stops the agent’s turn; the session goes idle with stopped. DELETE /v2/sessions/{id} removes an idle session, in the app too; a running one answers 409 session_busy, so stop it first.

Questions

When the agent needs something, it lists questions, each with its turn, a plain-text version (as_text) and a JSON Schema of its answer (answer_schema), so any client or LLM can answer one it does not render.
The answers build exactly the message a click in the app sends. A question left out of answers takes its default, as an untouched card does, and a new message closes the questions it leaves open. Answer the choices of one turn together, and one review at a time. A message is refused with 409 session_busy while the agent works, 409 question_closed when someone answered in the app first, and 409 artifact_changed when the storyboard moved past the revision you reviewed. The answer is 202 Accepted with the session, running.

Artifacts

Every artifact has the same header (title, summary, revision, images, url) and typed data: New kinds can appear: show one you do not know as a card with its url. Messages carry the artifacts of their turn, always in their latest state, and GET /v2/sessions/{id}/messages?starting_after=msg_… returns what came after a message you have.

Outputs

GET /v2/sessions/{id}/outputs lists what the agent published as results (the film, an image, a character), oldest first, each with published_at. A storyboard is working material, never an output.

Live events

GET /v2/sessions/{id}/events/stream sends server-sent events: a session.snapshot first, then session.status_changed, agent.activity (what the agent is doing, in one line), message.created, artifact.updated, generation.started / .succeeded / .failed (an image, a video or an audio the agent makes, intermediates included, with the generation itself), output.created and credits.updated. Every event has the same envelope: id, type, created_at, session, turn, data. Nothing replays: after a disconnection, reconnect, take the new snapshot, and read the messages you missed. A stream lasts at most an hour and sends a heartbeat every 20 seconds. Disconnecting never stops the agent.

Webhooks

Sessions started through the API or MCP send two webhook events: session.idle (the session, with its stop reason and questions) and output.created (the published artifact). They are for servers that must not miss the moment a session needs them.

Credits

Every session the API starts has a budget, max_credits. With an app, it must be within the app’s budget (GET /v2/apps) for the launch’s settings, and defaults to the recommended one; a budget outside it is refused with 400 parameter_invalid, which gives the bounds. Without an app, or for an app that recommends none, it defaults to Argil’s default budget, default_budget in GET /v2/apps. Paid steps start on their own while it holds; a step that would pass it does not start, and the session stops with budget_reached and one approval question. Answering it with approve: true raises the budget and resumes the work; PATCH /v2/sessions/{id} changes it at any time. A budget never goes below what the session spent. credits.spent is summed from the ledger, refunds deducted. A workspace without credits gets 402 insufficient_credits, and one without an active plan gets 403 plan_required on a launch or a message. Over MCP, an assistant cannot raise a budget: the answer is refused with 403 approval_required, and the question’s url is where the user raises it, signed in to Argil.

Limits

A workspace runs at most sessions at once: starting or resuming another is refused with 429 too_many_running_sessions. Starting a session and sending a message count against the session bucket, a minute.

Find a user’s sessions

A session says where it was started (origin: app, api or mcp) and carries your metadata. Its url opens it in the Argil app, for a member of the workspace. GET /v2/sessions?metadata[user]=u-42 lists the sessions of one of your users.