> This page is for API Reference.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://okx-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://okx-demo.ferndocs.com/_mcp/server.

# Place multiple orders

POST https://www.okx.com/api/v5/trade/batch-orders
Content-Type: application/json

Place orders in batches. Maximum 20 orders can be placed per request. Request parameters should be passed in the form of an array. Orders will be placed in turn

Reference: https://okx-demo.ferndocs.com/api/api-reference/trade/place-batch-orders

## Authentication

- `OK-ACCESS-KEY` header (required) — Your API key.
- `OK-ACCESS-SIGN` header (required) — Base64-encoded HMAC-SHA256 signature of the prehash string.
- `OK-ACCESS-TIMESTAMP` header (required) — ISO 8601 UTC timestamp, e.g. 2020-12-08T09:08:57.715Z.
- `OK-ACCESS-PASSPHRASE` header (required) — The passphrase you set when creating the API key.

## Request

### Body (application/json)

This endpoint expects an object.

- `instId` (string, required) — Instrument ID, e.g. `BTC-USDT`
- `tdMode` (enum, required) — Trade mode Margin mode `cross` `isolated` Non-Margin mode `cash` `spot_isolated` (only applicable to SPOT lead trading, `tdMode` should be `spot_isolated` for `SPOT` lead trading.) Note: `isolated` is not available in multi-currency margin mode and portfolio margin mode. Event contracts symbols only support `isolated`
  - Allowed values: `cross`, `isolated`, `cash`, `spot_isolated`
- `side` (enum, required) — Order side `buy` `sell`
  - Allowed values: `buy`, `sell`
- `ordType` (enum, required) — Order type `market`: Market order, only applicable to `SPOT/MARGIN/FUTURES/SWAP` `limit`: Limit order `post_only`: Post-only order `fok`: Fill-or-kill order `ioc`: Immediate-or-cancel order `optimal_limit_ioc`: Market order with immediate-or-cancel order (applicable only to Expiry Futures and Perpetual Futures). `mmp`: Market Maker Protection (only applicable to Option in Portfolio Margin mode) `mmp_and_post_only`: Market Maker Protection and Post-only order(only applicable to Option in Portfolio Margin mode) `rpi`: Retail Price Improvement order `elp`: Enhanced Liquidity Program order (Deprecated; use `rpi`. Accepted until October 31, 2026.)
  - Allowed values: `market`, `limit`, `post_only`, `fok`, `ioc`, `optimal_limit_ioc`, `mmp`, `mmp_and_post_only`, `elp`
- `sz` (string, required) — Quantity to buy or sell
- `px` (string, optional) — Order price. Only applicable to `limit`,`post_only`,`fok`,`ioc`,`mmp`,`mmp_and_post_only` order. When placing an option order, one of px/pxUsd/pxVol must be filled in, and only one can be filled in
- `clOrdId` (string, optional) — Client Order ID as assigned by the client A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 32 characters.
- `tag` (string, optional) — Order tag A combination of case-sensitive alphanumerics, all numbers, or all letters of up to 16 characters.
- `posSide` (enum, optional) — Position side The default is `net` in the `net` mode It is required in the `long/short` mode, and can only be `long` or `short`. Only applicable to `FUTURES`/`SWAP`.
  - Allowed values: `net`, `long`, `short`
- `ccy` (string, optional) — Margin currency Applicable to all `isolated` `MARGIN` orders and `cross` `MARGIN` orders in `Futures mode`.
- `reduceOnly` (boolean, optional) — Whether the order can only reduce position size. Valid options: `true` or `false`. The default value is `false`. Only applicable to `MARGIN` orders, and `FUTURES`/`SWAP` orders in `net` mode Only applicable to `Futures mode` and `Multi-currency margin`
- `tgtCcy` (enum, optional) — Order quantity unit setting for `sz` `base_ccy`: Base currency ,`quote_ccy`: Quote currency Only applicable to `SPOT` Market Orders Default is `quote_ccy` for buy, `base_ccy` for sell
  - Allowed values: `base_ccy`, `quote_ccy`

## Response

### 200

Successful response

- `code` (string, optional) — Result code. `0` means success; any other value is an error code.
- `msg` (string, optional) — Error message. Empty on success.
- `data` (list of ApiV5TradeBatchOrdersPostResponsesContentApplicationJsonSchemaDataItems, optional)

## Types

### ApiV5TradeBatchOrdersPostResponsesContentApplicationJsonSchemaDataItems

- `ordId` (string, optional) — Order ID.
- `clOrdId` (string, optional) — Client-supplied order ID.
- `tag` (string, optional) — Order tag.
- `ts` (string, optional) — Timestamp when the order request processing finished, Unix timestamp in ms.
- `sCode` (string, optional) — Per-order result code. 0 means success.
- `sMsg` (string, optional) — Per-order rejection or success message.

## Examples

**Request**

```json
{
  "instId": "BTC-USDT",
  "tdMode": "cash",
  "side": "buy",
  "ordType": "limit",
  "sz": "0.01"
}
```

**Response**

```json
{
  "code": "0",
  "msg": "",
  "data": [
    {
      "ordId": "12345689",
      "clOrdId": "oktswap6",
      "tag": "",
      "ts": "1695190491421",
      "sCode": "0",
      "sMsg": "",
      "subCode": ""
    },
    {
      "ordId": "12344",
      "clOrdId": "oktswap7",
      "tag": "",
      "ts": "1695190491421",
      "sCode": "0",
      "sMsg": "",
      "subCode": ""
    }
  ],
  "inTime": "1695190491421339",
  "outTime": "1695190491423240"
}
```

**SDK Code**

```python trade_placeBatchOrders_example
import requests

url = "https://www.okx.com/api/v5/trade/batch-orders"

payload = {
    "instId": "BTC-USDT",
    "tdMode": "cash",
    "side": "buy",
    "ordType": "limit",
    "sz": "0.01"
}
headers = {
    "OK-ACCESS-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript trade_placeBatchOrders_example
const url = 'https://www.okx.com/api/v5/trade/batch-orders';
const options = {
  method: 'POST',
  headers: {'OK-ACCESS-KEY': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"instId":"BTC-USDT","tdMode":"cash","side":"buy","ordType":"limit","sz":"0.01"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go trade_placeBatchOrders_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://www.okx.com/api/v5/trade/batch-orders"

	payload := strings.NewReader("{\n  \"instId\": \"BTC-USDT\",\n  \"tdMode\": \"cash\",\n  \"side\": \"buy\",\n  \"ordType\": \"limit\",\n  \"sz\": \"0.01\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("OK-ACCESS-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby trade_placeBatchOrders_example
require 'uri'
require 'net/http'

url = URI("https://www.okx.com/api/v5/trade/batch-orders")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["OK-ACCESS-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"instId\": \"BTC-USDT\",\n  \"tdMode\": \"cash\",\n  \"side\": \"buy\",\n  \"ordType\": \"limit\",\n  \"sz\": \"0.01\"\n}"

response = http.request(request)
puts response.read_body
```

```java trade_placeBatchOrders_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://www.okx.com/api/v5/trade/batch-orders")
  .header("OK-ACCESS-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"instId\": \"BTC-USDT\",\n  \"tdMode\": \"cash\",\n  \"side\": \"buy\",\n  \"ordType\": \"limit\",\n  \"sz\": \"0.01\"\n}")
  .asString();
```

```php trade_placeBatchOrders_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://www.okx.com/api/v5/trade/batch-orders', [
  'body' => '{
  "instId": "BTC-USDT",
  "tdMode": "cash",
  "side": "buy",
  "ordType": "limit",
  "sz": "0.01"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'OK-ACCESS-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp trade_placeBatchOrders_example
using RestSharp;

var client = new RestClient("https://www.okx.com/api/v5/trade/batch-orders");
var request = new RestRequest(Method.POST);
request.AddHeader("OK-ACCESS-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"instId\": \"BTC-USDT\",\n  \"tdMode\": \"cash\",\n  \"side\": \"buy\",\n  \"ordType\": \"limit\",\n  \"sz\": \"0.01\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift trade_placeBatchOrders_example
import Foundation

let headers = [
  "OK-ACCESS-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "instId": "BTC-USDT",
  "tdMode": "cash",
  "side": "buy",
  "ordType": "limit",
  "sz": "0.01"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://www.okx.com/api/v5/trade/batch-orders")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```