World · Execution
8 operations tagged world.execution.
world_consult_sync
POST /api/v1/world/{worldId}/consult
Run a synchronous world consult turn (external agent). External agents only: world:read, canQuery, risk tier T0, and the externalAgentReadEnabled flag. x-origin-system is required. The order of checks is: body idempotency key and replay check, quota (429), then runWorldConsultTurn, a HAM 'world.consult.broadcast' turn. Returns an ExecutionResult whose output is an emission surface, optionally projected by ?layers.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used). A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_consult_sync: callersexternal_agent; scopesworld:read; capabilitycanQuery; risk tier T0 or higher; world policyexternalAgentReadEnabled: the caller can read the world (checked forexternal_agent); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
layers | query | no | string | Comma-separated wire layers; same semantics as /execute. |
x-origin-system | header | yes | string | |
X-Correlation-Id | header | no | string |
Request body (application/json, required)
{
"type": "object",
"required": [
"idempotencyKey"
],
"properties": {
"idempotencyKey": {
"type": "string",
"minLength": 1
},
"idempotencyTtlMs": {
"type": "number"
},
"requestId": {
"type": "string"
},
"sessionId": {
"type": "string"
},
"userMessage": {
"type": "string",
"minLength": 1,
"description": "Required either here or in payload.userMessage."
},
"worldScope": {
"oneOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "array",
"minItems": 1,
"items": {
"type": "string",
"minLength": 1
}
}
],
"description": "Passed into the HAM intent input as world_scope."
},
"worldSetRef": {
"type": "string",
"minLength": 1,
"description": "Passed into the HAM intent input as world_set_ref."
},
"payload": {
"type": "object",
"properties": {
"userMessage": {
"type": "string"
},
"worldScope": {},
"worldSetRef": {
"type": "string"
}
}
}
}
}Responses
-
200: Success envelope; data is an ExecutionResult with output.kind 'emission_surface'.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "data": { "$ref": "#/components/schemas/ExecutionResult" }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" }, "requestId": { "type": "string" } } } } } -
400: ERR_VALIDATION_FAILED: invalid JSON. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
409: ERR_IDEMPOTENCY_CONFLICT: same key, different payload. Error codes:
ERR_IDEMPOTENCY_CONFLICT.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
422: ERR_VALIDATION_FAILED: missing x-origin-system, idempotencyKey, or userMessage, or an invalid worldScope or worldSetRef. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
429: ERR_QUOTA_EXCEEDED with Retry-After. Error codes:
ERR_QUOTA_EXCEEDED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
500: ERR_INTERNAL. A consult failure reported by runWorldConsultTurn carries a HAM failure code, which is outside the AES taxonomy, so error.code is ERR_INTERNAL and error.message is 'Consult failed: <failureCode>.' Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" }
Schemas used: #/components/responses/Forbidden, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied, ApiErrorEnvelope, ExecutionResult
app/api/v1/world/[worldId]/consult/route.ts (confidence: medium).
direct_persona
POST /api/v1/world/{worldId}/directive
Run a bounded persona directive (inference turn) in a world. Validates a persona directive, checks that every anchor ref exists in the graph, acquires the world's directive lock, and synchronously runs an inference turn through the HAM execute seam on the world-global turn flow, returning a DirectiveReceipt in the success envelope. The request blocks until the turn finishes; bounds.timeoutMs and bounds.maxTokens are checked only between turns, and in the current implementation exactly one turn runs regardless of bounds.maxTurns. Any client-supplied provenance is replaced by the authenticated identity. directiveId is used as the HAM session id; a duplicate envelope that already completed returns the cached result, while one still in flight fails with a retryable 500.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session; platform persona token. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session or a platform persona token. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
direct_persona: callersexternal_agent,human,persona; scopespersona:direct; capabilitycanDirectPersona; risk tier T1 or higher; mutation classinference_propose.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
X-Correlation-Id | header | no | string | Optional correlation id; echoed in X-Correlation-Id response header and the success meta. |
Request body (application/json, required)
{
"type": "object",
"required": [
"directiveId",
"intent",
"anchors"
],
"properties": {
"directiveId": {
"type": "string",
"minLength": 1
},
"intent": {
"type": "string",
"minLength": 1,
"description": "Trimmed before validation."
},
"anchors": {
"type": "array",
"items": {
"type": "string",
"pattern": "^(ent|set|txt):"
},
"description": "Graph refs to anchor the turn; may be empty but must be present (or supplied as anchorRefs). Each must exist (matched on node.ref) or the directive is rejected."
},
"anchorRefs": {
"type": "array",
"items": {
"type": "string"
},
"description": "Alias; copied into anchors when anchors is absent or empty."
},
"mode": {
"type": "string",
"enum": [
"answer",
"explore",
"bridge",
"canonize",
"fill",
"synthesize"
],
"description": "fill maps to answer and synthesize maps to canonize."
},
"bounds": {
"type": "object",
"required": [
"maxTurns",
"maxTokens",
"timeoutMs"
],
"properties": {
"maxTurns": {
"type": "integer",
"minimum": 1,
"maximum": 10
},
"maxTokens": {
"type": "integer",
"minimum": 100,
"maximum": 50000
},
"timeoutMs": {
"type": "integer",
"minimum": 1000,
"maximum": 300000
}
},
"default": {
"maxTurns": 1,
"maxTokens": 10000,
"timeoutMs": 60000
}
},
"provenance": {
"description": "Ignored; overwritten server-side with the caller's identity."
}
}
}Responses
-
200: Directive receipt with status completed or partial (partial = token or time bound hit; rejectionReason bounds_tokens_exceeded | bounds_timeout).
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "data": { "$ref": "#/components/schemas/DirectiveReceipt" }, "meta": { "type": "object", "required": [ "correlationId" ], "properties": { "correlationId": { "type": "string" } } } } } -
400: Body is not valid JSON, or worldId missing. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
409: World lock held by another session (retryable=true; no Retry-After header). Error codes:
ERR_WORLD_LOCKED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
422: Schema validation failed (message lists zod issues), or preflight rejected the directive (empty_intent, anchor_not_found). Error codes:
ERR_VALIDATION_FAILED,ERR_DIRECTIVE_REJECTED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: Turn execution failed (receipt status failed) or unexpected error; retryable=true. Error codes:
ERR_EXECUTION_FAILED,ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
503: HAM Redis (KV2_REDIS_URL) not configured; retryable=true. Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" }
Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, ApiErrorEnvelope, DirectiveReceipt
app/api/v1/world/[worldId]/directive/route.ts (confidence: medium).
world_execute_sync
POST /api/v1/world/{worldId}/execute
Run a synchronous world chat turn as an external agent or persona. Authorizes with authorizeRouteRequest. External agents need world:write and inference:propose, canExecuteFlows, risk tier T1 or higher, and the world's externalAgentAccessEnabled flag; personas use x-actor-kind: persona with a persona Bearer token. The order of checks is: request body idempotency key and replay check, quota (429), a HAM 'world.execute.chat' admission, then runExecuteTurn, which reserves STAR settlement and runs the turn pinned to flow:world-global-turn@1.0. The result is cached under the idempotency key. Returns an ExecutionResult whose output is the turn's emission surface, optionally projected to selected layers.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; platform persona token. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a platform persona token. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_execute_sync: callersexternal_agent,persona; scopesworld:write,inference:propose; capabilitycanExecuteFlows; risk tier T1 or higher; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); mutation classinference_propose.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
layers | query | no | string | Comma-separated subset of identity,text,refs,media,context,topology,epistemic,session. identity is always included and unknown names are ignored. When present, data.output.surface becomes a WireEmissionSurfaceProjection. |
x-origin-system | header | no | string | Required for external_agent callers (422 ERR_VALIDATION_FAILED if missing). |
X-Correlation-Id | header | no | string | Echoed in meta and response header. |
Request body (application/json, required)
{
"type": "object",
"required": [
"idempotencyKey"
],
"properties": {
"idempotencyKey": {
"type": "string",
"minLength": 1,
"description": "Required. A body field, not a header. Scoped per actor; the fingerprint covers method, route, and a hash of {mode, sessionId, payload}."
},
"idempotencyTtlMs": {
"type": "number",
"description": "Replay-cache TTL in ms; default 300000; not bounded."
},
"requestId": {
"type": "string"
},
"sessionId": {
"type": "string"
},
"payload": {
"type": "object",
"required": [
"kind",
"userMessage"
],
"properties": {
"kind": {
"const": "inference_turn"
},
"userMessage": {
"type": "string",
"minLength": 1
},
"flowId": {
"type": "string"
},
"flowInput": {
"type": "object"
},
"classification": {}
}
},
"userMessage": {
"type": "string",
"description": "Top-level alternative to payload.userMessage."
},
"flowId": {
"type": "string",
"description": "Forwarded to the HAM input but does not choose the executed flow."
},
"flowInput": {
"type": "object"
},
"classification": {}
}
}Responses
-
200: Success envelope. Idempotent replays return the cached result.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "data": { "$ref": "#/components/schemas/ExecutionResult", "description": "status 'completed'. output.kind is 'emission_surface' ({surface: WireEmissionSurface, turnId, packetId?}), or 'inference_result' when no surface was produced. budgetUsed is all zeros." }, "meta": { "type": "object", "required": [ "correlationId" ], "properties": { "correlationId": { "type": "string" }, "requestId": { "type": "string" } } } } } -
400: ERR_VALIDATION_FAILED: invalid JSON. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED for external agents when world policy is missing or denies access.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
409: ERR_IDEMPOTENCY_CONFLICT: the same key with a different payload, a key already used on /execute/async, or a HAM duplicate that has not materialized yet (retryable). Error codes:
ERR_IDEMPOTENCY_CONFLICT.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
422: ERR_VALIDATION_FAILED (missing x-origin-system, idempotencyKey, or userMessage). HAM admission rejections return 422 with the raw lowercase HAM failure code as error.code (for example capability_denied). The shared 422 ERR_AUTH_FORBIDDEN applies for mutation_not_permitted. Error codes:
ERR_VALIDATION_FAILED,ERR_AUTH_FORBIDDEN.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
429: ERR_QUOTA_EXCEEDED with a Retry-After header in seconds. Error codes:
ERR_QUOTA_EXCEEDED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
500: ERR_INTERNAL. An orchestration rejection carries a HAM failure code, which FailureClassifier classifies as ERR_INTERNAL; error.message is the orchestration's failure message, or 'Execution failed: <failureCode>.' when it has none. Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
503: ERR_INTERNAL: Redis is not configured. Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" }
Schemas used: #/components/responses/Forbidden, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied, ApiErrorEnvelope, ExecutionResult
app/api/v1/world/[worldId]/execute/route.ts (confidence: medium).
world_execute_async
POST /api/v1/world/{worldId}/execute/async
Enqueue an asynchronous world chat turn and get a pollable job. Uses the same authorization and body as /execute, plus an optional webhookUrl, but returns 202 with an AsyncJobEnvelope. The order of checks is: quota first (429), then the idempotency replay check, webhook validation, and HAM admission. A job record is then written to Redis (24 h TTL), and an internal POST to /api/v1/jobs/{jobId}/run starts it; the route answers 202 without waiting for that call and keeps it alive with waitUntil, so the job starts while the client polls. Poll GET /api/v1/jobs/{jobId} (pollUrl) for the result. Replays with the same key and payload return the cached 202 envelope.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; platform persona token. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a platform persona token. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_execute_async: callersexternal_agent,persona; scopesworld:write,inference:propose; capabilitycanExecuteFlows; risk tier T1 or higher; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); mutation classinference_propose.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
x-origin-system | header | no | string | Required for external_agent callers. |
X-Correlation-Id | header | no | string |
Request body (application/json, required)
{
"type": "object",
"required": [
"idempotencyKey"
],
"properties": {
"idempotencyKey": {
"type": "string",
"minLength": 1
},
"idempotencyTtlMs": {
"type": "number"
},
"requestId": {
"type": "string"
},
"sessionId": {
"type": "string"
},
"webhookUrl": {
"type": "string",
"format": "uri",
"description": "Must be https, not localhost or loopback, and not a 10.x, 172.16-31.x, or 192.168.x address. Stored on the job record but never delivered (see notes)."
},
"payload": {
"type": "object",
"required": [
"kind",
"userMessage"
],
"properties": {
"kind": {
"const": "inference_turn"
},
"userMessage": {
"type": "string",
"minLength": 1
},
"flowId": {
"type": "string"
},
"flowInput": {
"type": "object"
},
"classification": {}
}
},
"userMessage": {
"type": "string"
},
"flowId": {
"type": "string"
},
"flowInput": {
"type": "object"
},
"classification": {}
}
}Responses
-
202: Success envelope with data: AsyncJobEnvelope (status queued; pollUrl <origin>/api/v1/jobs/<jobId>; jobId job_<32 hex>). Replays also return 202.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "data": { "$ref": "#/components/schemas/AsyncJobEnvelope" }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" }, "requestId": { "type": "string" } } } } } -
400: ERR_VALIDATION_FAILED: invalid JSON. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
409: ERR_IDEMPOTENCY_CONFLICT: payload mismatch, or the key was already used on sync /execute. Error codes:
ERR_IDEMPOTENCY_CONFLICT.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
422: ERR_VALIDATION_FAILED (missing x-origin-system, idempotencyKey, or userMessage; invalid webhookUrl with reason empty, invalid_url, https_required, blocked_host, or private_ip), or a raw HAM admission failure code. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
429: ERR_QUOTA_EXCEEDED with Retry-After. Checked before replay detection, so replays also consume quota. Error codes:
ERR_QUOTA_EXCEEDED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
500: ERR_INTERNAL Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
503: ERR_INTERNAL: Redis is not configured. Error codes:
ERR_INTERNAL.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" }
Schemas used: #/components/responses/Forbidden, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied, ApiErrorEnvelope, AsyncJobEnvelope
app/api/v1/world/[worldId]/execute/async/route.ts (confidence: medium).
world_query
POST /api/v1/world/{worldId}/query
Search a world's graph for candidate refs (external agent). External agents only: world:read, canQuery, risk tier T0, and the world's externalAgentReadEnabled flag. x-origin-system is required. Runs a query_execution through ExecutionOrchestrator, which re-authorizes and enforces quota, then performs a world-graph search and returns ranked candidate refs. Without mediaType the search ranks every kind of ref in the world together, and images far outnumber entities, settings and stories; mediaType narrows it to one ref prefix. Read-only and not idempotency-keyed.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used). A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_query: callersexternal_agent; scopesworld:read; capabilitycanQuery; risk tier T0 or higher; world policyexternalAgentReadEnabled: the caller can read the world (checked forexternal_agent); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
x-origin-system | header | yes | string | |
X-Correlation-Id | header | no | string |
Request body (application/json, required)
{
"type": "object",
"required": [
"query"
],
"properties": {
"query": {
"type": "string",
"minLength": 1
},
"maxResults": {
"type": "integer",
"minimum": 1,
"default": 50,
"description": "Clamped to 200 by the search."
},
"retrievalDepth": {
"type": "integer",
"minimum": 1,
"description": "Validated but not used by the search."
},
"scope": {
"type": "string",
"enum": [
"mine",
"all"
],
"default": "all"
},
"mediaType": {
"type": "string",
"enum": [
"ent",
"set",
"txt",
"img",
"vid",
"aud",
"obj",
"topic"
],
"description": "Search only refs with this prefix: ent (entities), set (settings), txt (stories), or the media kinds img, vid, aud, obj and topic. Omitted, every kind is ranked together and images dominate."
},
"requestId": {
"type": "string"
}
}
}Responses
-
200: Success envelope.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "data": { "type": "object", "required": [ "kind", "candidates" ], "properties": { "kind": { "const": "query_result" }, "candidates": { "type": "object", "required": [ "candidates" ], "properties": { "candidates": { "type": "array", "items": { "$ref": "#/components/schemas/CandidateRecord" } } } } } }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" }, "requestId": { "type": "string" } } } } } -
400: ERR_VALIDATION_FAILED: invalid JSON or invalid fields, including a mediaType the search does not recognize. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Includes ERR_AUTH_FORBIDDEN from the orchestrator's re-authorization.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
422: ERR_VALIDATION_FAILED: x-origin-system is missing. Error codes:
ERR_VALIDATION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
429: ERR_QUOTA_EXCEEDED. Retry-After is probably absent because the classifier drops retryAfterMs. Error codes:
ERR_QUOTA_EXCEEDED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" } -
500: ERR_INTERNAL or ERR_EXECUTION_FAILED. Error codes:
ERR_INTERNAL,ERR_EXECUTION_FAILED.application/json{ "$ref": "#/components/schemas/ApiErrorEnvelope" }
Schemas used: #/components/responses/Forbidden, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied, ApiErrorEnvelope, CandidateRecord
app/api/v1/world/[worldId]/query/route.ts (confidence: medium).
world_session_messages_get
GET /api/v1/world/{worldId}/sessions/{sessionId}/messages
Read the durable transcript of a world chat session. Returns up to the first 500 messages of the session in ascending creation order, limited to world-visible tiers (world_public, world, world_internal); principal/private messages are never returned. Message bodies are loaded from storage; messages whose body cannot be read or has no text are silently skipped. worldId may be the world UUID or the world name, which is normalized before querying. There is no pagination and no check that the caller participated in the session.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_session_messages_get: callershuman,external_agent; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
sessionId | path | yes | string | |
x-correlation-id | header | no | string | Echoed in meta.correlationId / X-Correlation-Id. |
Responses
-
200: Success envelope.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" } } }, "data": { "type": "object", "required": [ "messages" ], "properties": { "messages": { "type": "array", "maxItems": 500, "items": { "type": "object", "required": [ "messageId", "turnId", "role", "text", "createdAt" ], "properties": { "messageId": { "type": "string" }, "turnId": { "type": [ "string", "null" ], "description": "Parsed from msg_{turnId}_{role}; null for other id formats." }, "role": { "type": "string", "enum": [ "user", "assistant" ] }, "text": { "type": "string" }, "createdAt": { "type": "string", "format": "date-time" } } } } } } } } -
400: ERR_VALIDATION_FAILED (missing ids).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: ERR_INTERNAL (retryable: true).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } }
Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied
app/api/v1/world/[worldId]/sessions/[sessionId]/messages/route.ts (confidence: high).
world_session_turns_get
GET /api/v1/world/{worldId}/sessions/{sessionId}/turns
List turns with stored surfaces for a session. Lists turn ids that have a stored surface.json under the world-owner's storage prefix for the given session id, each with the relative URL of its surface endpoint. No pagination or ordering guarantees beyond the storage listing; no session ownership check is performed.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_session_turns_get: callershuman,external_agent; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
sessionId | path | yes | string | |
x-correlation-id | header | no | string | Echoed in meta.correlationId / X-Correlation-Id. |
Responses
-
200: Success envelope.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" } } }, "data": { "type": "object", "required": [ "turns" ], "properties": { "turns": { "type": "array", "items": { "type": "object", "required": [ "turnId", "surfaceUrl" ], "properties": { "turnId": { "type": "string" }, "surfaceUrl": { "type": "string", "description": "/api/v1/world/{worldId}/turns/{turnId}/surface" } } } } } } } } -
400: ERR_VALIDATION_FAILED (missing ids).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
401: No credential and no signed-in session: middleware answers { "error": "unauthorized" } before the route runs. A credential that fails validation: ERR_AUTH_INVALID in the error envelope.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: ERR_INTERNAL (retryable: true).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } }
Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied
app/api/v1/world/[worldId]/sessions/[sessionId]/turns/route.ts (confidence: medium).
world_stream
GET /api/v1/world/{worldId}/stream
Stream a world's emission-surface events over SSE. Opens a Server-Sent Events stream of world program events from the world's shared event buffer (scoped by world owner and worldId, not by caller or session). The server polls once per second, sends each event with id = its sequence number, emits ping every 30 seconds, and closes after an event whose type is surface_complete or done, or after 300 consecutive idle polls (about 5 minutes) with a timeout event. Resume with the Last-Event-ID header or lastSeq query parameter; only events with seq greater than that value are replayed (buffer retention is limited). Returns 503 when the external SSE lane is disabled by deployment flag.
Credentials. Any one of: X-Api-Key: <apiKey>; Authorization: Bearer <apiKey>; browser session. Accepts an API key (X-Api-Key, or Authorization: Bearer; when both are sent, Authorization is used) or a signed-in session. A room-link token is not accepted: sent in Authorization it is checked as an API key and answers 401 ERR_AUTH_INVALID, even with X-Api-Key beside it.
Authorization (ROUTE_AUTH_POLICIES; GET /api/v1/account lists the operations your credential passes):
world_stream: callershuman,external_agent; scopesworld:read; capabilitycanQuery; world policyexternalAgentReadEnabled: the caller can read the world (checked forexternal_agent); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
lastSeq | query | no | integer (1–) | Resume after this sequence number; ignored when a positive Last-Event-ID header is present. |
last-event-id | header | no | string | Standard SSE resume header; positive integer seq. |
x-correlation-id | header | no | string | Echoed in X-Correlation-Id. |
Responses
-
200: SSE stream (starts with a ': ok' comment). Headers: Cache-Control no-cache, Connection keep-alive, X-Correlation-Id.
-
400: ERR_VALIDATION_FAILED (worldId missing).
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } } -
401: Shared 401, or ERR_AUTH_INVALID when the deprecated shared API key is used.
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Credential is valid but the policy denies this request. ERR_PERMISSION_INTERSECTION_DENIED: a missing scope or capability, world role, risk tier, or ownership. ERR_AUTH_FORBIDDEN: the actor kind is not allowed on this operation. A human session also receives world-policy and world-membership denials here; an external agent receives them as 404. error.details.reason names the denial.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_WORLD_POLICY_DENIED: the key owner's relationship to the world does not pass the check this operation requires for external agents (x-starholder-auth requiresWorldPolicyFlag): externalAgentReadEnabled needs a world the owner can read, externalAgentAccessEnabled a world the owner owns. Sent as 404, not 403, so the response does not reveal the world's configuration. error.details.reason is world_policy_denied or world_policy_missing.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
503: external_sse_disabled: the external SSE lane is not enabled on this deployment.
application/json{ "type": "object", "required": [ "ok", "error" ], "properties": { "ok": { "const": false }, "error": { "type": "object", "required": [ "code", "message", "retryable", "correlationId" ], "properties": { "code": { "type": "string" }, "message": { "type": "string" }, "retryable": { "type": "boolean" }, "correlationId": { "type": "string" } } } } }
Server-sent events
Any successful GET; the stream begins immediately and replays buffered events after the resume seq.
| Event | Data |
|---|---|
<WorldProgramEvent type> | Each buffered event is sent with SSE event name equal to its type (e.g. ack, obs, content, pee_event, classify, agent_event, skill_select, llm, narrative_trace, traversal_trace, tool_trace, tool, op, delta, receipt, error, done, world_proof, flow_start, flow_complete, flow_failed, node_start, node_complete, node_failed, vsp_asset_load_failure, surface_complete) and SSE id equal to seq. data is the full envelope JSON. (WorldProgramEventEnvelope) |
ping | Heartbeat every 30 seconds. |
timeout | Sent once before close when no terminal event arrived within the idle window. |
error | Stream-side failure (distinct from a buffered error event, which carries the envelope shape). |
Resume: Send Last-Event-ID (or ?lastSeq=) with the last seq received; the server replays events with seq greater than it, up to 200 per poll. Replay depends on event-buffer retention.
Schemas used: #/components/responses/Forbidden, #/components/responses/RateLimited, #/components/responses/Unauthenticated, #/components/responses/WorldPolicyDenied, WorldProgramEventEnvelope
app/api/v1/world/[worldId]/stream/route.ts (confidence: medium).