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

# Batch Order

> This endpoint allows users to submit multiple order operations in a single websocket request.

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

### Request

```json theme={null}
{
  "id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
  "params": {
    "batch_orders": {
      "actions": [
        {
          "type": "Create",
          "data": {
            "account": "42trU9A5...",
            "signature": "5UpRZ14Q...",
            "timestamp": 1749190500355,
            "expiry_window": 5000,
            "symbol": "BTC",
            "price": "100000",
            "reduce_only": false,
            "amount": "0.1",
            "side": "bid",
            "tif": "GTC",
            "client_order_id": "57a5efb1-bb96-49a5-8bfd-f25d5f22bc7e"
          }
        },
        {
          "type": "CreateMarket",
          "data": {
            "account": "42trU9A5...",
            "signature": "3KxMn7pQ...",
            "timestamp": 1749190500355,
            "expiry_window": 5000,
            "symbol": "ETH",
            "amount": "1.0",
            "side": "ask",
            "slippage_percent": "0.5",
            "reduce_only": false
          }
        },
        {
          "type": "Cancel",
          "data": {
            "account": "42trU9A5...",
            "signature": "4NDFHyTG...",
            "timestamp": 1749190500355,
            "expiry_window": 5000,
            "symbol": "SOL",
            "order_id": 42069
          }
        }
      ]
    }
  }
}
```

<table><thead><tr><th width="118">Field</th><th width="98">Type</th><th width="95">Need</th><th>Description</th><th>Example</th></tr></thead><tbody><tr><td><code>"id"</code></td><td>Full UUID string</td><td>required</td><td>Client-defined request ID</td><td>660065de-8f32-46ad-ba1e-83c93d3e3966</td></tr><tr><td><code>"actions"</code></td><td>array</td><td>required</td><td>List of order actions to perform<br /><br />Each action has a "type" field and action-specific "data"</td><td>See next two rows</td></tr><tr><td><code>"type"</code></td><td>string</td><td>required</td><td>Specifies type of action. This is DIFFERENT to the "type" used in signature headers</td><td><p><code>"Create"</code><br /><code>"CreateMarket"</code><br /><code>"Cancel"</code><br /><code>"Edit"</code><br /><code>"SetPositionTpsl"</code><br /><code>"CancelStopOrder"</code></p><p><br />(case sensitive)</p></td></tr><tr><td><code>"data"</code></td><td>object</td><td>required</td><td>Contains signed request payloads of individual actions. Fields are identical to the corresponding standalone endpoints: create limit order, create market order, cancel order, edit order, create position TP/SL, and cancel stop order.</td><td>See code block below. Messages and corresponding fields are identical to <a href="/api-documentation/api/rest-api/orders/create-limit-order">create</a> and <a href="/api-documentation/api/rest-api/orders/cancel-order">cancel</a> requests.</td></tr></tbody></table>

#### Response

* Status 200: Batch operations processed successfully

```json theme={null}
{
  "code": 200,
  "data": {
    "results": [
      {
        "success": true,
        "order_id": 645953,
        "error": null
      },
      {
        "success": false,
        "order_id": null,
        "error": "Order not found"
      }
    ]
  },
  "id": "660065de-8f32-46ad-ba1e-83c93d3e3966",
  "t": 1749223025962,
  "type": "batch_orders",
  "rl": {
    "r": 9980,
    "q": 10000,
    "t": 1000
  }
}
```

Each entry in `results` corresponds positionally to an action in the request `actions` array, and has the following fields:

| Field        | Type            | Description                                             |
| ------------ | --------------- | ------------------------------------------------------- |
| `'success'`  | boolean         | Whether the individual action succeeded                 |
| `'order_id'` | integer or null | Resulting order ID (null for cancels or failed actions) |
| `'error'`    | string or null  | Error message if the action failed, otherwise null      |

The top-level frame also includes the always-present `rl` (rate-limit) object: `r` = credits remaining, `q` = quota, `t` = reset-in (ms).

* Status 400: Bad request

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

* Status 500: Internal server error

### Notes on Batch Ordering

#### Speed Bump (Latency Protection)

Batch orders are subject to a conditional randomized \~200ms (190-210ms) delay to protect liquidity providers from adverse selection:\
\
Speed bump is applied if the batch contains:

* Market orders (CreateMarket)
* Limit orders with TIF = GTC or IOC

Speed bump is NOT applied if the batch only contains:

* Add Liquidity Only orders (TIF = ALO)
* Top of Book orders (TIF = TOB)
* Cancel operations
* TP/SL operations

#### Signature Requirements

* Each action in the batch must be individually signed
* All signatures must be valid for the batch to process

#### Execution Behavior and Limits

* Maximum 10 actions per batch request
* Actions are executed atomically in the order provided
* If one action fails, subsequent actions are still attempted
