Skip to content
Hoody.com

Submit a one-shot prompt to the agent in an ephemeral, gateway-owned session and poll for the captured result. The default json/text form returns an async job that you poll through the gateway job endpoints; the stream-json form (or stream: true) returns the run live over SSE. Use this endpoint when you want the agent to drive the full loop once against a fresh session without maintaining interactive state.

POST /api/v1/agent/headless/runs

Drives the full agent loop once over an ephemeral, gateway-owned session. Set format: "stream-json" (or stream: true) to stream the run over SSE; otherwise the run is accepted as an async job and the gateway returns a job_id that you poll for the captured Result.

NameInTypeRequiredDescription
X-Hoody-CwdheaderstringNoPer-request working-directory scope: the .hoody project layer / record cwd / tool+workflow cwd. Required by routes that resolve a cwd (e.g. POST /todos; createTodo also accepts a body cwd).
X-Hoody-Config-DirheaderstringNoPer-request --config-dir override selecting which on-disk .hoody install a stateless read/write resolves (HoodyPaths).
X-Hoody-ContainerheaderstringNoPer-request bound remote container (omitted = local). Rejected (400) on routes with no container dimension.
X-Hoody-RealmheaderstringNoPer-request realm selector: "global" or a 24-hex id (also accepted as ?realm=). Rejected (400 realm_scope_unsupported) on active-only / no-realm routes.
realmquerystringNoPer-request realm selector — the query-string alias of the X-Hoody-Realm header (read only when the header is absent): "global" or a 24-hex id. Rejected (400 realm_scope_unsupported) on active-only / no-realm routes.
FieldTypeRequiredDescription
promptstringYesThe prompt to drive the ephemeral session.
workflowstringNoOptional workflow name to run instead of, or alongside, the prompt.
modelstringNoOptional model spec for the run.
formatstringNoOutput rendering: text | json | stream-json. stream-json (or stream: true) streams the run over SSE; otherwise the run is an async job.
streambooleanNoForce SSE streaming (equivalent to format: "stream-json").
timeout_msintegerNoOptional run timeout in milliseconds (clamped to the hard ceiling).

Example request:

{
"prompt": "Refactor the auth middleware to use dependency injection",
"workflow": "code-review",
"model": "claude-sonnet-4.5",
"format": "json",
"stream": false,
"timeout_ms": 120000
}

Returned when the request opts into streaming (format: "stream-json" or stream: true). The body is a Server-Sent Events stream with content type text/event-stream. Frames progress start -> result/error -> end; a server-side daemon failure is delivered as the error frame.

event: start
data: {"run_id":"run_01HXY8N4R7K2M9P3QD5VCE6T8B"}
event: result
data: {"status":"ok","output":"Refactor complete. Files updated: src/middleware/auth.ts"}
event: end
data: {}
Terminal window
curl -X POST "https://{projectId}-{containerId}-agent-1.{server}.containers.hoody.com/api/v1/agent/headless/runs?realm=global" \
-H "Authorization: Bearer $HOODY_TOKEN" \
-H "Content-Type: application/json" \
-H "X-Hoody-Cwd: /workspace/api" \
-d '{
"prompt": "Refactor the auth middleware to use dependency injection",
"workflow": "code-review",
"model": "claude-sonnet-4.5",
"format": "json",
"timeout_ms": 120000
}'