> ## 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.

# Order Creation

> Understanding order types and creation workflows

## Create Order via WebSocket

To create orders on Rails platform, use the [WebSocket](/latest/perps/websocket-api/overview) API and subscribe to the [Order Creation Stream](/latest/perps/websocket-api/order-creation-stream).
The specifications and behavior remain the same.

## Order Creation Workflow

Order creation is done by submitting a [Create Order](/latest/perps/websocket-api/order-creation-stream/create-order) request. You will receive two responses in sequence:

* **Acknowledgment**: Confirms the request was received and validates basic parameters
* **Confirmation**: Confirms the order was accepted and created in the order book

Key differences:

|                | Acknowledgment                      | Confirmation     |
| -------------- | ----------------------------------- | ---------------- |
| Body           | `order created, pending acceptance` | `order accepted` |
| Order Status   | `pending`                           | `active`         |
| Status Code    | `202`                               | `200`            |
| API Quota Used | Included                            | Not included     |

Note that a unique `clientRequestId` can be used to correlate acknowledgment, confirmation, and any error responses for a single request.

## Order Types

### Limit Orders

Limit orders allow you to specify an exact price at which you want to trade. They provide price certainty but execution is not guaranteed.

**Key Characteristics:**

* Order executes only at the specified price or better
* May remain open in the order book until filled or cancelled
* Can use post-only option to ensure maker status

**Post-Only Option:** When set to `true`, the order will only be created if it *does not* match with an existing order in the order book. This ensures you are always the maker and never the taker. If the order would match immediately, you'll receive normal acknowledgment and confirmation responses, but followed by [Order Rejected Notifications](/latest/perps/websocket-api/order-creation-stream/order-rejected-notifications).

### Market Orders

Market orders prioritize execution speed over price certainty. They execute immediately against the best available prices in the order book.

**Key Characteristics:**

* Execute immediately at the best available market prices
* Use `maxSlippage` parameter to control price deviation (defaults to 0.02)
* Any unfilled quantity is automatically cancelled after execution

**Slippage Protection:**

* **Buy orders**: Fill price never exceeds `expectedPrice × (1 + maxSlippage)`
* **Sell orders**: Fill price never goes below `expectedPrice × (1 - maxSlippage)`

**Request Field Differences from Limit Orders:**

| Field         | Limit Order Value | Market Order Value |
| ------------- | ----------------- | ------------------ |
| `tradeType`   | `limit`           | `market`           |
| `postOnly`    | `true` or `false` | Not supported      |
| `maxSlippage` | Not supported     | `0 - 1` inclusive  |
| `price`       | Strict price      | Expected price     |

### IOC (Immediate-Or-Cancel) Orders

IOC orders can be achieved by creating a market order with `maxSlippage` of `0`. They execute as much as possible immediately and cancel any unfilled portion.

## Order Limits and Restrictions

### Maximum Open Orders Per Market

See [Rate Limits](/latest/perps/guides/rate-limits#maximum-open-orders-per-market) page for details.

### Price and Quantity Restrictions

* **Price bounds**: Orders must be within 50% of current index price
* **Market-specific limits**: Each market has tick size, lot size, and minimum order value requirements. See [Product Specifications](/latest/perps/guides/market-data#product-specifications) for details.

### Receive Window

All order creation requests must be processed within a 2-second receive window. Requests exceeding this timeframe are rejected with error message `receive window exceeded, order rejected`.

**Key points:**

* Only applies to order creation and modification, not cancellation
* Frequent rejections may indicate that you are submitting requests too quickly
* Reduce submission rate when encountering this error

## Margin Mode and Leverage

Both margin mode and leverage are applied at the market level rather than per-trade. All positions within the same market share the same margin mode and leverage, and each market can be configured independently.

### Margin Mode

* Supported values: `C` (cross margin) and `I` (isolated margin)
* Default margin mode is `C` (cross) if not explicitly set
* Update margin mode using the [Update Margin Mode](/latest/perps/rest-api/update-margin-mode) REST endpoint
* See [Risk Management](/latest/perps/guides/risk-management) for how each mode affects liquidation and collateral

### Leverage

* Supported values: `1`, `2`, `3`, `4`, `5`
* Default leverage is `1` if not explicitly set
* Update leverage using the [Update Leverage](/latest/perps/rest-api/update-leverage) REST endpoint
