Skip to content

The Headless agent endpoint drives the full agent loop once over an ephemeral, gateway-owned session. It is a one-shot entry point that supports two output forms:

  • Async job (default, format: text | json) — the gateway returns 202 with a job_id; the run executes after the ack and the outcome is delivered through the Jobs API (GET /jobs/{id} and GET /jobs/{id}/result).
  • SSE stream (format: stream-json or stream: true) — the run is streamed over Server-Sent Events; the initial 200 ack is followed by start → result/error → end frames.

Create a headless one-shot agent run.

NameInTypeRequiredDescription
X-Hoody-CwdheaderstringNoPer-request working-directory scope (§6.1): the .hoody project layer / record cwd / tool+workflow cwd.
X-Hoody-Config-DirheaderstringNoPer-request --config-dir override (§6.1) selecting which on-disk .hoody install a stateless read/write resolves.
X-Hoody-ContainerheaderstringNoPer-request bound remote container (§6.1; omitted = local). Rejected (400) on routes with no container dimension.
X-Hoody-RealmheaderstringNoPer-request realm selector (§6.1): "global" or a 24-hex id. Rejected (400 realm_scope_unsupported) on routes without a realm dimension.
realmquerystringNoIn-query alias of the X-Hoody-Realm header (read only when the header is absent).
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).
{
"prompt": "Refactor src/api/handlers.ts to extract the validation logic into a separate module, and add unit tests for the new module.",
"model": "claude-sonnet-4",
"format": "json",
"timeout_ms": 120000
}

SSE stream of the headless run (format: stream-json / stream: true).

event: start
data: {"job_id": "run_01HZX7W8M3K5PBV6A2FQY9JT4C"}
event: result
data: {"status": "ok", "text": "Refactored 3 files; created src/api/validation.ts and tests/api/validation.test.ts."}
event: end
data: {}

This status has no error codes.

const { job_id } = await client.agent.headless.createHeadlessRun({
prompt: "Refactor src/api/handlers.ts to extract the validation logic into a separate module, and add unit tests for the new module.",
model: "claude-sonnet-4",
format: "json",
timeout_ms: 120000
});
// Poll for the captured result
const result = await client.jobs.getResult({ id: job_id });
// Streaming form — returns an SSE stream
const stream = await client.agent.headless.createHeadlessRun({
prompt: "Summarize the diff in src/api/handlers.ts.",
format: "stream-json"
});
for await (const event of stream) {
if (event.type === "result") console.log(event.data);
if (event.type === "error") throw new Error(event.data.message);
}