Guides

Responses & Errors

The two envelopes, numeric error codes, pagination and idempotency.

Envelopes

Console and guest — ApiResponse<T>:

{ "success": true, "data": {}, "message": null, "code": null, "errors": null }

Public — the partner envelope:

{ "ok": true, "data": [], "total": 120 }
{ "ok": false, "error": { "code": 409, "message": "…" } }

The code is the HTTP status

NumberName
400IDEMPOTENCY_KEY_REQUIRED
401UNAUTHORIZED · REAUTH_REQUIRED
403FORBIDDEN · TENANT_MISMATCH
404NOT_FOUND
409CONFLICT · PERIOD_LOCKED
422VALIDATION
426UPGRADE_REQUIRED
429RATE_LIMITED
500INTERNAL
503MAINTENANCE (only when echoed) · otherwise transient

Thirteen names over ten numbers. Where a number is shared, the specific name is echoed in errors.code:

{
  "success": false,
  "message": "Business day 2026-09-01 is locked.",
  "code": 409,
  "errors": { "code": ["PeriodLocked"] }
}

Reading an error

  1. success: true → read data.
  2. Take the number: code if present, otherwise the HTTP status.
  3. 422 → VALIDATION; errors is the field dictionary (field → messages). Do not read errors.code as a name here — a form may have a field called code.
  4. Otherwise, if errors.code[0] names a member (e.g. PeriodLocked), that name wins.
  5. Otherwise use the number's own name from the table above: 426 is UPGRADE_REQUIRED. A 503 without the echoed Maintenance is a transient server fault — treat it as INTERNAL and retry later. Unknown numbers are INTERNAL.
  6. Switch on the name — never on message.

On /api/v1/public/**, read error.code. A refused credential, a missing scope, an unbindable body or an unhandled fault there still arrives in the { success, … } shape — apply the steps above to it.

Maintenance (503) and upgrade required (426)

These two are the only failures that carry data, and neither means the session is lost — keep your tokens and do not send the user to sign-in.

503 MAINTENANCE — an installation-wide maintenance window refuses the request. A read_only window refuses writes (POST, PUT, PATCH, DELETE); a full window refuses everything. It applies to /api/v1/console, /guest, /public, /media, /mcp and the offline drain, for every client. The response carries Retry-After (seconds until the window ends, 30–3600) and Cache-Control: no-store:

{
  "success": false,
  "message": "Scheduled server maintenance 03:00–04:00 (Baghdad).",
  "code": 503,
  "errors": { "code": ["Maintenance"] },
  "data": {
    "id": "0192f6b2-6d3e-7c41-8a55-3f1c0e9a1b22",
    "mode": "read_only",
    "startsAt": "2026-10-10T00:00:00Z",
    "endsAt": "2026-10-10T01:00:00Z",
    "messageAr": "صيانة مجدولة للخادم من 3:00 إلى 4:00 فجراً.",
    "messageEn": "Scheduled server maintenance 03:00–04:00 (Baghdad).",
    "retryAfterSeconds": 1200
  }
}

message is Arabic when Accept-Language starts with ar (or is absent), English otherwise. On /api/v1/public/** and /api/v1/mcp the body is the partner envelope instead — { "ok": false, "error": { "code": 503, "message": "…" } } — with the same headers. Queue the write and retry after Retry-After; read GET /api/v1/public/client-status to see a window coming before it starts.

426 UPGRADE_REQUIRED — sent only to the Panoptes staff app (requests carrying X-Client: panoptes-staff) when its build is below the platform's minimum. API keys, MCP clients and dashboards you build are never version-gated. data carries platform, currentVersion, minVersion, latestVersion and, except on the web, storeUrl.

Pagination

  • Console lists: page, per_page, search.
  • Public lists: limit, offset; the response carries total.

Idempotency

Send Idempotency-Key: <uuid> on writes. It is mandatory on POST /api/v1/public/orders and guest self-orders (missing → 400 IDEMPOTENCY_KEY_REQUIRED). A retry with the same key and body returns the original result instead of creating a duplicate.