Errors
Every non-2xx body is {"error": "<human message>", "code": "<machine code>"} (the 428 confirmation response carries a few extra fields). Match on code, never on the prose: the message may change; the code will not.
code is drawn from a closed enum that evolves additively: a new refusal class adds a member, but no member is ever renamed or removed (a contract test fails CI on a break). So a client can safely switch on it, and an unknown code means a newer server, so handle it as a generic failure and don't crash.
Status codes
| status | meaning |
|---|---|
400 | validation / insufficient balance or margin |
401 | missing or unknown key |
403 | compliance refusal, insufficient scope, or a program refusal |
404 | unknown market / order / account, or a route not served here |
409 | idempotency or uniqueness conflict |
428 | confirmation required (first-seen withdrawal destination) |
429 | rate limited (see Rate limits) |
501 | feature not wired for this deployment |
503 | deposits halted (never affects withdrawals) or a transient or deployment-level unavailability |
The code vocabulary
The full set, from the spec's ErrorCode enum (the REST reference links it, and /openapi.json carries it verbatim):
| code | status | retryable |
|---|---|---|
body_too_large | 413 | no |
compliance_refused | 403 | no |
confirmation_required | 428 | no |
conflict | 409 | no |
deposits_halted | 503 | yes |
feature_unavailable | 501 | no |
idempotency_key_reused | 409 | no |
insufficient_balance | 400 | no |
insufficient_margin | 400 | no |
insufficient_scope | 403 | no |
internal | 500 | no |
market_halted | 400, 409 | no |
not_found | 404 | no |
oi_cap | 400, 409 | no |
oracle_stale | 400, 409 | no |
position_limit | 400, 409 | no |
rate_limited | 429 | yes |
reduce_only | 400, 409 | no |
referral_forbidden | 403 | no |
session_limit | 403 | no |
size_not_whole_contracts | 400 | no |
token_rail_unavailable | 503 | no |
tvl_cap | 409 | no |
unauthorized | 401 | no |
unavailable | 503 | yes |
usdhb_capacity | 409 | no |
usdhb_dust | 409 | no |
usdhb_mints_halted | 409 | no |
usdhb_oracle_stale | 409 | no |
usdhb_quote_expired | 409 | no |
usdhb_requote | 409 | no |
usdhb_whole_units | 409 | no |
validation | 400 | no |
The status a given code rides can vary with context; the code is the stable signal. Build against code. A retryable code means the identical request may succeed later (back off first; honor Retry-After on a 429); every other code needs a changed request or a changed account state. The table is generated from the spec's x-hardbasis-errors map in /openapi.json, which carries the same statuses and retry flag per code.