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

# Create Limit Order

> This endpoint allows users to create a new limit order with optional take profit and stop loss levels.

The [Pacifica Python SDK](https://github.com/pacifica-fi/python-sdk/blob/f2385d42e9ae5276ba2ba85505d51db2eefd2715/rest/create_order.py) provides a comprehensive example on using this endpoint.

```http theme={null}
POST /api/v1/orders/create
```

#### Operation Type (for Signing)

| Header Field | Type   | Content          |
| ------------ | ------ | ---------------- |
| `"type"`     | string | `"create_order"` |

#### Request Body

<table><thead><tr><th width="188">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>"account"</code></td><td>string</td><td>required</td><td>User's wallet address</td><td><code>42trU9A5...</code></td></tr><tr><td><code>"signature"</code></td><td>string</td><td>required</td><td>Cryptographic signature</td><td><code>5j1Vy9Uq...</code></td></tr><tr><td><code>"timestamp"</code></td><td>integer</td><td>required</td><td>Current timestamp in milliseconds</td><td><code>1716200000000</code></td></tr><tr><td><code>"symbol"</code></td><td>string</td><td>required</td><td>Trading pair symbol</td><td><code>BTC</code></td></tr><tr><td><code>"price"</code></td><td>string</td><td>required</td><td>Order price</td><td><code>50000</code></td></tr><tr><td><code>"amount"</code></td><td>string</td><td>required</td><td>Order amount</td><td><code>0.1</code></td></tr><tr><td><code>"side"</code></td><td>string</td><td>required</td><td>Order side (bid/ask)</td><td><code>bid</code></td></tr><tr><td><code>"tif"</code></td><td>string</td><td>required</td><td>Time in force (<code>GTC</code>, <code>IOC</code>, <code>ALO</code>, <code>TOB</code>; case-insensitive)</td><td><code>GTC</code></td></tr><tr><td><code>"reduce\_only"</code></td><td>boolean</td><td>required</td><td>Whether the order is reduce-only</td><td><code>false</code></td></tr><tr><td><code>"client\_order\_id"</code></td><td>Full UUID string</td><td>optional</td><td>Client-defined order ID</td><td><code>f47ac10b-58cc-4372-a567-0e02b2c3d479</code></td></tr><tr><td><code>"take\_profit"</code></td><td>object</td><td>optional</td><td>Take profit stop order configuration</td><td>See next five rows</td></tr><tr><td><code>"stop\_price"</code></td><td>string</td><td>required</td><td>Stop trigger price</td><td><code>55000</code></td></tr><tr><td><code>"limit\_price"</code></td><td>string</td><td>optional</td><td>Limit price for the triggered order</td><td><code>54950</code></td></tr><tr><td><code>"client\_order\_id"</code></td><td>Full UUID string</td><td>optional</td><td>Client-defined order ID for the stop order</td><td><code>e36ac10b-58cc-4372-a567-0e02b2c3d479</code></td></tr><tr><td><code>"trigger\_price\_type"</code></td><td>string</td><td>optional</td><td>Price type used to trigger the stop order. Defaults to <code>last\_trade\_price</code>. Options: <code>mark\_price</code>, <code>last\_trade\_price</code>, <code>mid\_price</code></td><td><code>mark\_price</code></td></tr><tr><td><code>"amount"</code></td><td>string</td><td>optional</td><td>Order amount for the triggered order. If omitted, the full position size is used</td><td><code>0.1</code></td></tr><tr><td><code>"stop\_loss"</code></td><td>object</td><td>optional</td><td>Stop loss order configuration</td><td>See next five rows</td></tr><tr><td><code>"stop\_price"</code></td><td>string</td><td>required</td><td>Stop trigger price</td><td><code>48000</code></td></tr><tr><td><code>"limit\_price"</code></td><td>string</td><td>optional</td><td>Limit price for the triggered order</td><td><code>47950</code></td></tr><tr><td><code>"client\_order\_id"</code></td><td>Full UUID string</td><td>optional</td><td>Client-defined order ID for the stop order</td><td><code>d25ac10b-58cc-4372-a567-0e02b2c3d479</code></td></tr><tr><td><code>"trigger\_price\_type"</code></td><td>string</td><td>optional</td><td>Price type used to trigger the stop order. Defaults to <code>last\_trade\_price</code>. Options: <code>mark\_price</code>, <code>last\_trade\_price</code>, <code>mid\_price</code></td><td><code>mark\_price</code></td></tr><tr><td><code>"amount"</code></td><td>string</td><td>optional</td><td>Order amount for the triggered order. If omitted, the full position size is used</td><td><code>0.1</code></td></tr><tr><td><code>"agent\_wallet"</code></td><td>string</td><td>optional</td><td>Agent wallet address</td><td><code>69trU9A5...</code></td></tr><tr><td><code>"expiry\_window"</code></td><td>integer</td><td>optional</td><td>Signature expiry in milliseconds</td><td><code>30000</code></td></tr><tr><td><code>"builder\_code"</code></td><td>string</td><td>optional</td><td>Builder program code (3-16 alphanumeric characters)</td><td><code>MYCODE</code></td></tr></tbody></table>

```json theme={null}
{
  "account": "42trU9A5...",
  "signature": "5j1Vy9Uq",
  "timestamp": 1716200000000,
  "symbol": "BTC",
  "price": "50000",
  "amount": "0.1",
  "side": "bid",
  "tif": "GTC",
  "reduce_only": false,
  "client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
  "take_profit": {
    "stop_price": "55000",
    "limit_price": "54950",
    "client_order_id": "e36ac10b-58cc-4372-a567-0e02b2c3d479",
    "trigger_price_type": "mark_price"
  },
  "stop_loss": {
    "stop_price": "48000",
    "limit_price": "47950",
    "client_order_id": "d25ac10b-58cc-4372-a567-0e02b2c3d479",
    "trigger_price_type": "mark_price"
  },
  "agent_wallet": "69trU9A5...",
  "expiry_window": 30000,
  "builder_code": "MYCODE"
}
```

#### Response

* Status 200: Order created successfully

```json theme={null}
  {
    "order_id": 12345
  }
```

* Status 400: Bad request

```json theme={null}
  {
    "error": "Invalid order parameters",
    "code": 400
  }
```

* Status 500: Internal server error

#### Code Example (Python)

```python theme={null}
import requests

payload = {
    "account": "42trU9A5...",
    "signature": "5j1Vy9Uq...",
    "timestamp": 1716200000000,
    "symbol": "BTC",
    "price": "50000",
    "amount": "0.1",
    "side": "bid",
    "tif": "GTC",
    "reduce_only": False,
    "client_order_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479"
}

response = requests.post(
    "/api/v1/orders/create",
    json=payload,
    headers={"Content-Type": "application/json"}
)

data = response.json()
```

Note: In order to protect liquidity providers from adverse selection, all TIF GTC, and TIF IOC orders are subject to a \~200ms delay.
