Starholder API
Operation Reference

World · Turns

1 operation tagged world.turns.

world_turn_surface_get

GET /api/v1/world/{worldId}/turns/{turnId}/surface

Get the persisted emission surface for a world turn. Returns the stored EmissionSurface snapshot for a turn in the world-owner's world scope. With layers, returns a projection containing identity plus the requested layers (unknown layer names are ignored); with include=proof, also attaches the durable world proof (null if none). surfaceRef selects a specific stored surface, but only if it is registered as a surface.snapshot.bundle artifact for this world and turn.

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_turn_surface_get: callers human, external_agent; scopes world:read; capability canQuery; world policy externalAgentReadEnabled: the caller can read the world (checked for external_agent); mutation class none.

Parameters

NameInRequiredTypeDescription
worldIdpathyesstring
turnIdpathyesstring
layersquerynostringProject the surface to these layers; identity is always included.
includequerynostringComma-separated; 'proof' attaches worldProof.
surfaceRefquerynostringStorage key of a specific surface bundle; must match a recorded artifact for this world+turn, otherwise 404.
x-correlation-idheadernostringEchoed in X-Correlation-Id (and meta.correlationId when enveloped).

Responses

  • 200: Shape depends on query: (a) no layers and no include=proof: the raw stored surface JSON with NO ok/data envelope; (b) layers: envelope with data = projection {schema, requestedLayers, surface}, plus data.worldProof when include=proof; (c) include=proof only: envelope with data = {surface, worldProof}.

    application/json

    {
      "oneOf": [
        {
          "oneOf": [
            {
              "$ref": "#/components/schemas/WireEmissionSurface"
            },
            {
              "$ref": "#/components/schemas/EmissionSurface"
            }
          ]
        },
        {
          "type": "object",
          "required": [
            "ok",
            "data",
            "meta"
          ],
          "properties": {
            "ok": {
              "const": true
            },
            "meta": {
              "type": "object",
              "properties": {
                "correlationId": {
                  "type": "string"
                }
              }
            },
            "data": {
              "oneOf": [
                {
                  "allOf": [
                    {
                      "$ref": "#/components/schemas/WireEmissionSurfaceProjection"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "worldProof": {
                          "oneOf": [
                            {
                              "$ref": "#/components/schemas/WorldProofEventPayload"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      }
                    }
                  ]
                },
                {
                  "type": "object",
                  "required": [
                    "surface",
                    "worldProof"
                  ],
                  "properties": {
                    "surface": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/WireEmissionSurface"
                        },
                        {
                          "$ref": "#/components/schemas/EmissionSurface"
                        }
                      ]
                    },
                    "worldProof": {
                      "oneOf": [
                        {
                          "$ref": "#/components/schemas/WorldProofEventPayload"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    }
                  }
                }
              ]
            }
          }
        }
      ]
    }
  • 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_NOT_FOUND (surface not stored, or surfaceRef not registered for this turn). 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 (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, EmissionSurface, WireEmissionSurface, WireEmissionSurfaceProjection, WorldProofEventPayload

Contract authored from app/api/v1/world/[worldId]/turns/[turnId]/surface/route.ts (confidence: medium).