Skip to main content
POST

Behavior

With a free slot, the session starts pending and moves to running once the agent launches. Above your concurrency limit it is accepted as queued and starts when a slot frees up (set queue: false to get a 429 instead).

Headers

string
Optional idempotency key (1 to 255 characters). Safe retry within 24 hours: the same key returns the original session. Reusing it with a different body returns 422.

Request body

string | object
required
A catalog identifier (for example "h/web-surfer-flash") or an inline agent, which follows the same rules: environments is required (at most one per kind) and may be [] only with subagents or custom tools. The session reads environments, skills, and subagents from the agent.
A catalog ID runs the agent’s latest revision. Append :N to run a fixed one, for example "agent": "my-research-bot:3".
string | object | object[]
The initial task, queued before the agent’s first step: a plain string (one user message), one message object, or a list.
string
"user_message", the default.
string
required
The instruction or task.
string[]
Base64 data URIs to attach (for example data:image/png;base64,...).
object[]
Files to attach, up to 10 and 7 MB in total. Each is { name, source, type: "base64", media_type? } (media_type is guessed if omitted). Saved under files/ in a code sandbox workspace, and ~/Downloads on a cloud browser.
string
The sender. Defaults to user. Leave it unset for normal user input.
string | null
IANA timezone the agent uses for dates and times, for example "Europe/Paris". null or omitted means UTC. An unknown name returns 422. Child sessions a manager spawns inherit it.
integer
Cap on steps, where each step is one decide-and-act cycle. Minimum 1. At the cap the agent is asked for a final answer from what it has so far (it is not hard-killed). Omit to run uncapped.
number
Cap on wall-clock seconds per answer, greater than 0. Idle time between answers doesn’t count. At the cap, as with max_steps, the agent is asked for a final answer. If it is still running 60 seconds later, the session ends failed, not timed_out, with error_code timeout. Omit to run uncapped.
integer
Switches between one-shot and interactive. Leave it null for a one-shot task: the session ends when the agent answers. Set it (seconds, greater than 0) to keep the session open for follow-up messages: after each answer the session goes idle and waits this long for your next message. At your concurrency limit, a session idle for 120 seconds can end sooner to make room for your next one.
integer | null
Minutes after the session finishes before it is deleted, with its events and screenshots. Minimum 1. Omit it to keep the session for the retention period in your privacy settings. A value deletes it sooner. null adds no expiry beyond that period.
integer | null
Minutes after the session finishes before its screenshots are deleted, to expire visual data sooner than the session. Minimum 1. Omit it or pass null to keep screenshots as long as the session.
boolean
default:"true"
At your concurrency limit, accept the session as queued instead of rejecting it with 429. Queued sessions don’t count against your quota and start oldest first as running sessions finish. Set false to fail fast.
string
Tag for grouping related sessions. Filter on it with GET /sessions?group_id=....
string
Parent session ID, for subagent sessions. The parent’s status lists this session in subagent_session_ids. Child sessions never queue: at capacity the create fails with 429 even when queue is true, since a child queued behind its own parent would deadlock it.
object
Per-session tweaks applied after the agent (and its environments, skills, and subagents) are resolved, so you can adjust a catalog agent for one session. Each key is a path into the resolved request, and its value replaces what the path points to:
  • Dots walk into objects: agent.instructions, agent.model, agent.answer_format (structured answer).
  • [field=value] picks a list member: agent.environments[kind=web].start_url, agent.environments[kind=web].mode.
Each value must match the type of the field it targets: an unknown path or a wrong type returns 422 at creation, before the agent runs.

Response

201 with the created session object, status pending or queued.

More examples

With idempotency key

With an inline agent

Pass an inline agent instead of a catalog ID to set environments (or any other field) per session. Environments nest under agent.

Child session

A child session of a manager:

Errors