Errors and rate limits
The envelope
Section titled “The envelope”Every answer that is not a success is JSON:
{"error": {"code": "RATE_LIMITED", "source": "api", "message": "…", "detail": null, "trace_id": "…"}}code is stable: write your code against it, not against message. source says who refused: api, engine (a rule
of your program) or exec (the market or the simulator). The X-Trace-Id header repeats trace_id: quote it when you
write to us. Answers carry Cache-Control: no-store.
Statuses
Section titled “Statuses”| Status | code |
Meaning |
|---|---|---|
| 400 | VALIDATION_ERROR |
a parameter, header or body not as described: a decimal number, an unknown field, a value out of range, a missing Idempotency-Key. Nothing done |
| 401 | API_KEY_INVALID |
the key is missing, malformed, unknown or revoked (detail.reason CONTRACT_WALLET_REVOKED: see Authentication) |
| 403 | API_KEY_READ_ONLY |
a write with a read key. Nothing done |
| 404 | NOT_FOUND |
the account is not yours (exactly like an unknown one), or the order, the market or the route is unknown |
| 405 | METHOD_NOT_ALLOWED |
the route does not take this method (the Allow header lists those it takes) |
| 409 | ORDER_NOT_OPEN, POSITION_CHANGED, STALE_STATE… |
the order or the position changed since you read it. Nothing done |
| 413 | BODY_TOO_LARGE |
a body over 16,384 bytes |
| 422 | the reason of the refusal, IDEMPOTENCY_KEY_REUSED |
your account’s rules or the market refused (see source), or the key was used for another request. Nothing done |
| 429 | RATE_LIMITED |
over a budget: wait the seconds of the Retry-After header |
| 503 | API_DISABLED |
the API is switched off for the moment |
| 503 | API_TRADING_DISABLED |
trading through the API is switched off for the moment; reads still work. Nothing done |
| 503 | ORDERS_BLOCKED |
new orders are paused by an operator; a reduce-only market or limit order still goes through |
| 503 | OVERLOADED, STORAGE_UNAVAILABLE, SIWE_RPC_UNAVAILABLE |
the service (or the network of the contract wallet that made the key) could not take the request: retry a write with the same Idempotency-Key |
Rate limits
Section titled “Rate limits”| Budget | Limit | Over it |
|---|---|---|
| calls per key (every route, and each stream opening) | 60 a minute | 429 RATE_LIMITED, Retry-After |
| order writes per trader, every key together (place, modify, cancel, close, brackets, reverse, leverage) | 30 a minute | 429 RATE_LIMITED, Retry-After |
| refused keys per client address | 30 a minute | 429, even for a good key not seen before |
| open account streams per trader | 2 | close code 4429 |
An order write counts in both budgets: its trader’s and its key’s. Several keys never make several order budgets.