Error codes

Every error uses one envelope with a stable machine-readable code. Branch on error.code, not the mutable message or HTTP status alone.

{
  "error": {
    "code": "validation_failed",
    "message": "Request validation failed.",
    "request_id": "req_01HQ...",
    "details": [
      {
        "field": "territories",
        "issue": "zod_invalid_format",
        "message": "The value has an invalid format."
      }
    ]
  }
}

request_id echoes your X-NU-Request-Id, or a server-generated value. Include it in support requests. details is present for validation errors.

Code reference

CodeHTTPMeaningTypical action
invalid_api_key401Key missing, malformed, unknown, or expiredSend a valid Authorization: Bearer key for the correct environment
api_key_revoked401Key has been revokedReplace it with an active key (04)
invalid_approval_token401Approval token is invalid, expired, or already used for bootstrapRequest a new approval token and bootstrap it once (04)
invalid_application_token401Application reference or status token is wrong or expiredUse the one-time status credentials from the initial application response
missing_scope403Key lacks the required scopeGrant the scope; see the scope table (03)
production_key_required403Sandbox key called a Production-only endpointRetry the settlement request with an nsp_live_ key
organization_not_approved403Organization is not approved yetWait for approval or complete onboarding (02)
resource_not_found404Resource does not exist or is not visible to your organizationCheck the ID and your organization’s access
validation_failed422Request body or parameter validation failedFix the fields listed in details
rate_limit_exceeded429Per-key rate limit reachedBack off using Retry-After (12)
license_not_active403No ACTIVE agreement authorizes this playbackActivate the agreement or enable its Production API (06)
territory_not_allowed403Production country missing, or country, origin, or IP is not allowed by the agreement or keySend an allowed Production country; include an allowed origin when configured and check allowed_ips
episode_not_licensed403Episode is not ready, lacks a ready video asset, or is outside the licensed asset setLicense the ready video asset or use an eligible ready episode
duplicate_event_id409event_id was already accepted; idempotent no-opTreat as success; do not retry with a different ID
invalid_playback_session400Unknown or invalid playback sessionUse the playback_session_id returned by the Playback API
playback_concurrency_limit429Too many active sessions for this viewer and agreement or titleRevoke an existing session or let it complete or expire before issuing another
settlement_not_disputable409Settlement is not in a disputable stateDispute only while the state permits it (09)
conflict409Resource already exists or a concurrent or in-progress request holds the operationRetry the idempotent request or reconcile the existing resource
service_unavailable503The required service is temporarily unavailable.Retry idempotent calls with exponential backoff.
internal_error500Unexpected server errorRetry with backoff; if it persists, contact support with request_id

Handling guidance

  • 401 — Fix authentication; do not retry blindly.
  • 403 — Authorization issue involving scope, organization, or rights. Retrying is not useful until the underlying permission changes.
  • 404 — Check the ID and organization visibility.
  • 422 — Inspect details[] and correct the request.
  • 409 — Depends on the code: duplicate_event_id means the event was already accepted and should be treated as success; settlement_not_disputable means the action is not currently allowed; conflict means a resource exists or a concurrent request is in progress. Retry the idempotent call or reconcile the existing resource as appropriate.
  • 429 — Honor Retry-After; see Rate limits.
  • 5xx — Retry idempotent calls with exponential backoff.

Database constraint mapping

Known database errors map to clean 4xx responses instead of a generic 500, including read-then-write races against concurrently deleted rows:

Database conditionHTTPerror.code
Row not found during write (P2025)404resource_not_found
Unique constraint violation (P2002)409conflict
Foreign-key constraint violation (P2003)422validation_failed