Skip to content
Hoody.com

The headless agent endpoint drives a single, one-shot agent loop over an ephemeral, gateway-owned session. Submit a prompt (and optional target) and the gateway returns either an async job (default text/json form) or a Server-Sent Events stream (stream-json / stream:true). The endpoint is intended for automation, CI pipelines, and scripted workflows rather than interactive sessions.

Submits a prompt and (optionally) a workflow to the agent. The response shape depends on the output format:

  • text / json (default) — Async job. The endpoint returns 202 with a job_id; poll GET /jobs/{id} (and GET /jobs/{id}/result for the captured Result) for the outcome. A server-side failure surfaces as {status:"failed", error} in the result, not as an HTTP status on this call.
  • stream-json / stream:true — SSE stream. The endpoint returns 200 and streams start → result/error → end frames over text/event-stream.
NameInTypeRequiredDescription
X-Hoody-CwdheaderstringNoPer-request working-directory scope: the .hoody project layer / record cwd / tool+workflow cwd. Required by routes that resolve a 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 (realm_scope_unsupported) on active-only / no-realm routes.
realmquerystringNoPer-request realm selector — the in:query alias of the X-Hoody-Realm header (read only when the header is absent). Same semantics.
FieldTypeRequiredDescription
promptstringYesThe prompt to drive the ephemeral session.
workflowstringNoOptional workflow name to run instead of / 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).
await client.agent.headless.createHeadlessRun({
prompt: "Refactor src/auth/session.ts to use the new token store and report which tests broke.",
format: "json",
timeout_ms: 120000
});
Terminal window
curl -X POST "https://prj_abc123-cnt_xyz789-agent-1.us-east-1.containers.hoody.icu/api/v1/agent/headless/runs" \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Refactor src/auth/session.ts to use the new token store and report which tests broke.",
"format": "json",
"timeout_ms": 120000
}'

Returned when format: stream-json or stream: true. The body is a text/event-stream of the run.

event: start
data: {"run_id":"run_7f3a2b1c","model":"claude-sonnet-4.5"}
event: result
data: {"type":"text","text":"Refactored 3 files; 12 tests pass, 2 fail."}
event: end
data: {"ok":true}