Starholder API

Error Handling

Error envelope format, error codes, retry strategy, and status code mapping.

The Starholder API is designed so that errors are structured, predictable, and include enough information to fix the problem without guessing. Every error response tells you what went wrong, which request it applies to, and whether you should retry. This page covers the response format, every error code you might encounter, and how to handle retries.

Response Envelope

Every API response follows the same structure, so you always know what to expect regardless of which endpoint you call. Parse the top-level ok field first — it tells you whether the request succeeded before you look at anything else.

Success

{
  "ok": true,
  "data": { ... },
  "meta": {
    "correlationId": "corr_abc123def456",
    "requestId": "req_001"
  }
}

meta is present when the handler includes request metadata. Some older routes ($STAR wallet, key lifecycle) return raw JSON without the ok wrapper — these are being migrated over time.

Error

{
  "ok": false,
  "error": {
    "code": "ERR_PERMISSION_INTERSECTION_DENIED",
    "message": "This credential does not hold the account:write scope this operation requires",
    "retryable": false,
    "correlationId": "corr_abc123def456",
    "details": { "reason": "missing_scope", "detail": "account:write" }
  }
}

When retryable is true, the error may include retryAfterMs; on 409 and 429 responses the Retry-After header carries the same delay in seconds. Authorization denials include error.details.reason, which names exactly which check failed (for example missing_scope, missing_capability, risk_tier_exceeded, world_policy_denied). For missing_scope and missing_capability, error.details.detail names the scope or capability, and so does the message. A key created in Settings holds every standard scope, so if one of those is missing, the key was created with a narrower list or is an OAuth connection approved without it: create a new key, or reconnect and approve the scope.

A few routes answer outside this envelope. A rejected narrative submission returns 422 with { submissionId, status: "rejected", rejection: { reasons: [{ code, field?, message }] } }, and the Operation Reference shows the shape each operation returns.

HTTP Status Codes

StatusMeaningRetryable
200Success—
201Created (narrative submit)—
202Accepted (async job enqueued — work is happening in the background)—
400Bad request (malformed JSON, invalid query parameters)No
401Authentication failed (missing, invalid, expired, or revoked credential)No
403Authorization denied (insufficient scope, capability, role, or risk tier)No
404Resource not found, or a world policy denies an external agentNo
409Conflict (resource not ready, idempotency conflict, already decided)Sometimes
422Validation error, a rejected submission, or a mutation your actor may not performNo
429Quota exceededYes
500Internal server errorYes
503Service unavailable (dependency down, feature disabled, ledger unconfigured)Yes

Error Codes

This page covers the codes shared across the API. Each operation in the Operation Reference lists the codes its responses can carry.

Authentication

CodeStatusDescription
ERR_AUTH_INVALID401The credential is malformed, unknown, expired, or revoked. Send the key as X-Api-Key: <key> or Authorization: Bearer <key>. A credential that fails never falls back to a browser session.

A request with no credential and no signed-in session is answered before it reaches the route, with 401 and a bare { "error": "unauthorized" } instead of the envelope.

Authorization

CodeStatusDescription
ERR_PERMISSION_INTERSECTION_DENIED403Your key lacks the required scope, capability, world role, or risk tier for this operation. "Intersection" refers to the overlap between what your key is allowed to do and what the route requires — if there's no overlap, the request is denied. error.details.reason says which check failed. An external agent without membership in the world gets this code with 404.
ERR_AUTH_FORBIDDEN403 or 422403: your actor class isn't allowed on this route — for example, an API key calling a session-only endpoint. 422: the specific type of mutation you're attempting isn't allowed for your actor class (details.reason is mutation_not_permitted); some mutations are restricted by design regardless of permissions.
ERR_WORLD_POLICY_DENIED404 for external agents, 403 for sessionsYour relationship to the world does not pass this route's world check: reads need a world you can read, and actions need a world you own. External agents get 404 (not 403) so that a key that may not read a world does not learn that it exists or how it is configured. Your key acts as you, so it reaches the same worlds you do; see World Policy Checks.
ERR_QUOTA_EXCEEDED429A rate or daily quota is exhausted; message names which one. See Rate Limits.

Validation

CodeStatusDescription
ERR_VALIDATION_FAILED400 or 422The request fails validation. The message field says which fields are invalid or missing. A missing x-origin-system header on query and execute routes is reported this way (422).

A rejected narrative submission is not an error envelope; its rejection.reasons[].code values include MISSING_FIELD, PROVENANCE_MISMATCH (the contentHash doesn't match the SHA-256 of the trimmed narrative text), duplicate_submission (the same text was submitted within 24 hours), submission_quality_floor, and submission_policy_violation.

Resource State

These errors relate to the state of resources as they move through processing pipelines. Several of them are expected during normal operation — they don't mean something is broken, just that the resource isn't ready yet.

CodeStatusDescription
ERR_EXTRACTION_NOT_READY409The submitted story doesn't have a TextRoot yet, so there is no extraction to read. This is normal right after submitting a narrative. Poll the submission and retry.
ERR_MANIFEST_NOT_READY409The manifest (a structured breakdown of media assets needed for a narrative) can't be built yet. Like extraction, this is part of the normal submission lifecycle. Poll and retry.
ERR_STRATEGY_ALREADY_SET409The manifest's fulfillment strategy has already been chosen and can't be changed. Strategies are immutable once set to prevent conflicting work.
ERR_SUBMISSION_SEALED409The submission is finalized, or its current state doesn't allow this step.
ERR_IDEMPOTENCY_CONFLICT409The same idempotency key was used with a different payload, or on the other of execute and execute/async. Use a new idempotency key if you intend this to be a separate operation.

Directive

CodeStatusDescription
ERR_DIRECTIVE_REJECTED422The directive failed schema validation, or was rejected during preflight — a validation step where the system checks whether your directive makes sense before actually executing it, such as an empty intent or an anchor that doesn't exist. The message field explains why.

Correlation IDs

Every /api/v1 response includes X-Correlation-Id in the response header. If you supply one in the request, it is echoed back. Otherwise the server generates one in the format corr_<16 hex chars>.

Use correlation IDs when reporting issues or tracing requests through logs.

Retry Strategy

For retryable errors (429, some 409, 5xx):

  1. Check the Retry-After header (seconds) if present
  2. If no header, use exponential backoff starting at 1 second
  3. Cap at 5 retries for 5xx errors
  4. Never retry 401, 403, 404, or 422 errors

For idempotent operations (execute, execute/async), safe replay is guaranteed via the idempotencyKey.