Errors and rate limits¶
Every error returns an HTTP status and a body with error.code and error.message. Use error.code in your code; the message is for people to read and can change.
Wallet and user profile return "success": false instead of "status": "error", with the same error object.
Error codes¶
| HTTP | Code | Endpoints | Meaning | What to do |
|---|---|---|---|---|
| 400 | invalid_order_payload | Place | A field is missing, not recognised or invalid; an order rule isn't met; a bracket price is outside its range; or the stock can't be traded right now | Fix the request; see order rules |
| 400 | invalid_payload | Place, cancel | The body isn't valid JSON, or a number was sent as a string | Fix the request |
| 400 | invalid_query | Order book, portfolio | Unknown, repeated or invalid query parameter | Fix the query |
| 400 | invalid_security_id | Place | Unknown security_id | Check Instruments |
| 400 | no_position | Place (SELL) | You don't hold this stock | Check Portfolio |
| 400 | insufficient_balance | Place | Not enough trading balance; the order is recorded as REJECTED | Add funds or reduce the order |
| 400 | DataException | Quotes | Invalid security_ids or mode | Fix the request |
| 401 | api_authentication_failed | Orders, portfolio, wallet, profile | Token missing, expired, replaced or revoked | Generate a new token |
| 403 | TokenException | Market data | Token missing, expired, replaced or revoked | Generate a new token |
| 403 | account_not_tradable | Place | Your US stocks account isn't OPEN | Check User profile |
| 403 | trading_blocked | Place | This order can't be placed right now: the market is closed for this order type, a corporate action is in progress, or your account has a restriction | Try later or change the order |
| 403 | restricted_stock | Place | This stock can't be bought | Choose another stock |
| 403 | limit_orders_not_enabled | Place | LIMIT orders aren't enabled for your account yet | Use MARKET or contact support |
| 404 | route_not_found or none | Any | Wrong path, or the order doesn't exist or isn't yours | Check the path and order_id |
| 405 | method_not_allowed | Any | Wrong HTTP method for this path | Use the method shown in these docs |
| 409 | invalid_order_state | Cancel | The order can't be cancelled now, for example because it is already filled or cancelled | Read the order |
| 409 | pending_broker_confirmation | Cancel | The order is still being processed | Wait a few seconds and try again |
| 429 | rate_limit_exceeded | Orders, portfolio, wallet, profile | Over the rate limit | Wait for Retry-After |
| 429 | RateLimitException | Market data | Over 5 calls per second | Wait for Retry-After |
| 500 | InternalException | Market data | Server error | Try again after a short wait |
| 503 | order_outcome_unknown | Place, cancel | We couldn't confirm the result | Check the order book before you send the request again |
| 503 | security_unavailable | Place, orders, portfolio | Instrument details are temporarily unavailable | Try again after a short wait |
| 503 | order_unavailable | Place, cancel, get order | Temporarily unavailable | Try again after a short wait |
| 503 | orders_unavailable | Order book | Temporarily unavailable | Try again after a short wait |
| 503 | account_unavailable | Place, cancel, portfolio | Temporarily unavailable | Try again after a short wait |
| 503 | position_unavailable | Place (SELL), portfolio | Holdings are temporarily unavailable | Try again after a short wait |
| 502 / 503 | wallet_unavailable | Wallet | Balances are temporarily unavailable | Try again after a short wait |
Retrying requests¶
Each place request creates a new order, so sending the same request twice places two orders.
- 400, 401, 403, 404, 409: fix the cause before you try again.
- 429: wait the number of seconds in
Retry-After, then try again. - 503
order_outcome_unknown, a timeout, or a dropped connection on place or cancel: check the order book or the order to see whether your request went through before you send it again. - Other 503s and 500: your request wasn't processed. Try again after a short wait.
Rate limits¶
Limits apply per user.
| Endpoint | Limit |
|---|---|
| Place order | 5 per minute, and at most 5 per second |
| Cancel order | 5 per minute |
| Order book + Get order | 10 per minute, shared |
| Portfolio | 10 per minute |
| Wallet | 10 per minute |
| User profile | 10 per minute |
| Market status, instruments, quotes | 5 per second each |