---
title: "private/batch_order"
method: POST
path: "/private/batch_order"
tags: ["Orderbook"]
---

# private/batch_order

`POST /private/batch_order`

## Request

- Base URL: `https://api.derive.xyz/v3`
- URL: `https://api.derive.xyz/v3/private/batch_order`
- Auth: API key in header `X-DeriveWallet` and API key in header `X-DeriveTimestamp` and API key in header `X-DeriveSignature`

Places, replaces and cancels orders for one subaccount in a single request. `orders` holds post-only limit orders and `cancels` holds open orders to cancel, each by order_id and instrument_name; together they hold 1 to 1000 items. Each order is a signed private/order payload; an order that also sets order_id_to_cancel or nonce_to_cancel replaces that open order, which must be on the same instrument. Every order must use the batch subaccount_id, the same signer, time_in_force post_only and order_type limit, with no trigger or algo fields, reduce_only or is_atomic_signing. The batch is checked as a whole first, including margin for all of its orders together; open orders that it cancels or replaces do not count. If a check fails, no order is placed or cancelled, and the error data names the failing order as `index=<n>` or the failing cancel as `cancel index=<n>`. A batch of cancels alone has no margin check. Otherwise, on each instrument the cancels apply before the orders. Returns one result per order with its nonce, order_id, status (open, rejected with its error, or pending if it had no result yet), final limit_price and cancelled_order_id, and one result per cancel with its order_id and status (cancelled, rejected with its error, or pending). A cancel of an order that is not open on the named instrument is rejected and does not affect the rest of the batch. A replace cancels its old order even when the new order is then rejected. A batch costs 50 matching rate-limit points, whatever its size. A batch refused for lack of points costs nothing. Requires Orderbook trade scope for the instrument of every order; a batch of cancels alone requires any trade scope.

## Request body

- BatchOrderRequest: `private/batch_order` params.
  - `cancels` BatchCancelRequest[]: Open orders to cancel. `orders` and `cancels` hold 1 to 1000 items in total.
    - `instrument_name` string, required
    - `order_id` string, uuid, required: UUID v4 string
  - `orders` ReplaceOrderRequest[]: Post-only limit orders, all with the same signer. An order with `order_id_to_cancel` or `nonce_to_cancel` replaces that order.
    - `algo_duration_sec` integer, nullable
    - `algo_num_slices` integer, nullable
    - `algo_type` 'twap', nullable
    - `amount` string, decimal, required: Order amount in units of the base, as a decimal string (e.g. `"1.5"`) or a JSON number.
    - `client` string, nullable
    - `direction` 'buy' | 'sell', required
    - `expected_filled_amount` string, decimal, nullable: Optional decimal string of the human value (e.g. `"1.5"`), up to 12 fractional digits, or null; a string or JSON number is accepted
    - `extra_fee` string, decimal, nullable: Optional builder fee for the whole order, in USDC, as a decimal string or JSON number. Each fill pays its pro-rata share. Defaults to zero.
    - `instrument_name` string, required
    - `is_atomic_signing` boolean, nullable
    - `label` string, nullable
    - `limit_price` string, decimal, required: Limit price in quote currency, as a decimal string (e.g. `"3100.5"`) or a JSON number.
    - `max_fee` string, decimal, required: Max fee per unit of volume in quote currency, as a decimal string or a JSON number.
    - `mmp` boolean, nullable: Tags the order for market maker protection. Only tagged orders are cancelled by cancel on disconnect.
    - `nonce` string, required
    - `nonce_to_cancel` string, nullable
    - `order_id_to_cancel` string, uuid, nullable: Optional UUID v4 string
    - `order_type` 'limit' | 'market'
    - `reduce_only` boolean, nullable
    - `referral_code` string, nullable
    - `reject_post_only` boolean, nullable
    - `reject_timestamp` integer, nullable
    - `signature` string, required
    - `signature_expiry_sec` integer, required
    - `signer` string, required
    - `subaccount_id` integer, required
    - `time_in_force` 'gtc' | 'post_only' | 'fok' | 'ioc'
    - `trigger_price` string, decimal, nullable: Trigger price as a decimal string or JSON number; omit for non-trigger orders.
    - `trigger_price_type` 'mark' | 'index', nullable
    - `trigger_type` 'stoploss' | 'takeprofit', nullable
  - `subaccount_id` integer, required

## Response `200`

Success

- BatchOrderResponse
  - `cancels` BatchCancelResult[], required
    - `error` RPCError, nullable
      - `code` integer, required
      - `data` string, nullable
      - `message` string, required
    - `order_id` string, uuid, required: UUID v4 string
    - `status` union, required
      - 'cancelled'
      - 'rejected': The order was not cancelled; `error` gives the reason.
      - 'pending': The cancel had no result yet when the response was sent.
  - `orders` BatchOrderResult[], required
    - `cancelled_order_id` string, uuid, nullable, required: Optional UUID v4 string
    - `error` RPCError, nullable
      - `code` integer, required
      - `data` string, nullable
      - `message` string, required
    - `limit_price` string, decimal, nullable, required: Final limit price of the order; a post-only order sent with `reject_post_only: false` can rest at a price other than the signed one.
    - `nonce` string, required
    - `order_id` string, uuid, nullable, required: Optional UUID v4 string
    - `status` union, required
      - 'open': The order rests on the book.
      - 'rejected': The order was not placed; `error` gives the reason.
      - 'pending': The order had no result yet when the response was sent.

## Other responses

- `default`: JSON-RPC error (see Error Codes)

## Changes

- **2026-12-03** `415f8a73b10c`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/lyra/apis/derive-v3-api/changes/private/batch_order/post.md)

---

[API](https://skmtc.dev/lyra/apis/derive-v3-api.md) - [All operations](https://skmtc.dev/lyra/apis/derive-v3-api/llms.txt) - [OpenAPI document](https://skmtc.dev/lyra/apis/derive-v3-api/revisions/415f8a73b10c?raw)
