---
title: "Bulk orders"
description: "Create, cancel or cancel-replace several orders of one sub-account in one call."
---

A cancel-replace cancels the old order and creates a new one with a new `order_id`. The reply comes before the exchange assigns that id, so follow the new order by its `client_order_id` on the [order stream](../streams/order.md) or with [get_order](get_order.md).

**Rules**

- Up to 100 entries in each of `orders`, `order_i_ds` and `client_order_i_ds`.
- Every order to create must be on the same instrument.
- The orders to create must all have different `client_order_id`s.
- Send `order_i_ds` or `client_order_i_ds`, not both: a request with both is rejected.
- Rate limits: each order created counts as one `create_order` call; the cancels together count as one `cancel_order` call.

**Create**

Fill in `orders` only; leave `order_i_ds` and `client_order_i_ds` empty. One request can't mix several ordinary orders with trigger orders (take-profit and stop-loss).

To make an order a take-profit (TP) or stop-loss (SL), set its `metadata.trigger` ([TriggerOrderMetadata](../types.md#triggerordermetadata)).

A parent order is an ordinary order whose linked TP/SL orders become active once the parent is fully filled.

Supported combinations:

- **Ordinary orders**: one or more.
- **Standalone TP**: 1 TP order.
- **Standalone SL**: 1 SL order.
- **OCO** (one cancels the other; 2 orders: 1 TP + 1 SL): same instrument, size and side.
- **OTO** (one triggers the other; 2 orders: parent + 1 TP or SL): same instrument and size; the parent's side is the opposite of the trigger's.
- **OTOCO** (3 orders: parent + TP + SL): same instrument and size for all three; the parent's side is the opposite of the TP's and SL's.

**Cancel**

Leave `orders` empty and fill in `order_i_ds` or `client_order_i_ds`. You can name ordinary orders, standalone TP/SL orders, or any order of an OCO, OTO or OTOCO group. Naming any order of a group cancels the whole group.

**Cancel-replace**

Fill in `orders` together with `order_i_ds` or `client_order_i_ds`. The ids below are entries in whichever id list you use.

*Ordinary orders*: all the cancels run first, then all the creates.

*TP/SL orders*: send as many creates as cancels, and change only one group per request. In OTO and OTOCO groups only the TP/SL part can be replaced: leave the parent out of `orders` and out of the id list, and it stays on the book unchanged.

- **Standalone TP or SL**: cancel its id and create 1 new order with the same `trigger_type`.
- **OCO**: cancel both ids (TP and SL) and create 1 new TP and 1 new SL, shaped as for an OCO create.
- **OTO**: cancel the trigger order's id and create 1 new trigger order. It is linked to the same parent.
- **OTOCO**: cancel both ids (TP and SL) and create 1 new TP and 1 new SL, shaped as for an OCO create. They are linked to the same parent.

| | |
|---|---|
| SDK | `client.bulk_orders(...)` |
| HTTP | `POST https://trades.<domain>/full/v2/bulk_orders`, or `/lite/v2/bulk_orders` for [lite names](../../guides/environments.md#encoding-full-or-lite) (the SDKs' default) |
| WebSocket | method `v2/bulk_orders` on `wss://trades.<domain>/ws/full`, or `/ws/lite` for lite names |
| Auth | Session required ([Authentication](../../guides/authentication.md)) |
| Signed | `orders[].signature` is signed: every element of `orders` separately, with its own nonce and expiration (the field tables' `order.` paths mean that element): [`Order`](../signing/Order.md) / [`OrderWithBuilderFee`](../signing/OrderWithBuilderFee.md). Each order is signed on its own, like create_order: OrderWithBuilderFee when that order's builder is set to a non-zero address, otherwise Order. The cancel lists and time_to_live_ms are not signed. ([Signing](../../guides/signing.md)) |
| Retries | Write: never retried automatically ([why](../../guides/errors-and-retries.md)) |
| Contract id | `order.bulk_orders` (`RPCBulkOrdersV2`) |

## Request

Body type `ApiBulkOrdersRequest`. Fields the server fills are left out.

- `sub_account_id` · lite `sa` · string (uint64) · required — The sub-account ID of the user creating the request
- `orders` · lite `o` · object Order[] · optional — Orders to create or replace, supply up to 100 orders
- `orders[].sub_account_id` · lite `sa` · string (uint64) · required — The sub-account placing the order.
- `orders[].is_market` · lite `im` · bool · optional, default `false` — True for a market order. A market order has no limit price, never rests on the book and fills at the prices of the resting orders it meets.

  On STABLE_PERP a slippage bound is mandatory: `limit_price` must carry the signed bound (reference price ± the chosen slippage), or the order is rejected (`STABLE_PERP_REQUIRES_PRICE_BOUND`). There, `is_market` = false with a limit price behaves the same; the flag only records intent.
- `orders[].time_in_force` · lite `ti` · enum TimeInForce · required — How long the order stays open and whether it may fill partly. The order book takes `GOOD_TILL_TIME`, `IMMEDIATE_OR_CANCEL`, `FILL_OR_KILL` and `RETAIL_PRICE_IMPROVEMENT`. An RFQ maker quote uses `GOOD_TILL_TIME` or `ALL_OR_NONE`; an RFQ taker uses `IMMEDIATE_OR_CANCEL` or `FILL_OR_KILL`.
  Values: `GOOD_TILL_TIME`, `ALL_OR_NONE`, `IMMEDIATE_OR_CANCEL`, `FILL_OR_KILL`, `RETAIL_PRICE_IMPROVEMENT` ([details](../enums.md#timeinforce)).
- `orders[].post_only` · lite `po` · bool · optional, default `false` — If true, the order must rest on the book as a maker order: if it would match at once, it is rejected (`FAIL_POST_ONLY`). A market, `IMMEDIATE_OR_CANCEL` or `FILL_OR_KILL` order cannot be post-only.

  If false, the order may take or make liquidity. Such orders can be held for a short speed bump before matching, so they meet up-to-date quotes; the exchange sets the delay, and it can differ per instrument.
- `orders[].reduce_only` · lite `ro` · bool · optional, default `false` — If true, the order may only reduce your position; the part that would increase it is cancelled.
- `orders[].legs` · lite `l` · object OrderLeg[] · required — What to trade. Send exactly one leg: the order book rejects orders with more than one (`MULTI_LEGGED_ORDER`).
- `orders[].legs[].instrument` · lite `i` · string (instrument name) · required — The instrument to trade, e.g. `BTC_USDT_Perp`.
- `orders[].legs[].size` · lite `s` · string · required — How much to trade, in the base asset. Decimal string, e.g. "0.01"; up to the instrument's base_decimals and a multiple of its minimum size. Scaled to an integer only inside the signature.
- `orders[].legs[].limit_price` · lite `lp` · string · optional, default `0` — The worst price you accept, in the quote currency per unit. Decimal string, e.g. "65000.5"; up to 9 decimals and a multiple of the instrument's tick size. Scaled to an integer only inside the signature.

  Leave it out (or `"0"`) on a market order. Exception: a STABLE_PERP market order must carry the signed slippage bound (reference price ± the chosen slippage) here.
- `orders[].legs[].is_buying_asset` · lite `ib` · bool · required — True to buy, false to sell.
- `orders[].signature` · lite `s` · object Signature · required — The EIP-712 signature that authorises this order. The SDKs fill it in; the Signing guide shows how to build it yourself.
- `orders[].signature.signer` · lite `s` · string (uint256) · required — The address of the wallet that signed (`0x` + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
- `orders[].signature.r` · lite `r` · string (uint256) · required — The signature's `r`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `orders[].signature.s` · lite `s1` · string (uint256) · required — The signature's `s`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `orders[].signature.v` · lite `v` · integer (uint8) · required — The signature's `v`, 27 or 28.
- `orders[].signature.expiration` · lite `e` · string (int64 unix ns) · required — When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with `2001`. On an order it is also the order's lifetime: an order still open then is cancelled with reason `EXPIRED`. The SDKs use now + 24 hours.
- `orders[].signature.nonce` · lite `n` · integer (uint32) · required — A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

  A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with `4007`.

  Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent `IMMEDIATE_OR_CANCEL` order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.
- `orders[].signature.chain_id` · lite `ci` · string (uint64) · required — The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; `"0"` means the environment's chain id.
- `orders[].metadata` · lite `m` · object OrderMetadata · required — Unsigned data the exchange uses but the chain never sees, such as your `client_order_id`.
- `orders[].metadata.client_order_id` · lite `co` · string (uint64) · required — Your own id for the order, to find or cancel it later. Any non-zero uint64 (`0` fails with `2011`) that none of the sub-account's open orders uses, take-profit and stop-loss orders waiting for their price included: a duplicate fails with `2012` (or is rejected with `OVERLAPPING_CLIENT_ORDER_ID`), and repeating the sub-account's last client order id fails with `2013`. After an order closes, its id is accepted again, so use a new id for each order.

  The Grvt web app picks ids below 2^63, so ids from 2^63 up never clash with orders placed there. That is a convention, not a rule the exchange checks. The SDKs set one for you when you leave it out. Not signed and not sent on chain.
- `orders[].metadata.trigger` · lite `t` · object TriggerOrderMetadata · optional — Trigger fields are used to support any type of trigger order such as TP/SL
- `orders[].metadata.trigger.trigger_type` · lite `tt` · enum TriggerType · required — Type of the trigger order. eg: Take Profit, Stop Loss, etc
  Values: `UNSPECIFIED`, `TAKE_PROFIT`, `STOP_LOSS` ([details](../enums.md#triggertype)).
- `orders[].metadata.trigger.tpsl` · lite `t` · object TPSLOrderMetadata · required — Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders.
  Fields: see [TPSLOrderMetadata](../types.md#tpslordermetadata).
- `orders[].metadata.broker` · lite `b` · enum BrokerTag · optional — Specifies the broker who brokered the order
  Values: `UNSPECIFIED`, `COIN_ROUTES`, `ALERTATRON`, `ORIGAMI` ([details](../enums.md#brokertag)).
- `orders[].metadata.is_ecn` · lite `ie` · bool · optional, default `false` — Marks an ECN order, eligible for market maker last look. Only on STABLE_PERP instruments, for qualified market makers.
- `orders[].metadata.slippage_bps` · lite `sb` · integer (uint16) · optional, default `0` — Maximum slippage from the mark price for an `IMMEDIATE_OR_CANCEL` limit order, in basis points (800 = 8%). Only valid on IOC limit orders; 0 means no slippage protection.
- `orders[].metadata.rfq_id` · lite `ri` · string (uint128) · optional — Binds this order to an RFQ (see ApiCreateRfqRequest and the `v1.rfq` / `v1.quote` streams). Optional.

  As a taker acceptance: unlocks that RFQ's private quote pool, so the order matches across the private pool merged with the public book (firm resting liquidity + public quotes). The acceptance must be a single-leg order with time_in_force = IOC or FOK. Setting `rfq_id` on a non-ECN GTT order is rejected. If the referenced RFQ has expired, been cancelled, or is unknown, the order is rejected.

  As a maker quote (is_ecn = true): identifies which RFQ the quote is responding to.

  Omit `rfq_id` to match the public book only — private RFQ liquidity requires an RFQ.
- `orders[].metadata.is_private` · lite `ip1` · bool · optional, default `false` — Maker quotes only. true = a private quote delivered to a single RFQ's taker (appears only on that taker's `v1.quote` book); false = a public quote resting on the order book, visible to all. When true, `rfq_id` is required.
- `orders[].metadata.algo_order_id` · lite `ao` · string (uint128) · optional — The algo order that placed this order as a sub-order; zero for an ordinary order.
- `orders[].builder` · lite `b` · string (0x address) · optional — The main account id of a builder (a third party that routes your order and charges a fee on it). Leave it out unless you trade through a builder: setting it switches the signature to `OrderWithBuilderFee`.
- `orders[].builder_fee` · lite `bf` · string · optional — The builder's fee for this order, as a percentage: `"0.001"` means 0.001%. Only with `builder`.
- `order_i_ds` · lite `oi` · string (uint128)[] · optional — The order IDs of the orders to cancel or replace, supply up to 100 orderIDs (a request with both `order_i_ds` and `client_order_i_ds` is rejected)
- `client_order_i_ds` · lite `co` · string (uint64)[] · optional — The client order IDs of the orders to cancel or replace, supply up to 100 clientOrderIDs (a request with both `order_i_ds` and `client_order_i_ds` is rejected)
- `time_to_live_ms` · lite `tt` · string (uint64) · optional, default `0` — How long a cancel by `client_order_id` keeps waiting, in milliseconds, for an order that hasn't arrived yet. A cancel can overtake the create it refers to; an order with that `client_order_id` that arrives within this time is cancelled instead of placed. A cancel by `order_id` ignores this field.

  Unlike `cancel_order`, `bulk_orders` doesn't check this value: it isn't rounded, has no minimum and no 5000 ms limit, and `'0'` or a missing value means the cancel doesn't wait. The wait ends at the next 100 ms boundary after it runs out.

## Response

Body type `ApiBulkOrdersResponse` (the same object is the JSON-RPC `result` over WebSocket).

- `orders` · lite `o` · object Order[] · required — The orders in same order as requested
- `orders[].order_id` · lite `oi` · string (uint128) · optional, default `0` — Set by the server. The exchange's 128-bit id for the order. The reply to `create_order` or `bulk_orders` comes before the id is assigned, so it is zero there; the order stream and `get_order` carry it. Every replace creates a new order with a new `order_id`.
- `orders[].sub_account_id` · lite `sa` · string (uint64) · required — The sub-account placing the order.
- `orders[].is_market` · lite `im` · bool · optional, default `false` — True for a market order. A market order has no limit price, never rests on the book and fills at the prices of the resting orders it meets.

  On STABLE_PERP a slippage bound is mandatory: `limit_price` must carry the signed bound (reference price ± the chosen slippage), or the order is rejected (`STABLE_PERP_REQUIRES_PRICE_BOUND`). There, `is_market` = false with a limit price behaves the same; the flag only records intent.
- `orders[].time_in_force` · lite `ti` · enum TimeInForce · required — How long the order stays open and whether it may fill partly. The order book takes `GOOD_TILL_TIME`, `IMMEDIATE_OR_CANCEL`, `FILL_OR_KILL` and `RETAIL_PRICE_IMPROVEMENT`. An RFQ maker quote uses `GOOD_TILL_TIME` or `ALL_OR_NONE`; an RFQ taker uses `IMMEDIATE_OR_CANCEL` or `FILL_OR_KILL`.
  Values: `GOOD_TILL_TIME`, `ALL_OR_NONE`, `IMMEDIATE_OR_CANCEL`, `FILL_OR_KILL`, `RETAIL_PRICE_IMPROVEMENT` ([details](../enums.md#timeinforce)).
- `orders[].post_only` · lite `po` · bool · optional, default `false` — If true, the order must rest on the book as a maker order: if it would match at once, it is rejected (`FAIL_POST_ONLY`). A market, `IMMEDIATE_OR_CANCEL` or `FILL_OR_KILL` order cannot be post-only.

  If false, the order may take or make liquidity. Such orders can be held for a short speed bump before matching, so they meet up-to-date quotes; the exchange sets the delay, and it can differ per instrument.
- `orders[].reduce_only` · lite `ro` · bool · optional, default `false` — If true, the order may only reduce your position; the part that would increase it is cancelled.
- `orders[].legs` · lite `l` · object OrderLeg[] · required — What to trade. Send exactly one leg: the order book rejects orders with more than one (`MULTI_LEGGED_ORDER`).
- `orders[].legs[].instrument` · lite `i` · string (instrument name) · required — The instrument to trade, e.g. `BTC_USDT_Perp`.
- `orders[].legs[].size` · lite `s` · string · required — How much to trade, in the base asset. Decimal string, e.g. "0.01"; up to the instrument's base_decimals and a multiple of its minimum size. Scaled to an integer only inside the signature.
- `orders[].legs[].limit_price` · lite `lp` · string · optional, default `0` — The worst price you accept, in the quote currency per unit. Decimal string, e.g. "65000.5"; up to 9 decimals and a multiple of the instrument's tick size. Scaled to an integer only inside the signature.

  Leave it out (or `"0"`) on a market order. Exception: a STABLE_PERP market order must carry the signed slippage bound (reference price ± the chosen slippage) here.
- `orders[].legs[].is_buying_asset` · lite `ib` · bool · required — True to buy, false to sell.
- `orders[].signature` · lite `s` · object Signature · required — The EIP-712 signature that authorises this order. The SDKs fill it in; the Signing guide shows how to build it yourself.
- `orders[].signature.signer` · lite `s` · string (uint256) · required — The address of the wallet that signed (`0x` + 40 hex characters). That wallet must be allowed to act for the account; for an order, to trade for the sub-account.
- `orders[].signature.r` · lite `r` · string (uint256) · required — The signature's `r`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `orders[].signature.s` · lite `s1` · string (uint256) · required — The signature's `s`, as `0x` + 64 hex characters. Without the `0x` the signature fails to verify.
- `orders[].signature.v` · lite `v` · integer (uint8) · required — The signature's `v`, 27 or 28.
- `orders[].signature.expiration` · lite `e` · string (int64 unix ns) · required — When the signature stops being valid, in unix nanoseconds, measured on the exchange's clock. At most 30 days ahead (take-profit and stop-loss orders may be accepted up to 180 days ahead); one already past fails with `2001`. On an order it is also the order's lifetime: an order still open then is cancelled with reason `EXPIRED`. The SDKs use now + 24 hours.
- `orders[].signature.nonce` · lite `n` · integer (uint32) · required — A number you choose, 0 to 4,294,967,295 (uint32), so that two otherwise identical requests have different signatures. Use a new random one for each request you sign.

  A transfer whose signed fields (nonce and expiration included) exactly repeat an earlier one is rejected, not ignored: it fails with `4007`.

  Orders are different. An exact resend of a signed order can be accepted and rest on the book, but the exchange counts fills per signed order, so all copies together never fill more than the signed size, and a resent `IMMEDIATE_OR_CANCEL` order whose first copy already filled is rejected. An order signed again (new nonce or expiration) is a new order and can fill in full again.
- `orders[].signature.chain_id` · lite `ci` · string (uint64) · required — The chain id in the signed EIP-712 domain, as a string. Testnet 326, production 325; `"0"` means the environment's chain id.
- `orders[].metadata` · lite `m` · object OrderMetadata · required — Unsigned data the exchange uses but the chain never sees, such as your `client_order_id`.
- `orders[].metadata.client_order_id` · lite `co` · string (uint64) · required — Your own id for the order, to find or cancel it later. Any non-zero uint64 (`0` fails with `2011`) that none of the sub-account's open orders uses, take-profit and stop-loss orders waiting for their price included: a duplicate fails with `2012` (or is rejected with `OVERLAPPING_CLIENT_ORDER_ID`), and repeating the sub-account's last client order id fails with `2013`. After an order closes, its id is accepted again, so use a new id for each order.

  The Grvt web app picks ids below 2^63, so ids from 2^63 up never clash with orders placed there. That is a convention, not a rule the exchange checks. The SDKs set one for you when you leave it out. Not signed and not sent on chain.
- `orders[].metadata.create_time` · lite `ct` · string (int64 unix ns) · optional, default `0` — Set by the server. When the exchange received the order, in unix nanoseconds.
- `orders[].metadata.trigger` · lite `t` · object TriggerOrderMetadata · optional — Trigger fields are used to support any type of trigger order such as TP/SL
- `orders[].metadata.trigger.trigger_type` · lite `tt` · enum TriggerType · required — Type of the trigger order. eg: Take Profit, Stop Loss, etc
  Values: `UNSPECIFIED`, `TAKE_PROFIT`, `STOP_LOSS` ([details](../enums.md#triggertype)).
- `orders[].metadata.trigger.tpsl` · lite `t` · object TPSLOrderMetadata · required — Contains metadata for Take Profit (TP) and Stop Loss (SL) trigger orders.
  Fields: see [TPSLOrderMetadata](../types.md#tpslordermetadata).
- `orders[].metadata.broker` · lite `b` · enum BrokerTag · optional — Specifies the broker who brokered the order
  Values: `UNSPECIFIED`, `COIN_ROUTES`, `ALERTATRON`, `ORIGAMI` ([details](../enums.md#brokertag)).
- `orders[].metadata.is_ecn` · lite `ie` · bool · optional, default `false` — Marks an ECN order, eligible for market maker last look. Only on STABLE_PERP instruments, for qualified market makers.
- `orders[].metadata.slippage_bps` · lite `sb` · integer (uint16) · optional, default `0` — Maximum slippage from the mark price for an `IMMEDIATE_OR_CANCEL` limit order, in basis points (800 = 8%). Only valid on IOC limit orders; 0 means no slippage protection.
- `orders[].metadata.rfq_id` · lite `ri` · string (uint128) · optional — Binds this order to an RFQ (see ApiCreateRfqRequest and the `v1.rfq` / `v1.quote` streams). Optional.

  As a taker acceptance: unlocks that RFQ's private quote pool, so the order matches across the private pool merged with the public book (firm resting liquidity + public quotes). The acceptance must be a single-leg order with time_in_force = IOC or FOK. Setting `rfq_id` on a non-ECN GTT order is rejected. If the referenced RFQ has expired, been cancelled, or is unknown, the order is rejected.

  As a maker quote (is_ecn = true): identifies which RFQ the quote is responding to.

  Omit `rfq_id` to match the public book only — private RFQ liquidity requires an RFQ.
- `orders[].metadata.is_private` · lite `ip1` · bool · optional, default `false` — Maker quotes only. true = a private quote delivered to a single RFQ's taker (appears only on that taker's `v1.quote` book); false = a public quote resting on the order book, visible to all. When true, `rfq_id` is required.
- `orders[].metadata.algo_order_id` · lite `ao` · string (uint128) · optional — The algo order that placed this order as a sub-order; zero for an ordinary order.
- `orders[].state` · lite `s1` · object OrderState · optional — Set by the server. The order's status, filled size and average fill price; not signed.
- `orders[].state.status` · lite `s` · enum OrderStatus · required — The order's status. `FILLED`, `REJECTED` and `CANCELLED` are final.
  Values: `PENDING`, `OPEN`, `FILLED`, `REJECTED`, `CANCELLED` ([details](../enums.md#orderstatus)).
- `orders[].state.reject_reason` · lite `rr` · enum OrderRejectReason · required — Why the order was rejected or cancelled. `UNSPECIFIED` while it is not.
  Values: `UNSPECIFIED`, `CLIENT_CANCEL`, `CLIENT_BULK_CANCEL`, `CLIENT_SESSION_END`, `MARKET_CANCEL`, `IOC_CANCEL`, `AON_CANCEL`, `FOK_CANCEL`, `EXPIRED`, `FAIL_POST_ONLY`, `FAIL_REDUCE_ONLY`, `MM_PROTECTION`, `SELF_TRADE_PROTECTION`, `SELF_MATCHED_SUBACCOUNT`, `OVERLAPPING_CLIENT_ORDER_ID`, `BELOW_MARGIN`, `LIQUIDATION`, `INSTRUMENT_INVALID`, `INSTRUMENT_DEACTIVATED`, `SYSTEM_FAILOVER`, `UNAUTHORISED`, `SESSION_KEY_EXPIRED`, `SUB_ACCOUNT_NOT_FOUND`, `NO_TRADE_PERMISSION`, `UNSUPPORTED_TIME_IN_FORCE`, `MULTI_LEGGED_ORDER`, `EXCEED_MAX_POSITION_SIZE`, `EXCEED_MAX_SIGNATURE_EXPIRATION`, `MARKET_ORDER_WITH_LIMIT_PRICE`, `CLIENT_CANCEL_ON_DISCONNECT_TRIGGERED`, `OCO_COUNTER_PART_TRIGGERED`, `REDUCE_ONLY_LIMIT`, `CLIENT_REPLACE`, `DERISK_MUST_BE_IOC`, `DERISK_MUST_BE_REDUCE_ONLY`, `DERISK_NOT_SUPPORTED`, `INVALID_ORDER_TYPE`, `CURRENCY_NOT_DEFINED`, `INVALID_CHAIN_ID`, `BUILDER_ORDER_FEE_EXCEED`, `BUILDER_ORDER_FEE_NEGATIVE`, `BUILDER_ORDER_BUILDER_NOT_AUTHORIZED`, `BUILDER_ORDER_BUILDER_NOT_EXIST`, `TRADE_PRICE_WORSE_THAN_BANKRUPTCY_PRICE`, `TOO_MANY_MAKER_ORDERS`, `REDUCE_ONLY_NOT_SUPPORTED_FOR_SPOT_ORDER`, `TPSL_NOT_SUPPORTED_FOR_SPOT_ORDER`, `SPOT_ORDER_NOT_SUPPORTED`, `INSUFFICIENT_BALANCE`, `SPOT_TRADING_BLOCKED_DURING_SOCIALIZED_LOSS`, `BELOW_MARGIN_WITH_PENALTY_DEVIATION`, `CORPORATE_ACTION`, `NOT_QUALIFIED_MAKER`, `PRIVATE_QUOTE_REQUIRES_RFQ`, `STABLE_PERP_REQUIRES_PRICE_BOUND`, `UNSUPPORTED_TRIGGER_BY`, `RFQ_NOT_FOUND`, `RESTING_ORDER_WOULD_CROSS`, `SESSION_CLOSED`, `RFQ_TERMINATED`, `STABLE_PERP_REQUIRES_MULTI_ASSET_MODE`, `BORROW_LIMIT_EXCEEDED_AFTER_TRADE`, `UNDEPLOYED_LOAN_AUTO_EXCHANGE`, `LIQUIDATION_AUTO_EXCHANGE`, `USDC_COLLATERAL_DISABLED`, `SFP_POST_ONLY_NOT_ALLOWED`, `VAULT_NON_QUOTE_INVESTMENT_CURRENCY`, `RFQ_ID_REQUIRES_STABLE_PERP`, `RFQ_PRIVATE_POOL_NOT_SUPPORTED`, `RFQ_REQUIRES_IOC`, `RFQ_MISMATCH`, `RFQ_ALREADY_BOUND`, `RFQ_MAKER_MUST_BE_ECN`, `FOK_NOT_SUPPORTED`, `MARKET_ORDER_NOT_SUPPORTED`, `STABLE_PERP_ORDER_NOT_SUPPORTED` ([details](../enums.md#orderrejectreason)).
- `orders[].state.book_size` · lite `bs` · string[] · required — The size still open to fill, per leg (same order as `legs`), in the base asset.
- `orders[].state.traded_size` · lite `ts` · string[] · required — The size filled so far, per leg (same order as `legs`), in the base asset.
- `orders[].state.update_time` · lite `ut` · string (int64 unix ns) · required — When the order last changed, in unix nanoseconds.
- `orders[].state.avg_fill_price` · lite `af` · string[] · required — The average price of the fills so far, per leg (same order as `legs`); 0 before the first fill.
- `orders[].builder` · lite `b` · string (0x address) · optional — The main account id of a builder (a third party that routes your order and charges a fee on it). Leave it out unless you trade through a builder: setting it switches the signature to `OrderWithBuilderFee`.
- `orders[].builder_fee` · lite `bf` · string · optional — The builder's fee for this order, as a percentage: `"0.001"` means 0.001%. Only with `builder`.
- `cancel_acks` · lite `ca` · object Ack[] · required — A list of acks for the cancelled orders
- `cancel_acks[].ack` · lite `a` · bool · required — True when the exchange received the request and will process it. It doesn't mean the request has taken effect yet.

## Errors

Errors come back as `{"code", "message", "status"}` (lite `{"c", "m", "s"}`) with the HTTP status. Codes this call can return, as code, name (HTTP status) ([all error codes](../errors.md)):

`1000` Unauthorized (401) · `1001` Forbidden (403) · `1002` InternalServer (500) · `1003` InvalidRequest (400) · `1004` NotFound (404) · `1005` UnknownErr (500) · `1006` RateLimit (429, retryable) · `1008` IPNotWhitelisted (401) · `1009` APIEndpointTemporarilyDeactivated (503, retryable) · `1012` InvalidSignatureChainID (400) · `1400` NoTradePermission (403) · `2000` SignerUnauthorized (403) · `2001` SignatureExpired (403) · `2002` SignatureDoesNotMatchPayload (403) · `2003` OrderSubAccountDoesNotMatchLoggedInUser (403) · `2004` SessionKeySignerExpired (403) · `2005` SignatureInvalidV (403) · `2006` SignatureInvalidRSLength (403) · `2007` SignatureSIsNotCurveLowerHalf (403) · `2010` OrderIDShouldBeEmpty (400) · `2011` ClientOrderIDShouldBeSupplied (400) · `2012` ClientOrderIDOverlaps (400) · `2020` MarketOrderWithLimitPrice (400) · `2021` LimitOrderWithoutLimitPrice (400) · `2030` InvalidTimeInForceOrderbook (400) · `2031` InvalidTimeInForceRFQ (400) · `2032` PostOnlyWhenTakerOrder (400) · `2040` LegsEmpty (400) · `2041` LegsNotSorted (400) · `2042` LegsMultipleOrderbook (400) · `2050` NonEmptyState (400) · `2051` ExecutionMetadataShouldBeEmpty (400) · `2060` InactiveDerivative (400) · `2061` InstrumentNotSupported (400) · `2062` NumContractsUnderMinSize (400) · `2063` NumContractsUnderMinBlockSize (400) · `2064` InvalidLimitPriceTick (400) · `2065` InvalidContractGrainSize (400) · `2066` NotionalBelowMinimum (400) · `2067` PositionClosingNotionalBelowMinimum (400) · `2070` LiquidationOrderNotSupported (400) · `2080` InsufficientMargin (400) · `2081` MaximumPositionSizeExceeded (400) · `2082` FailedPreOrderCheck (400) · `2083` MaximumLeverageConfigPositionSizeExceeded (400) · `2084` FailedPostOrderCheck (400) · `2090` MaxOpenOrdersExceeded (429) · `2091` SessionOrderReduceOnlyRequired (403) · `2110` InvalidTriggerBy (400) · `2111` UnsupportedTriggerBy (400) · `2112` InvalidTriggerOrder (400) · `2113` EmptyTriggerPrice (400) · `2114` InvalidPTPSLReduceOnly (400) · `2115` InvalidPTPSLSize (400) · `2116` PTPSLOrderAlreadyExists (400) · `2117` PTPSLMustBeFromWebOrMobile (400) · `2118` InvalidTriggerPriceTick (400) · `2147` StablePerpRequiresMultiAssetMode (400) · `2148` VaultCannotTrade (400) · `2222` NotTPSLOrder (400) · `2230` InvalidOSOTriggerPrice (400) · `2232` InvalidPTPSLOrderLinkage (400) · `2233` BothOrderIDAndClientOrderIDProvided (400) · `2234` InvalidBulkOrdersAssetMismatch (400) · `2235` BulkOrdersMaxCountExceeded (400) · `2236` BulkOrdersNotSupportTriggerOrder (400) · `2237` BulkOrdersNotFromApiSource (400) · `2238` SplitTPSLMustNotBePositionLinkedTPSL (400) · `2239` SplitTPSLMustBeReduceOnly (400) · `2240` SplitTPSLCreatesMustNotContainNonSplit (400) · `2241` SplitTPSLCreatesExceedsSetSize (400) · `2242` SplitTPSLNotSupported (400) · `2243` SplitTPSLSetAlreadyExists (400) · `2244` CreatingSplitTPSLWithoutExistingPosition (400) · `2245` CreatingSplitTPSLExceedingPositionSize (400) · `2246` ModifyingSplitTPSLMismatchedCancels (400) · `2400` ReduceOnlyOrderWithNoPosition (400) · `2401` ReduceOnlyOrderIncreaseSize (400) · `2402` ReduceOnlyOrderSizeExceeded (400) · `2413` ReplaceOrderNumOrdersMismatch (400) · `2450` SpotOrderNotSupported (400) · `2451` SpotOrderReduceOnlyNotSupported (400) · `2452` SpotOrderTPSLNotSupported (400) · `2453` SpotTradingBlockedDuringSocializedLoss (400) · `3004` MMConfigNotFound (500) · `3005` AssetUnderlyingBalDecConfigNotFound (500) · `3006` AssetQuoteBalDecConfigNotFound (500) · `7303` DelistCreateOrderBlocked (400) · `7304` DelistPositionOpenBlocked (400) · `7600` SlippageFeatureDisabled (400) · `7601` SlippageRequiresIOCLimitOrder (400) · `7602` SlippageBelowMinimum (400) · `7603` SlippageExceedsPriceProtectionBand (400) · `7701` SfpIndicativeNotQualifiedMaker (403) · `7704` SfpOrderNotSupported (400) · `7705` SfpInstrumentMismatch (400) · `7706` SfpPrivateQuoteNotSupported (400) · `7707` SfpRfqNotLive (400) · `7708` SfpRfqAlreadyHasTakerOrder (400) · `7709` SfpTakerInvalidTimeInForce (400) · `7711` SfpMarketOrderNotAllowed (400) · `7712` RfqIDNotAllowedForNonSFP (400) · `7723` UsdcCollateralDisabled (400) · `7724` SfpPostOnlyNotAllowedForRetail (400) · `7726` SfpMarketClosed (400)

## Example

```python
import os
from decimal import Decimal

from grvt import Grvt, enums as e, PrivateKeySigner, models as m

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
    signer=PrivateKeySigner(os.environ["GRVT_PRIVATE_KEY"]),
) as client:
    resp = client.bulk_orders(
        sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
        orders=[
            m.OrderInput(
                sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
                is_market=False,
                time_in_force=e.TimeInForce("GOOD_TILL_TIME"),
                post_only=True,
                reduce_only=False,
                legs=[
                    m.OrderLeg(
                        instrument="BTC_USDT_Perp",
                        size=Decimal("0.5"),
                        limit_price=Decimal("64000"),
                        is_buying_asset=True,
                    ),
                ],
            ),
            m.OrderInput(
                sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
                is_market=False,
                time_in_force=e.TimeInForce("GOOD_TILL_TIME"),
                post_only=False,
                reduce_only=False,
                legs=[
                    m.OrderLeg(
                        instrument="BTC_USDT_Perp",
                        size=Decimal("0.25"),
                        limit_price=Decimal("66000.5"),
                        is_buying_asset=False,
                    ),
                ],
                builder="0x2222222222222222222222222222222222222222",
                builder_fee=Decimal("0.0005"),
            ),
        ],
        client_order_ids=[
            "4001",
        ],
        time_to_live_ms="1000",
    )
    print(resp)
```

Raw HTTP (set `GRVT_DOMAIN`, see [Environments](../../guides/environments.md); `GRVT_COOKIE` and `GRVT_ACCOUNT_ID` come from [login](../../guides/authentication.md)):

The body below is the `bulk_orders` signing case: a real signature by the public test key for chain id 326. Build your own with the [Signing guide](../../guides/signing.md); the server will reject this one (unknown account). `signature.expiration` is unix nanoseconds: use now + 1 day (the signing case uses 2100-01-01 so it never expires).

With full field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/full/v2/bulk_orders" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sub_account_id": "8289849667772468",
  "orders": [
    {
      "sub_account_id": "8289849667772468",
      "is_market": false,
      "time_in_force": "GOOD_TILL_TIME",
      "post_only": true,
      "reduce_only": false,
      "legs": [
        {
          "instrument": "BTC_USDT_Perp",
          "size": "0.5",
          "limit_price": "64000",
          "is_buying_asset": true
        }
      ],
      "signature": {
        "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
        "expiration": "4102444800000000000",
        "nonce": 5001,
        "chain_id": "326",
        "r": "0x7f50b9e9d602c8040e5502f8196ae574847218d66a96ded61af1c9dfa351ab6a",
        "s": "0x61a4c4232e618980d834baf654ddebcf50158285db01454b7b4ede4cbb793e31",
        "v": 28
      },
      "metadata": {
        "client_order_id": "5001"
      }
    },
    {
      "sub_account_id": "8289849667772468",
      "is_market": false,
      "time_in_force": "GOOD_TILL_TIME",
      "post_only": false,
      "reduce_only": false,
      "legs": [
        {
          "instrument": "BTC_USDT_Perp",
          "size": "0.25",
          "limit_price": "66000.5",
          "is_buying_asset": false
        }
      ],
      "builder": "0x2222222222222222222222222222222222222222",
      "builder_fee": "0.0005",
      "signature": {
        "signer": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
        "expiration": "4102444800000000000",
        "nonce": 5002,
        "chain_id": "326",
        "r": "0x088634c19819a8d169e7f5f23c917f7174b0817805da899288eac4eb04256eaa",
        "s": "0x09194903f97803ad2f199157b4561836526c57321521858133c51f6e27a769b2",
        "v": 27
      },
      "metadata": {
        "client_order_id": "5002"
      }
    }
  ],
  "client_order_i_ds": ["4001"],
  "time_to_live_ms": "1000"
}
EOF
```

With lite field names:

```sh
curl -sS "https://trades.$GRVT_DOMAIN/lite/v2/bulk_orders" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "sa": "8289849667772468",
  "o": [
    {
      "sa": "8289849667772468",
      "im": false,
      "ti": "GOOD_TILL_TIME",
      "po": true,
      "ro": false,
      "l": [
        {
          "i": "BTC_USDT_Perp",
          "s": "0.5",
          "lp": "64000",
          "ib": true
        }
      ],
      "s": {
        "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
        "e": "4102444800000000000",
        "n": 5001,
        "ci": "326",
        "r": "0x7f50b9e9d602c8040e5502f8196ae574847218d66a96ded61af1c9dfa351ab6a",
        "s1": "0x61a4c4232e618980d834baf654ddebcf50158285db01454b7b4ede4cbb793e31",
        "v": 28
      },
      "m": {
        "co": "5001"
      }
    },
    {
      "sa": "8289849667772468",
      "im": false,
      "ti": "GOOD_TILL_TIME",
      "po": false,
      "ro": false,
      "l": [
        {
          "i": "BTC_USDT_Perp",
          "s": "0.25",
          "lp": "66000.5",
          "ib": false
        }
      ],
      "b": "0x2222222222222222222222222222222222222222",
      "bf": "0.0005",
      "s": {
        "s": "0x1267c6181aee40f5ddbd70c56ecf4613117326b5",
        "e": "4102444800000000000",
        "n": 5002,
        "ci": "326",
        "r": "0x088634c19819a8d169e7f5f23c917f7174b0817805da899288eac4eb04256eaa",
        "s1": "0x09194903f97803ad2f199157b4561836526c57321521858133c51f6e27a769b2",
        "v": 27
      },
      "m": {
        "co": "5002"
      }
    }
  ],
  "co": ["4001"],
  "tt": "1000"
}
EOF
```
