Common Patterns
Create an orchestration, add entity agents with clear role descriptions, then use the streaming endpoint. The coordinator handles delegation. Keep entity role descriptions specific and non-overlapping so the coordinator can route cleanly.CRUD
POST /api/orchestrations
Create an orchestration.GET /api/orchestrations
List all orchestrations.GET /api/orchestrations/
Get orchestration with its entities.string
required
Orchestration ID
PUT /api/orchestrations/
Update orchestration config.string
required
Orchestration ID
DELETE /api/orchestrations/
Delete an orchestration.string
required
Orchestration ID
Entities
POST /api/orchestrations//entities
Add an agent as an entity.string
required
Orchestration ID
string
required
Use
"agent". The route accepts any string ≤50 chars, but the orchestrator’s execution path only invokes entities where entity_type === "agent"; other values are stored but silently skipped at run time.string
required
UUID of the agent to add.
string
Free-text role hint shown to the coordinator when delegating. Replaces the prior
role field used in older docs examples.object
Per-entity overrides; defaults to
{}.integer
Sort order in list responses; defaults to
0.The route returns 400 if either
entity_type or entity_ref_id is missing. List/PUT responses key off entity_ref_id and role_description, so any client trying to round-trip will see the same field names.GET /api/orchestrations//entities
List entities in the orchestration.string
required
Orchestration ID
PUT /api/orchestrations//entities/
Update an entity. Onlyrole_description, config, and position are writable; any other top-level keys are silently ignored. entity_type and entity_ref_id are not updatable; create a new entity instead.
string
required
Orchestration ID
string
required
Entity ID
string
Free-text role hint shown to the coordinator when delegating.
object
Per-entity overrides.
integer
Sort order in list responses.
DELETE /api/orchestrations//entities/
Remove an entity.string
required
Orchestration ID
string
required
Entity ID
Execution
POST /api/orchestrations//run/stream
Run orchestration with streaming SSE. Includes delegation events.string
required
Orchestration ID
GET /api/orchestrations/runs/
Get orchestration run result.string
required
Run ID
Hooks
These endpoints register hooks against an orchestration using the sameai.hooks model as agent hooks: event, type, config, matcher, enabled, and position.
POST /api/orchestrations//hooks
Add a hook.string
required
Orchestration ID
string
required
Lifecycle event name. Stored verbatim; not validated.
string
required
Hook handler type:
http, rule, or approval (see the agent hook contract).object
required
Handler-specific configuration (for
http, includes url).string
Optional filter narrowing when the hook fires.
boolean
Defaults to
true.integer
Execution order within the event. Defaults to
0.GET /api/orchestrations//hooks
List hooks for the orchestration, ordered byposition.
string
required
Orchestration ID
DELETE /api/orchestrations//hooks/
Remove a hook.string
required
Orchestration ID
string
required
Hook ID
Sessions
Session-level reads on orchestrations. The streaming/run/stream endpoint returns a session_id you can use here to fetch history.
GET /api/orchestrations//sessions
List the most recent 100 sessions for an orchestration. Each entry includessession_id, run_count, first_message, last_activity_at, and created_at.
string
required
Orchestration ID
GET /api/orchestrations//sessions//messages
Assembled messages for a session. Each assistant message carries per-run reasoning replay metadata (reasoning_requested, reasoning_duration_ms, reasoning, events) so a chat UI can re-render the original “Thought for X.Xs” pill on refresh. Tool calls are attached per-message via tool_calls. The legacy top-level events field is preserved for older clients.
string
required
Orchestration ID
string
required
Session ID
Error Responses
Orchestration routes return{"error": "<message>"} (no structured error code field).