Agents, threads and runs

Master the Service execution API: pin agent revisions, submit idempotent inbox messages, batch human approvals on waiting runs, and steer active runs.

All execution endpoints live under /api/v1 and use a workspace API key (read to inspect, run to execute/steer/stop, write to edit agents). For a copy-paste shell script, start with Connect an application.

  • Agent revision: Immutable versioned configuration (ap_... + revision).
  • Session & Thread: A thread holds one conversation history; a session groups related threads (forks and async children).
  • Run: One accepted execution advancement over a thread's inbox.

Agents

Create an agent in Console (Agents → Create manually) or via POST /api/v1/agents using a saved model key from GET /api/v1/models:

JSON
{
  "name": "Support",
  "config": {"model": "your-model-key", "instructions": "Answer product questions precisely."}
}

Edits (POST /api/v1/agents/{agent_id}/revisions with {config, note?, make_default?} and If-Match) publish a new numbered revision; unpinned runs use the current default revision while active runs keep their captured revision. Validate drafts via POST /api/v1/agents/validate.

Start a conversation

Call POST /api/v1/threads with a unique Idempotency-Key header to create a thread (and session if session_id is omitted) alongside its first inbox entry. Save {thread.id, thread.session_id, entry.id} from the receipt and follow entry.assigned_run_id (read or stream results).

Search past conversations across /sessions, /threads, and /runs with ?text_query=....

Submit a message

Send follow-ups to POST /api/v1/threads/{thread_id}/inbox with agent_id, payload, optional delivery, and a fresh Idempotency-Key:

  • delivery: "steer" (default): Joins an active compatible run at the next model boundary (or starts a run if idle).
  • delivery: "next_run": Waits in the inbox to start a separate run after the current run finishes.

Manage queued pending entries with the thread's If-Match via PATCH / DELETE /api/v1/threads/{thread_id}/inbox/{entry_id} and PUT .../inbox/order. Pass one-run overrides or request caps via options:

JSON
{"options": {"max_usage": {"requests": 40}, "overrides": {"instructions": "Answer in German."}}}

See Advanced execution options for imported history, caller headers, and execution policy.

Attached files

Include 1–32 parts (text, uploaded workspace asset, HTTP(S) URL, or JSON):

JSON
{"content": [{"type": "text", "text": "Summarize this report."}, {"type": "asset", "asset_id": "ast_..."}]}

Service sends supported media natively when declared on the model, inlines text up to 64 KiB, or writes files to /workspace/.a13n/attachments/ when a workspace environment is mounted.

Waits, approvals and questions

When a run needs human approval (pending.approvals) or a client-tool / ask_user_question response (pending.calls), it seals as waiting.

Resume a waiting run

Submit both approvals and calls covering every pending ID to POST /api/v1/runs/{run_id}/resume with a fresh Idempotency-Key (and optional supplemental input). Service creates a new successor run while leaving the paused run sealed as waiting:

JSON
{
  "approvals": {"call_delete": {"action": "deny", "reason": "Keep the file"}},
  "calls": {
    "call_question": {
      "status": "returned",
      "value": {"answers": {"Which color?": "blue"}}
    }
  }
}

Approval actions are {"action": "approve"} or {"action": "deny", "reason": "..."}; call results are {"status": "returned", "value": ...} or {"status": "failed", "message": "..."}.

Interrupt, fork and archive

GoalEndpoint
Stop an active or queued runPOST /api/v1/runs/{run_id}/interrupt
Branch into a new thread from an ended runPOST /api/v1/runs/{run_id}/fork (fresh_environments optional)
Permanently close a threadPOST /api/v1/threads/{thread_id}/archive (If-Match required)

On this page