# Error Codes

Canonical PAX API error catalog — 103 codes across 15 groups. All errors return the envelope `{"error":{"code","message","trace_id","details?"}}`. Auto-generated from `packages/core/src/errors.ts` on every deploy.

A subset of codes below are *reserved or dormant* — defined in the error catalog but not returned by the standard live surface today (MCP tooling, receiver-side webhook verification, and a few legacy codes retained for catalog stability). Endpoints that can actually return each code are listed on the per-endpoint OpenAPI page ([/openapi](https://docs.predictasiax.com/openapi)). If you see an undocumented code in production, contact [support](https://docs.predictasiax.com/request-access) with the `trace_id`.

## Error response format

```
{
  "error": {
    "code":     "TIER_LIMIT_EXCEEDED",
    "message":  "order notional 50.00 exceeds tier max_order_usdt 10",
    "trace_id": "a98efc1d-7db7-4ee2-bba6-afe481418c11",
    "details":  { "tier": "sandbox", "cap": "10" }
  }
}
```

The HTTP status is bound to the `code` via the shared error catalog — the same code always returns the same status. Reference the `trace_id` when contacting [support](https://docs.predictasiax.com/request-access). Requests made with your own API keys or OAuth apps can be looked up by `trace_id` for 7 days in the Builder Portal (Ops > API request logs) or with [`GET /v1/builders/me/request-logs/{trace_id}`](https://docs.predictasiax.com/builders#request-logs).

## 400 — client errors

| HTTP | Code | Description |
|---|---|---|
| 400 | `BAD_REQUEST` | Malformed request body or query |
| 400 | `VALIDATION_FAILED` | Payload did not pass schema validation |
| 200 | `ORDER_REJECTED` | One order in `POST /v1/orders/batch` was rejected. `error.reject_reason` is the reason (the same value `POST /v1/orders` returns as `reject_reason`, for example `insufficient_balance`), `error.message` its detail, and `data` the rejection as `POST /v1/orders` returns it |
| 400 | `INVALID_FIELD` | A field broke a rule. For orders: `size` at most 6 decimal places, `price` between 0 and 1 with at most 4 decimal places, plain decimals only (no exponent form) |
| 400 | `BELOW_MIN_NOTIONAL` | Order value (size × price; MARKET orders: size) is below 1 USDT |
| 400 | `ABOVE_MAX_NOTIONAL` | Order value is above 100,000 USDT |
| 400 | `IDEMPOTENCY_KEY_MISSING` | Idempotency-Key header required on writes |
| 400 | `IDEMPOTENCY_KEY_MALFORMED` | Idempotency-Key must match `[A-Za-z0-9_-]{8,128}` |
| 409 | `IDEMPOTENCY_BODY_MISMATCH` | Idempotency key reused with different body |
| 400 | `URN_MALFORMED` | Identifier not a canonical URN |
| 400 | `URN_INVALID_DOMAIN` | Identifier URN domain unrecognized |
| 400 | `URN_INVALID_SLUG` | Identifier URN slug malformed |
| 400 | `URN_SLUG_TOO_LONG` | Identifier URN slug exceeds 128 chars |
| 400 | `ID_MALFORMED` | Identifier not a canonical prefixed id |
| 400 | `ID_INVALID_KIND` | Identifier prefix unrecognized |

## 401 — authentication

| HTTP | Code | Description |
|---|---|---|
| 401 | `AUTH_REQUIRED` | Missing credentials |
| 401 | `AUTH_INVALID` | Credentials rejected |
| 401 | `WRONG_ENV_KEY` | Key's environment prefix does not match the target environment — an `sk_live_` key used against sandbox, or an `sk_test_` key against production. |
| 401 | `TIMESTAMP_SKEW` | Presented `PAX-TIMESTAMP` is more than 300 seconds off the server clock. Sync via NTP and resend. |
| 401 | `NONCE_REUSED` | Presented `PAX-NONCE` reused within its 600s TTL. Generate a fresh random nonce per request. |
| 401 | `SIGNATURE_INVALID` | HMAC signature does not match the request. Recompute over `timestamp\nnonce\nmethod\npath\nbody` with your `sk_live_…` secret — see [Auth → HMAC](https://docs.predictasiax.com/auth#hmac). |
| 401 | `TOKEN_EXPIRED` | OAuth access token expired |
| 401 | `TOKEN_REVOKED` | OAuth access token revoked |
| 401 | `TOKEN_INVALID` | OAuth access token could not be verified |
| 400 | `PKCE_INVALID` | PKCE code_verifier did not match code_challenge |
| 400 | `AUTH_CODE_EXPIRED` | OAuth authorization code has expired |
| 400 | `AUTH_CODE_CONSUMED` | OAuth authorization code has already been used |
| 400 | `REDIRECT_URI_MISMATCH` | redirect_uri does not match the value bound at authorize time |
| 401 | `REFRESH_TOKEN_REUSED` | Refresh token reuse detected — token family revoked |

## 403 — authorization

| HTTP | Code | Description |
|---|---|---|
| 403 | `SCOPE_MISSING` | Required scope not present on credential |
| 403 | `WS_TOKEN_UNSUPPORTED` | `POST /v1/ws/token`: this credential is not bound to an API account |
| 403 | `ACCOUNT_SESSION_REQUIRED` | Account actions (password change, signing out other sessions, 2FA, team, payout wallets and settings, withdrawals) need a signed-in Builder Portal session; API keys and third-party app tokens cannot perform them |
| 403 | `SCOPE_NOT_ALLOWED` | Requested scope is not in the app allowed_scopes list |
| 403 | `STEP_UP_MFA_REQUIRED` | High-friction scope requires step-up MFA verification. When present, `details.step_up` names the factor to send: `password` (`current_password`) or `totp` (the 2FA code) |
| 403 | `STEP_UP_INVALID` | The 2FA code, recovery code or account password sent for a step-up was wrong or already used |
| 403 | `BUILDER_NOT_APPROVED` | Builder identity is not in approved status |
| 403 | `APP_NOT_APPROVED` | App is not in approved status |
| 403 | `APP_DISABLED` | App has been disabled by owner or admin |
| 403 | `ACCOUNT_MISMATCH` | `user_id` must be omitted or equal the authenticated account |
| 403 | `DELEGATION_MISSING` | `on_behalf_of` names an account that has no live (unrevoked, unexpired) approval for you: a trading-agent approval, or the user's app connection (`pxu_...`) |
| 403 | `JURISDICTION_BLOCKED` | This action is not permitted in this jurisdiction |
| 403 | `SANCTIONS_HIT` | Wallet address matches a sanctions list; registration or payout blocked |
| 404 | `SANDBOX_ONLY` | Endpoint only available in sandbox environment |
| 404 | `PROD_ONLY` | Endpoint disabled in sandbox environment |

## 404

| HTTP | Code | Description |
|---|---|---|
| 404 | `NOT_FOUND` | Resource not found (generic — route or record not present) |
| 404 | `MARKET_NOT_FOUND` | Market ID does not exist (specific — surfaces inside handlers that need a valid market before proceeding, e.g. subaccount transfer, MM quote creation, RFQ) |

## 409 — conflict

| HTTP | Code | Description |
|---|---|---|
| 409 | `ALREADY_EXISTS` | Resource with that identifier already exists |
| 409 | `CONFLICT` | Uniqueness constraint hit (e.g. same address registered on the same currency+network) |
| 409 | `STATE_CONFLICT` | Requested transition not valid from current state |
| 409 | `IDEMPOTENCY_IN_FLIGHT` | A prior request with the same key is still processing |

## 422 — semantic

| HTTP | Code | Description |
|---|---|---|
| 422 | `RISK_LIMIT_BREACH` | Order would breach a configured risk limit |
| 422 | `BUILDER_FEE_ABOVE_CAP` | Requested builder_fee_bps exceeds apps.builder_fee_cap_bps |
| 422 | `MARKET_HALTED` | Market currently halted by circuit breaker |
| 422 | `MARKET_CLOSED` | Market is past close time |
| 422 | `PRICE_ALERT_LIMIT` | The builder account already has 100 active price alerts (`POST /v1/price-alerts`); cancel one first. See [Price Alerts](https://docs.predictasiax.com/price-alerts) |
| 422 | `MARKET_NOT_APPROVED` | reserved · not emitted. Legacy proposal-approval code. Markets are now created directly at `status: open` via `POST /v1/composer/markets` with no approval step, so no current path returns this. |
| 422 | `MARKET_TEMPLATE_UNKNOWN` | Template id not found |
| 422 | `MARKET_TEMPLATE_PARAM_INVALID` | Template param failed validation |
| 422 | `ORACLE_ADAPTER_UNKNOWN` | Oracle adapter not registered |
| 422 | `ORACLE_DISAGREEMENT` | Oracle adapters disagreed beyond max deviation |
| 422 | `RESOLUTION_LOCKED` | Resolution challenge window still open |
| 422 | `DISPUTE_ALREADY_OPEN` | A dispute is already open on this market |
| 422 | `ANTI_ABUSE_BLOCKED` | Trade flagged by anti-abuse rules (wash/self/related-party) |
| 422 | `OPERATOR_AGREEMENT_MISSING` | reserved · not emitted. Defined in the error catalog but returned by no current action — PredictAsiaX gates no action behind a signed operator agreement. |

## 429

| HTTP | Code | Description |
|---|---|---|
| 429 | `RATE_LIMITED` | Rate limit exceeded, retry after Retry-After. A request refused by a per-key limit is not counted; for a batch, `details.cost` is its item count. See [Rate limits](https://docs.predictasiax.com/rate-limits#batches). |
| 429 | `TIER_LIMIT_EXCEEDED` | Order or daily notional exceeds api_key tier caps |
| 403 | `TIER_UPGRADE_REQUIRED` | This endpoint requires a higher trust tier |
| 429 | `SANDBOX_KEY_DAILY_LIMIT` | This IP has already minted a sandbox key today |
| 401 | `PASSWORD_INCORRECT` | Current password does not match |
| 422 | `PASSWORD_TOO_WEAK` | New password does not meet strength requirements |
| 410 | `SIGNIN_LINK_INVALID` | Builder Portal sign-in link is invalid, expired, revoked or already used. Ask the PredictAsiaX team for a new link. |
| 410 | `GRANTS_RETIRED` | Builder grants are retired (2026-12-02). Builder PAX is paid by the weekly rewards: `GET /v1/builders/me/points`. |

## webhook subsystem

| HTTP | Code | Description |
|---|---|---|
| 400 | `WEBHOOK_URL_INVALID` | Webhook URL must be a valid https URL with no userinfo/fragment (thrown by PAX on `POST /v1/webhooks`, and on `PATCH /v1/webhooks/{id}` with `{"active": true}` when re-enabling) |
| 400 | `WEBHOOK_SECRET_INVALID` | receiver-side. Recommended code for your webhook receiver to return when it cannot decode the signing secret. Not emitted by PAX; PAX emits `WEBHOOK_URL_INVALID` at register time. |
| 401 | `WEBHOOK_TIMESTAMP_SKEW` | receiver-side. Recommended code for your receiver to return when the `t=` value in `X-PAX-Signature` is outside your tolerance window. Not emitted by PAX. |
| 401 | `WEBHOOK_SIGNATURE_INVALID` | receiver-side. Recommended code for your receiver to return when neither `v1=` HMAC matches the body. See [/webhook-signing](https://docs.predictasiax.com/webhook-signing). |
| 422 | `WEBHOOK_EVENT_UNKNOWN` | Webhook event_type not present in canonical catalog (thrown by PAX on `POST /v1/webhooks` and `PATCH /v1/webhooks/{id}`) |

## subaccounts / delegation

| HTTP | Code | Description |
|---|---|---|
| 404 | `SLOT_NOT_FOUND` | `subaccount_slot` names a slot that does not exist; create it with `POST /v1/subaccounts`. Sandbox keys have only slot 0. A slot that is not an integer 0–63 is `400 VALIDATION_FAILED` |
| 403 | `SUBACCOUNTS_BUILDER_ONLY` | Subaccounts are available to builder accounts |
| 409 | `SUBACCOUNT_NOT_EMPTY` | A subaccount with a balance, open orders or open positions cannot be deleted; empty it first |
| 409 | `INSUFFICIENT_BALANCE` | The source slot of a subaccount transfer does not hold the amount |
| 202 | `pending: true` | Not an error: a subaccount transfer was interrupted between its two legs and completes automatically |
| 403 | `DELEGATION_SCOPE_MISMATCH` | The trading-agent approval does not cover this request: scope (e.g. `close_only` and a BUY), slot, market, or per-order `max_notional_usdt` |
| 422 | `DELEGATION_DAILY_CAP_EXCEEDED` | The order would take the approval past its rolling-24h `daily_notional_cap` |
| 403 | `APPROVAL_INVALID` / `APPROVAL_EXPIRED` | Approving a trading agent: the request did not come from your Builder Portal session with a fresh 2FA code; approve it in the portal |
| 409 | `LIMIT_REACHED` | 10 live trading agents already; revoke one first |
| 400 | `INVALID_FIELD` | Approving a trading agent: `delegatee_id` is not a live builder account |
| 503 | `SERVICE_UNAVAILABLE` | Approving a trading agent: the agent account could not be verified; retry shortly |
| 400 | `VALIDATION_FAILED` | Approving a trading agent: the body has a field this endpoint does not take; `details.unknown_fields` names it (for example `per_order_cap` instead of `max_notional_usdt`). Nothing is created and the 2FA code is not used up |

## builder fee

| HTTP | Code | Description |
|---|---|---|
| 403 | `BUILDER_FEE_NOT_APPROVED` | Order placed for another account (`on_behalf_of`) by a builder that charges a builder fee, and that account has not approved the builder's fee (`POST /v1/builder-fee-approvals`). The message names the rate. Nothing was placed |
| 403 | `BUILDER_FEE_EXCEEDS_APPROVAL` | The builder's current rate is above the maximum the account approved. Nothing was placed; the account can raise its approval |
| 503 | `BUILDER_FEE_UNAVAILABLE` | The builder's rate or the account's approval could not be read. The order is refused rather than placed with an unverified fee; retry shortly |
| 409 | `RATE_CHANGE_PENDING` | `PUT /v1/builders/me/fee` while a change is pending; `details.pending_effective_at`. Cancel it with `DELETE /v1/builders/me/fee/pending` or wait |
| 429 | `RATE_CHANGE_COOLDOWN` | The rate can change at most once every 7 days; `details.next_change_allowed_at` |
| 403 | `BUILDER_NOT_ELIGIBLE` | Setting a rate: only live (non-sandbox) builders can charge a builder fee. Approving (404): unknown or inactive builder |
| 409 | `APPROVAL_LIMIT` | 10 live builder fee approvals already; revoke one first |
| 404 | `NOT_FOUND` | No pending rate change to cancel, or no live approval for that builder to revoke |

## composer

| HTTP | Code | Description |
|---|---|---|
| 400 | `TEMPLATE_SCHEMA_INVALID` | Template params_schema is malformed |
| 400 | `TEMPLATE_DISPLAY_KEY_MISSING` | display_defaults references a key not in params_schema |
| 409 | `PROPOSAL_STATE_INVALID` | Proposal state transition not valid |
| 422 | `COMBO_COMPONENT_HALTED` | Combo derived market has a halted component |
| 403 | `COMPLIANCE_GATE_BLOCKED` | Compliance gate blocked market creation |

## liquidity/RFQ

| HTTP | Code | Description |
|---|---|---|
| 400 | `QUOTE_EXPIRED_IN_PAST` | Quote expires_at_ms must be in the future |
| 400 | `QUOTE_SIZE_INVALID` | Quote size is invalid (must be > 0) |
| 409 | `RFQ_NOT_OPEN` | RFQ is not open for new quotes |
| 422 | `RFQ_QUOTE_OUT_OF_BOUNDS` | RFQ quote price outside min/max bounds |
| 400 | `QUOTE_SIZE_MISMATCH` | Quotes are for the full RFQ size |
| 409 | `QUOTE_NOT_LIVE` | Quote is no longer live (expired, withdrawn, replaced, failed or filled) |
| 409 | `QUOTE_EXECUTING` | The requester accepted this quote; it is being executed |
| 409 | `RFQ_EXECUTING` | A quote on this RFQ is being executed; retry shortly |
| 422 | `RFQ_QUOTE_FAILED` | The accepted quote could not be executed; nothing moved and the RFQ is open again |
| 422 | `SELF_TRADE` | You cannot trade against your own account |
| 409 | `INSUFFICIENT_BALANCE` | Block trade proposal or acceptance, or RFQ quote: your account's free USDT is below the cash your own leg needs (buyer: price x size; seller backing with USDT: (1 - price) x size; fees not included). Only your own leg is checked; nothing is reserved, and the engine checks both legs again at execution |
| 409 | `INSUFFICIENT_POSITION` | Same, for a leg that sells shares: your account holds fewer sellable shares than the leg's size |
| 503 | `BACKING_CHECK_UNAVAILABLE` | Your balance or holdings could not be checked; retry |
| 503 | `RFQ_UNAVAILABLE` | Block trades are temporarily unavailable |
| 422 | `INCENTIVE_BUDGET_EXCEEDED` | Incentive budget for this period is exhausted |

## widget / data / MCP

| HTTP | Code | Description |
|---|---|---|
| 404 | `MCP_TOOL_UNKNOWN` | reserved · MCP subsystem. MCP tool name not registered |
| 403 | `MCP_SCOPE_MISSING` | reserved · MCP subsystem. MCP tool call missing required scope |
| 501 | `MCP_NOT_IMPLEMENTED` | reserved · MCP subsystem. MCP tool has no upstream implementation yet |
| 403 | `WIDGET_ORIGIN_BLOCKED` | Widget embed origin is blocked |
| 403 | `DATA_TIER_EXCEEDED` | Data query exceeds allowed tier |
| 422 | `DATA_RANGE_TOO_LARGE_FOR_TIER` | Requested range exceeds tier maximum |

## oracle / resolution

| HTTP | Code | Description |
|---|---|---|
| 502 | `ORACLE_ADAPTER_ERROR` | Oracle adapter fetch failed |
| 403 | `ORACLE_BOND_INSUFFICIENT` | Oracle provider PAX bond below configured minimum |
| 422 | `RESOLUTION_EVIDENCE_MISSING` | Resolution requires evidence and none was attached |
| 409 | `RESOLUTION_CHALLENGE_OPEN` | Cannot finalize while a challenge window is open |

## marketplace

| HTTP | Code | Description |
|---|---|---|
| 403 | `LISTING_NOT_APPROVED` | Marketplace listing has not been approved |
| 403 | `DISPUTE_REQUIRES_POSITION` | Only an account holding a position in the market can challenge its oracle verdict |
| 403 | `USE_API_GATEWAY` | API keys are accepted only at `https://api.predictasiax.com/v1`; calls to any other host are refused |
| 409 | `BOUNTY_ALREADY_CLAIMED` | Bounty has already been claimed |

## 500 — / 502 / 503 / 504

| HTTP | Code | Description |
|---|---|---|
| 500 | `INTERNAL_ERROR` | An internal error occurred |
| 502 | `UPSTREAM_ERROR` | Upstream service returned an error |
| 504 | `UPSTREAM_TIMEOUT` | Upstream service timeout |
| 503 | `SERVICE_UNAVAILABLE` | Named subsystem is currently gated off (e.g. payouts kill-switch on for a scope), with a human-readable reason in the message |
| 503 | `SERVICE_UNAVAILABLE` | Placing or cancelling an order: the result is not known yet. The order may or may not have been placed: send it again with the same `client_order_id`. It is never placed twice, and if the first one was placed, the reply is that order with `duplicate: true`. Check a cancel with `GET /v1/orders/{id}`. |
| 503 | `MAINTENANCE` | Service temporarily in maintenance |
| 503 | `SANCTIONS_SCREEN_UNAVAILABLE` | Sanctions screening could not complete, so the wallet address was not accepted; retry later |

## Canonical source

This table is generated from `packages/core/src/errors.ts`. To propose a new code, PR that file; do not edit this HTML directly. See [OpenAPI spec](https://docs.predictasiax.com/openapi) for which codes each endpoint can return.

Source: https://docs.predictasiax.com/errors
