Errors
Standard HTTP status codes and one error envelope on every endpoint. Branch on the code; the message is for people.
Error envelope
Every non-2xx response is an object with a single top-level key:
{
"error": {
"code": "invalid_api_key",
"message": "API key is invalid, revoked, or expired",
"details": { }
}
}
Always branch on error.code rather than the English message. Messages may be refined over time; codes are stable. The AI pass-through is the one exception: it returns errors in the provider's own shape, so the provider SDK raises its own typed errors.
Status codes
| Status | When |
|---|---|
| 200 OK | Successful response. A rejected order leg is still a 200 — read results[i].rejected_code. |
| 201 Created | Something was made: a model, a practice deposit, a link session, an app token. |
| 202 Accepted | Queued, not done: a notification send, an AI inference still running past wait_seconds. |
| 400 Bad Request | Invalid parameters, bad JSON, a malformed cursor, an unknown field on a strict body. |
| 401 Unauthorized | Missing, invalid, revoked or expired credential. |
| 402 Payment Required | Out of reasoning credits on a managed AI call. |
| 403 Forbidden | Authenticated, but the plan, key scopes or the user's consent do not cover this — or the account is not yours. |
| 404 Not Found | The resource does not exist, or is not yours (the two are indistinguishable by design). |
| 409 Conflict | State disagrees: an archived model, an already-listed app, a linked AI key the provider rejected. |
| 413 Payload Too Large | An AI request body over 32 MB. |
| 429 Too Many Requests | The per-minute or per-day budget, or a user's monthly AI token cap. |
| 500 Internal Server Error | Unexpected server error. Safe to retry with backoff. |
| 503 Service Unavailable | An upstream dependency is down. Retry with backoff. |
Codes you will meet everywhere
| Code | Meaning |
|---|---|
missing_credentials | Neither X-API-Key nor Authorization: Bearer was sent. |
invalid_api_key | The key is unknown, revoked or past its expiry. |
invalid_jwt | The session token failed verification or expired. |
entitlement_required | Your plan or key scopes lack a code; details.missing lists which. |
scope_not_granted | An install key whose user declined the scope, or a Connect user who withheld a venue permission. |
account_forbidden | X-OpenMarkets-Account names a user your organization does not own. |
rate_limit_exceeded | Per-minute or per-day quota hit. details.window says which; Retry-After says how long. |
unknown_parameter | A field outside a strict contract (orders, models) was sent. |
not_found | The addressed league, contest, market or position does not exist. |
invalid_position_hash | The position_hash is not a 6-part colon-separated string. |
internal_error | Unexpected server-side failure. Safe to retry. |
Each page lists the codes specific to its surface — orders, models, AI Connect, Connect and notifications all have their own.
Sell codes
Selling a position (POST /orders/sell and /orders/sell/preview) has its own list of leg codes. Like a rejected buy leg, a refused sell leg is a 200 with the code in results[i].rejected_code. Each leg also carries message_user, written for an end user, and fix, a hint a UI can act on. The list is closed; treat an unlisted value as unknown.
| Code | Meaning | fix |
|---|---|---|
sell_not_supported | The venue cannot sell this position, or selling is off for it. It is held until it settles. The position's sell block says which. | none |
unsupported_order_type | The venue does not take that order_type for a sell. | none |
position_not_found | No open contracts for this position. Missing and not yours are the same answer. | none |
position_route_ambiguous | The position is held on more than one market at the venue. Send partner_market_id; details.partner_market_ids lists the choices. | name_route |
insufficient_position | Not enough sellable contracts. details has held, reserved and sellable, and venue_position when the venue's own count was read. Also returned when the venue holds fewer contracts than our books show and the sell filled nothing. | lower_contracts, or none when the venue holds none |
sell_in_progress | Another sell on the position is still working, or mixes a model scope with an unscoped one. Wait for it or cancel it. | retry |
position_settling | The contest is no longer open. The position will settle instead. | none |
no_bid | Nobody is bidding on the position. | use_limit where the venue takes a limit sell, else none |
bid_below_min_price | The best bid is under your min_price, so a market sell would not fill. | lower_price |
no_live_bid_for_paper | No venue gives a bid for the practice position, so the practice sell has no price. | none |
venue_disabled | The venue account is not connected, or signing in to it failed. | connect_venue |
contracts_not_whole | The venue sells whole contracts only. | lower_contracts |
venue_location_check | The venue needs to confirm the user's location. The user opens the venue's app, signs in and allows location access, then the sell is sent again. Nothing was sold. details.venue_url is set when the venue has a link for it. | retry |
venue_location_blocked | The venue does not allow trading from the user's location. Opening the app does not change it. | none |
unknown | Anything not classified. On a pending leg the venue did not answer, and on a failed leg the sell could not be confirmed: do not retry, check your orders. | retry, or none when the outcome is unknown |
Failures that apply to the whole request are HTTP errors with the usual envelope. The sell endpoints add one code of their own and share the rest with /orders/buy:
| Code | HTTP | Meaning |
|---|---|---|
sell_not_enabled | 403 | Selling is not available for this environment. Nothing was placed. |
real_money_not_permitted | 403 | A leg sells a real-money position and the caller lacks trade:execute. Nothing is placed, practice legs included. |
connect_scope_required | 403 | Acting for a Connect user who has not granted trade:execute for a venue named on a real-money leg. |
environment_unresolved | 403 | The credential carries no recognised environment. Mint a new key. |
model_not_found | 404 | A model_id that does not exist or is not yours. An archived model is allowed. |
bad_request | 400 | Invalid body: orders is not 1 to 10 legs, a bad liquidity_hash, contracts, min_price or order_type. |
unknown_parameter | 400 | A field outside the strict sell contract was sent. |
internal_error | 500 | Unexpected failure. Check your orders before you retry a sell. |
Location refusals
A venue can refuse an order because it must confirm where the user is. The same two codes appear on a buy leg (POST /orders/buy) and on a sell leg, in results[i].rejected_code. Nothing was spent or sold. Today only Novig and BettorEdge classify these refusals; other venues return their usual codes. The refusal can only be known when the venue answers the order, not at preflight.
| Code | Meaning | fix |
|---|---|---|
venue_location_check | The user can fix it. They open the venue's app, sign in and allow location access, then you send the order again as a new confirmation. message_user names the venue's app. details.venue_url is set when the venue has a link for it. | retry |
venue_location_blocked | The venue does not allow trading from the user's location. There is nothing to fix. | none |
Retrying
Safe to retry: 429 (after Retry-After), 500, 503. Use exponential backoff with jitter. On a write, send the same Idempotency-Key so a retry cannot double-place.
Not safe to retry without changes: 400, 404, 409 — fix the input or the state first.
Never retry: 401 and 403. A second attempt with the same credential fails the same way.