Run agents via the API
Start an agent run and stream its events over Server-Sent Events.
An agent is a goal-directed reasoner that uses the tasks, skills, collections, and connections you’ve made available to it. Running one is different from running a task: an agent takes turns, calls tools, and can pause for approval, so its run streams back as Server-Sent Events rather than returning a single response body.
The response is a text/event-stream. All requests use bearer authentication — see Authentication.
Request body
You can also select a revision with the revision_id query parameter; otherwise the agent’s active revision is used.
Stream a run
Pass -N to curl so it does not buffer the stream.
The event stream
Each event is one SSE frame: a line beginning with data: followed by a JSON object, terminated by a blank line. The JSON always carries an event_type; the fields populated depend on the type.
A representative sequence:
A run ends in one of four statuses: running, waiting_for_human, completed, or failed.
Multi-turn sessions
The first session_id event and the final done event both carry the session ID. Pass it back as session_id on the next run to continue the same conversation with its full history intact.
Manage sessions directly:
Approval pauses
If a tool is configured to require approval, the run emits an approval_required event and its status becomes waiting_for_human. The stream ends without a done event; the run resumes once the request is approved, rejected, or resumed. See Approvals (HITL) for the approve/reject/resume endpoints and the full lifecycle.
Attach input files
Send files with a run the same two ways a task does.
Base64 in JSON
Multipart form data
Add a files array. Each entry has base64 content and a filename.
Retrieve a run after the fact
The stream is the live view. To read a completed run’s events or download files it produced, use the run endpoints — handy when a client disconnected mid-stream or you need the transcript later.