# Stable error codes — Admin API 2027-01
# Codes are stable identifiers. Human messages may change.

x-pulssor-api-version: "2027-01"
x-pulssor-status: proposed

# Two levels (contract §31)
levels:
  graphql_errors:
    description: Auth, authorization, rate limits, invalid GraphQL, internal failures
  user_errors:
    description: Mutation business validation — returned in payload.userErrors

graphql_error_codes:
  AUTHENTICATION_REQUIRED:
    http_hint: 401
  INVALID_ACCESS_TOKEN:
    http_hint: 401
  TOKEN_EXPIRED:
    http_hint: 401
  TOKEN_REVOKED:
    http_hint: 401

  INSUFFICIENT_SCOPE:
    http_hint: 200 # GraphQL errors still use 200 unless RATE_LIMITED
  INSTALLATION_NOT_FOUND:
    http_hint: 200
  INSTALLATION_SUSPENDED:
    http_hint: 200
  STORE_ACCESS_DENIED:
    http_hint: 200

  RESOURCE_NOT_FOUND:
    http_hint: 200
  INVALID_ID:
    http_hint: 200
  INVALID_CURSOR:
    http_hint: 200

  INVALID_INPUT:
    http_hint: 200
  VALIDATION_ERROR:
    http_hint: 200
  INVALID_ENUM:
    http_hint: 200
  INVALID_ARGUMENT:
    http_hint: 200

  CONFLICT:
    http_hint: 200
  RESOURCE_VERSION_CONFLICT:
    http_hint: 200

  RATE_LIMITED:
    http_hint: 429
  QUERY_TOO_COMPLEX:
    http_hint: 200
  QUERY_TOO_DEEP:
    http_hint: 200

  WEBHOOK_NOT_FOUND:
    http_hint: 200
  WEBHOOK_INVALID_SIGNATURE:
    http_hint: 401

  INTERNAL_ERROR:
    http_hint: 500
  SERVICE_UNAVAILABLE:
    http_hint: 503

user_error_codes:
  TITLE_REQUIRED: {}
  HANDLE_TAKEN: {}
  INVALID_STATUS: {}
  NOT_FOUND: {}
  CONFLICT: {}

http_status_mapping:
  "200": GraphQL request processed, including GraphQL-level errors
  "400": Malformed HTTP/JSON request
  "401": Missing or invalid authentication
  "403": Authenticated but access denied (rare; prefer GraphQL INSUFFICIENT_SCOPE)
  "429": Rate limit exceeded
  "500": Unexpected platform error
  "503": Temporary service unavailability

request_id:
  response_extensions: extensions.requestId
  response_header: X-Request-ID
  client_header: X-Request-ID

graphql_error_shape:
  message: string
  path: "[string|int]"
  extensions:
    code: string
    requestId: string
    retryAfter: "number (RATE_LIMITED only)"

live_today:
  status: mixed
  notes: >
    Runtime AdminSchema returns { errors: [{ message }] } without extensions.code
    or requestId. Aligning runtime is an implementation phase after this freeze.
