World · Prompt Policy
2 operations tagged world.prompt-policy.
world_prompt_policy_get
GET /api/v1/world/{worldId}/prompt-policy
Get the world's effective prompt policy. Owner-only read of the effective world prompt policy (prompt text, schema version, source) along with the config ref and config hash needed for PUT. Response is Cache-Control: no-store.
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_prompt_policy_get: callershuman,external_agent; scopesworld:read; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); world roleowneror higher (humans); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | 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": { "$ref": "#/components/schemas/WorldPromptPolicyPayload" } } } -
401: Shared 401, or ERR_AUTH_INVALID (no user id).
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Shared denials, or ERR_AUTH_FORBIDDEN (not owner).
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_NOT_FOUND. Also ERR_WORLD_POLICY_DENIED when the world's policy does not admit external agents. Error codes:
ERR_WORLD_POLICY_DENIED.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" } } } } } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: ERR_INTERNAL.
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" } } } } } -
503: ERR_WORLD_POLICY_UNRESOLVABLE.
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, WorldPromptPolicyPayload
app/api/v1/world/[worldId]/prompt-policy/route.ts (confidence: high).
world_prompt_policy_put
PUT /api/v1/world/{worldId}/prompt-policy
Replace the world's prompt policy text. Owner-only replacement of the world prompt text (trimmed, 1-2500 characters). baseConfigHash must equal the current world config hash or the call fails with 409. The handler rewrites the full world config with the new promptPolicy, writes a config-update receipt, and updates the world's config ref/hash; it does not use the generic config mutation path or refresh the public directory. Because the hash changes on success, a blind retry returns 409.
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_prompt_policy_put: callershuman,external_agent; scopesworld:write; world policyexternalAgentAccessEnabled: the caller owns the world (checked forexternal_agent); world roleowneror higher (humans); mutation classnone.
Parameters
| Name | In | Required | Type | Description |
|---|---|---|---|---|
worldId | path | yes | string | |
x-correlation-id | header | no | string | Echoed in meta.correlationId / X-Correlation-Id. |
Request body (application/json, required)
{
"type": "object",
"required": [
"baseConfigHash",
"promptText"
],
"additionalProperties": false,
"properties": {
"baseConfigHash": {
"type": "string"
},
"promptText": {
"type": "string",
"minLength": 1,
"maxLength": 2500,
"description": "Length checked after trimming."
}
}
}Responses
-
200: Policy updated. Cache-Control: no-store.
application/json{ "type": "object", "required": [ "ok", "data", "meta" ], "properties": { "ok": { "const": true }, "meta": { "type": "object", "properties": { "correlationId": { "type": "string" } } }, "data": { "$ref": "#/components/schemas/UpdateWorldPromptPolicyResponse" } } } -
400: ERR_VALIDATION_FAILED (invalid JSON, extra or missing keys, empty or > 2500-char prompt).
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 (no user id).
application/json{ "oneOf": [ { "$ref": "#/components/schemas/AesErrorEnvelope" }, { "type": "object", "required": [ "error" ], "properties": { "error": { "const": "unauthorized" } } } ] } -
403: Shared denials, or ERR_AUTH_FORBIDDEN (not owner).
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
404: ERR_NOT_FOUND. Also ERR_WORLD_POLICY_DENIED when the world's policy does not admit external agents. Error codes:
ERR_WORLD_POLICY_DENIED.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" } } } } } -
409: ERR_WORLD_PROMPT_CONFIG_CONFLICT (stale baseConfigHash).
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" } } } } } -
429: Per-key or per-actor quota exceeded (ERR_QUOTA_EXCEEDED). Honor Retry-After.
application/json{ "$ref": "#/components/schemas/AesErrorEnvelope" } -
500: ERR_INTERNAL (including config write hash mismatch).
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" } } } } } -
503: ERR_WORLD_POLICY_UNRESOLVABLE.
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, UpdateWorldPromptPolicyResponse
app/api/v1/world/[worldId]/prompt-policy/route.ts (confidence: high).