> ## Documentation Index
> Fetch the complete documentation index at: https://docs.rails.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Error Codes

> Error codes returned by the Perpetuals order, margin and leverage routes.

Every Perpetuals error carries `error.slug` and `error.code` next to its human-readable text; the [Error Reference](/latest/error-reference/error-code) describes the shape per transport and the codes `0001`–`0014` shared by every route. The codes below belong to one route each: `1xxx` `createOrder`, `2xxx` `cancelOrder`, `3xxx` `modifyOrder`, `6xxx` `rejectOrder`, `7xxx` `updateLeverage`, `8xxx` `updateMargin`, `9xxx` `updateMarginMode`.

## createOrder

| Error Code | Error Slug                               | Server Status Code | Meaning                                                                                                                                        |
| ---------- | ---------------------------------------- | ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| **1000**   | **CREATE\_ORDER\_ERROR**                 | `400`, `500`       | A create failure none of the codes below names.                                                                                                |
| **1001**   | **CREATE\_ORDER\_INSUFFICIENT\_BALANCE** | `400`              | Available balance does not cover the order's margin.                                                                                           |
| **1002**   | **CREATE\_ORDER\_INVALID\_TRADE**        | `400`              | A trading rule none of the codes below names, for example a bad price or quantity.                                                             |
| **1003**   | **CREATE\_ORDER\_RECEIVE\_WINDOW**       | `400`              | The order reached the engine after the [receive window](/latest/perps/guides/order-creation#receive-window) and was rejected.                  |
| **1004**   | **CREATE\_ORDER\_MAX\_OPEN\_ORDERS**     | `400`              | The [per-market open-orders cap](/latest/perps/guides/rate-limits#maximum-open-orders-per-market) is reached.                                  |
| **1005**   | **CREATE\_ORDER\_BANNED**                | `403`              | An [order creation ban](/latest/perps/guides/rate-limits#order-creation-ban-cancellation-only) is in force; `retryAfterSec` says for how long. |
| **1006**   | **CREATE\_ORDER\_REDUCE\_ONLY**          | `400`              | A reduce-only rule: there is no open position, or the quantity exceeds it.                                                                     |
| **1007**   | **CREATE\_ORDER\_SELF\_TRADE**           | `400`              | The order would trade against one of your own resting orders.                                                                                  |
| **1008**   | **CREATE\_ORDER\_PRICE\_BAND**           | `400`              | The price is too far from the mark or index price.                                                                                             |
| **1009**   | **CREATE\_ORDER\_CONFLICT**              | `409`              | The order's state moved on while the command was in flight. Look the order up before deciding what to do.                                      |

## cancelOrder

| Error Code | Error Slug                             | Server Status Code | Meaning                                                                                                      |
| ---------- | -------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------ |
| **2000**   | **CANCEL\_ORDER\_ERROR**               | `400`, `500`       | A cancel failure none of the codes below names.                                                              |
| **2001**   | **CANCEL\_ORDER\_CONFLICT\_ERROR**     | `409`              | The cancel lost a race with a fill or another update and was not applied. Send it again as is.               |
| **2002**   | **CANCEL\_ORDER\_ALREADY\_CANCELLING** | `409`              | Another cancel of the same order is already in flight; its answer follows on this connection. Do not resend. |
| **2003**   | **CANCEL\_ORDER\_NOT\_CANCELLABLE**    | `400`, `409`       | The order is filled, cancelled, rejected, or a liquidation order. Nothing to cancel.                         |

## modifyOrder

| Error Code | Error Slug                               | Server Status Code | Meaning                                                                    |
| ---------- | ---------------------------------------- | ------------------ | -------------------------------------------------------------------------- |
| **3000**   | **MODIFY\_ORDER\_ERROR**                 | `400`, `500`       | A modify failure none of the codes below names.                            |
| **3001**   | **MODIFY\_ORDER\_INSUFFICIENT\_BALANCE** | `400`              | Available balance does not cover the modified order's margin.              |
| **3002**   | **MODIFY\_ORDER\_INVALID\_TRADE**        | `400`              | A trading rule none of the codes below names.                              |
| **3003**   | **MODIFY\_ORDER\_NOT\_FOUND\_ERROR**     | `404`              | No order with that id for this account.                                    |
| **3004**   | **MODIFY\_ORDER\_CONFLICT\_ERROR**       | `409`              | The modify lost a race with another update and was not applied.            |
| **3005**   | **MODIFY\_ORDER\_NOT\_ACTIVE**           | `400`, `409`       | Only an `active` order can be modified.                                    |
| **3006**   | **MODIFY\_ORDER\_RECEIVE\_WINDOW**       | `400`              | The replacement order reached the engine after the receive window.         |
| **3007**   | **MODIFY\_ORDER\_MAX\_OPEN\_ORDERS**     | `400`              | The replacement order would exceed the per-market open-orders cap.         |
| **3008**   | **MODIFY\_ORDER\_REDUCE\_ONLY**          | `400`              | A reduce-only rule on the replacement order.                               |
| **3009**   | **MODIFY\_ORDER\_WOULD\_MATCH**          | `400`              | The modified post-only price would take liquidity.                         |
| **3010**   | **PARTIAL\_FILL\_ORDER\_ERROR**          | `500`              | Internal failure while recording a partial fill.                           |
| **3011**   | **MODIFY\_ORDER\_STATE\_CHANGED**        | `409`              | The original order filled or was cancelled while the modify was in flight. |
| **3012**   | **MODIFY\_ORDER\_SELF\_TRADE**           | `400`              | The replacement order would trade against one of your own resting orders.  |
| **3013**   | **MODIFY\_ORDER\_PRICE\_BAND**           | `400`              | The modified price is too far from the mark or index price.                |
| **3020**   | **COMPLETE\_FILL\_ORDER\_ERROR**         | `500`              | Internal failure while recording a complete fill.                          |

## rejectOrder

Pushed after an order was accepted, on the [Order Creation Stream](/latest/perps/websocket-api/order-creation-stream).

| Error Code | Error Slug                      | Server Status Code | Meaning                                                            |
| ---------- | ------------------------------- | ------------------ | ------------------------------------------------------------------ |
| **6000**   | **ORDER\_REJECTED**             | `400`, `500`       | A rejection none of the codes below names.                         |
| **6001**   | **ORDER\_REJECTED\_POST\_ONLY** | `400`              | A post-only order would have matched immediately and was rejected. |

## updateLeverage

| Error Code | Error Slug                         | Server Status Code | Meaning                                                   |
| ---------- | ---------------------------------- | ------------------ | --------------------------------------------------------- |
| **7000**   | **UPDATE\_LEVERAGE\_ERROR**        | `400`, `500`       | A leverage update failure none of the codes below names.  |
| **7001**   | **UPDATE\_LEVERAGE\_ALREADY\_SET** | `400`              | The market already uses the requested leverage.           |
| **7002**   | **UPDATE\_LEVERAGE\_NOT\_ALLOWED** | `400`              | Open positions or orders in the market forbid the change. |

## updateMargin

| Error Code | Error Slug                             | Server Status Code | Meaning                                                                              |
| ---------- | -------------------------------------- | ------------------ | ------------------------------------------------------------------------------------ |
| **8000**   | **UPDATE\_MARGIN\_ERROR**              | `400`, `500`       | A margin update failure none of the codes below names.                               |
| **8001**   | **UPDATE\_MARGIN\_NO\_POSITION**       | `400`              | No position in the market.                                                           |
| **8002**   | **UPDATE\_MARGIN\_NOT\_ISOLATED**      | `400`              | Margin can only be updated on an isolated-margin position.                           |
| **8003**   | **UPDATE\_MARGIN\_EXCEEDS\_AVAILABLE** | `400`              | The increase exceeds available balance.                                              |
| **8004**   | **UPDATE\_MARGIN\_BELOW\_MINIMUM**     | `400`              | The decrease would leave less than the minimum required margin.                      |
| **8005**   | **UPDATE\_MARGIN\_CONFLICT**           | `409`              | The position's margin was updated by another request in the meantime. Send it again. |

## updateMarginMode

| Error Code | Error Slug                                | Server Status Code | Meaning                                                   |
| ---------- | ----------------------------------------- | ------------------ | --------------------------------------------------------- |
| **9001**   | **UPDATE\_MARGIN\_MODE\_MARKET\_IN\_USE** | `400`              | Open positions or orders in the market forbid the change. |
