Skip to main content
POST
Create a session
Creates a new session that runs an agent against the given task. When a slot is available the session starts in pending status and transitions to running once the agent launches. A create above your concurrency limit is accepted as queued and starts automatically when a slot frees up (set queue: false to get a 429 instead). Returns the created Session object with status pending or queued.

Headers

Idempotency-Key
string
Optional idempotency key (max 255 characters). Safe retry within 24 hours: reusing the same key with a different body returns 422.

Request body

agent
string | object
required
Either a catalog identifier (string, e.g. "h/web-surfer-flash") or an inline Agent object. An inline agent must include its own environments (at most one per kind), unless it is a pure manager that only delegates to subagents; the session resolves only agent and reads everything else (environments, skills, subagents) from there.Using a catalog id (environments come from the agent’s stored spec):
Inline agent, with environments nested under it:
See Browser for its config and fields.
messages
string | object | array
Initial messages queued before the agent’s first step. Usually a single user message describing the task; a plain string is accepted as shorthand for one user message.Each message object has:
  • type (string, optional): "user_message", the default.
  • message (string): The instruction or task description.
  • images (array, optional): Base64 data URIs to attach (e.g. data:image/png;base64,...).
  • caller_id (string, optional): Identifies the message sender. Defaults to user; leave it unset for normal user input.
max_steps
integer
Cap on the number of steps the agent may take, where each step is one decide-and-act cycle. On reaching the cap the agent is asked to produce a final answer from what it has so far (it is not hard-killed), so you still get a structured result. Omit it to run uncapped.
max_time_s
number
Cap on wall-clock seconds. On reaching the cap, like max_steps, the agent is asked for a final answer rather than terminated abruptly. Omit it to run uncapped.
idle_timeout_s
integer
Switches between one-shot and interactive. Leave it null for a one-shot task: the session ends as soon as the agent answers. Set it (in seconds) to keep the session open for follow-up messages: after each answer the session enters the idle status and waits this long for your next message before terminating.
delete_after_min
integer
default:"43200"
Minutes after the session finishes before it is automatically deleted, along with its events and screenshots. Defaults to 30 days. Set null to keep the session forever.
delete_screenshot_after_min
integer
default:"43200"
Minutes after the session finishes before its screenshots are deleted, so you can expire visual data sooner than the session record. Defaults to 30 days. Set null to keep screenshots for the session’s lifetime.
queue
boolean
default:"true"
When you are at your concurrency limit, accept this session into a queue (status queued) instead of rejecting it with 429. Queued sessions don’t count against your quota and start automatically, oldest first, as running sessions finish. Ideal for batch workloads: fire N tasks, then collect results via webhooks. Set false to fail fast with 429 when at capacity.
group_id
string
Tag for grouping related sessions. You can later query all sessions with GET /sessions?group_id=....
parent_session_id
string
ID of a parent session, for multi-agent orchestration. The parent’s status endpoint will include this session in its subagent_session_ids list. Child sessions never queue: at capacity the create fails with 429 even when queue is true, because queueing a child behind its own parent’s slot would deadlock the parent.
overrides
object
Per-run tweaks applied after the agent (and its environments, skills, and subagents) are resolved, so you can adjust a catalog agent for a single run without editing its stored spec. Keys are dotted paths into the request; list members are addressed with an explicit [field=value] selector. Each value is validated against the field its path targets, so an unknown path or a wrong type is rejected with 422 at creation.Common uses: point the browser at a different start URL, or ask a catalog agent for structured output by overriding its answer_format.

Response

id
string
Unique session identifier.
request
object
The original session request body.
status
object
Session status object with status: "pending" for a newly created session, or "queued" when the create was accepted above your concurrency limit.
agent_view_url
string
Link to the session’s Agent View page for live viewing and replay.
created_at
string
ISO 8601 timestamp.

Examples

Basic session

Reference a catalog agent; its stored spec supplies the environments:
Response

With idempotency key

With an inline agent and explicit browser environment

Pass an inline Agent instead of a catalog id when you want to override the environments (or any other field) on a per-session basis. Environments must be nested under agent.

With per-run overrides

Reuse a catalog agent but tweak it for this run only: here we send it to a different start URL without editing its stored spec.

Child session (multi-agent)

See Multi-agent for the full picture.

Errors