Skip to main content
Start an agent run

Authorizations

Authorization
string
header
required

Authorization: Bearer stefan_sk_... (API key — bills the API wallet) or stefan_oat_... (OAuth member token — bills your plan pool).

Headers

Idempotency-Key
string

Safe blind retries: resubmitting the same key returns the ORIGINAL run's envelope (202 while it is running, the full status once it finished), with no second chat and no second billed run. A key first used for a different request is 409 idempotency_conflict; a start refused because the chat is busy (409 agent_run_rejected) does not use up its key for a retry in the same chat. Uploaded files are staged again on every call, so retry a request with files under a new key. Run keys are scoped to your account. Both API versions retain keys for 24 hours after acceptance and while the run remains active. UTC midnight does not reset the window. Once the window ends and the run finishes, reuse can start another billed run. Use a new key for new work. 1-128 chars of A-Z a-z 0-9 _ . : -; invalid values are 400 invalid_idempotency_key.

Pattern: ^[A-Za-z0-9_.:-]{1,128}$

Body

message
string
required
title
string

Optional title for a standalone new chat, 1-64 characters after trimming, without control characters. On MCP, pass chat: new without session. Shared default/session chats keep routing names. Developer session names are reserved; choose a different title. Existing chats keep their names.

Required string length: 1 - 64
Pattern: ^(?![\s\S]*[\u0000-\u001f\u007f-\u009f])
chat
string

A chat_... id to continue. Omit it to start the run in a new chat, with or without project.

project
string

A proj_... id or project UUID. Without chat, the run starts in a new chat inside that project.

sync
boolean

Hold the connection until the run ends or the sync window closes: about 90 s, counted from when the request arrives (upload time included). A run that ends inside the window returns 200 with its final status; failed and cancelled runs also return 200, so check status. Otherwise the normal 202 envelope; finish by polling. Keyed replays answer at once. Set the HTTP client timeout to 120 s: a dropped connection or 504 does not stop the run.

on_busy
enum<string>

Busy-chat behavior. Only explicit "reject" is supported: it returns 409 when the chat is busy. Without it, 2026-10-20 rejects and 2026-11-01 steers the active turn. Retry a refused input after completion, or use a separate chat.

Available options:
reject
output_config
object

Structured output constraint: { format: { type: "json_schema", schema } }. The schema must satisfy strict mode (additionalProperties: false everywhere; every property listed in required).

Response

The run's final status: a sync-mode run ({ sync: true }) that ended inside the sync window (about 90 s from when the request arrived, upload time included), or a keyed replay of a run that already ended. Failed and cancelled runs also return 200; check status.

object
string
run_id
string
chat
string
status
string
output
string | null

The latest assistant text, or null before there is any. It is the final answer only once status is completed.

structured_output
object | null

Parsed JSON of the final answer for runs started with output_config; null when not requested or not completed.

artifacts
object[]

Produced files with fresh ten-minute download grants. Match path to paths in the answer. Read the run again to renew links.

deliverables
object[]

Optional saved-file delivery, enabled per account. Text previews contain at most 16,000 characters per file and 48,000 total. Files over 1 MiB and binary files use download_url. Preview/unavailable entries name the retrieval fix; partial marks outputs of failed or cancelled runs.

turn_state
string | null
created_at
string<date-time> | null
started_at
string<date-time> | null
completed_at
string<date-time> | null
cancel_requested
boolean
last_error
string | null
error
object
project
string
user_message
string

Acceptance envelope only (msg_u_... id).

assistant_message
string

Acceptance envelope only (msg_a_... id).

status_url
string

Acceptance envelope only.

events_url
string

Acceptance envelope only.

cancel_url
string

Acceptance envelope only.

progress
object | null

The work the run has done, or null before it starts. A running run is working while last_activity_at keeps advancing; a long rewrite can run for an hour.

steered_into_run_id
string

This input steered the named active run. Its run_id addresses the same turn and result, not a separate billed turn.