Skip to main content

Batch Cancel Orders

Description

Batch cancel orders. Maximum 10 orders per request.

HTTP Request

DELETE /fapi/v1/batchOrders (HMAC SHA256)

Weight

1

Request Parameters

NameTypeRequiredDescription
symbolSTRINGYESTrading pair
orderIdListJSON LISTNOList of system order IDs; max 10
origClientOrderIdListJSON LISTNOList of user-defined order IDs; max 10
timestampLONGYESTimestamp

Response Example

[
{
"clientOrderId": "testOrderBatchCancel1",
"cumQty": "0",
"cumQuote": "0",
"executedQty": "0",
"orderId": 2254222045,
"origQty": "10",
"origType": "TRAILING_STOP_MARKET",
"price": "0",
"reduceOnly": false,
"side": "SELL",
"positionSide": "BOTH",
"status": "CANCELED",
"stopPrice": "0",
"closePosition": false,
"symbol": "BTCUSDT",
"timeInForce": "GTC",
"type": "TRAILING_STOP_MARKET",
"activatePrice": "9020",
"priceRate": "0.3",
"updateTime": 1566818724722,
"workingType": "CONTRACT_PRICE",
"priceProtect": false
}
]

Either orderIdList or origClientOrderIdList must be sent.

Notes

  • Each orderId may refer to a regular order or a trigger_order; the cancel path resolves the type and acts accordingly.
  • Cancelling a parent order cascade-cancels its attached TP/SL trigger orders.
  • Frozen margin attributable to the cancelled fapi-created orders is released on success. Order IDs that are already terminal (FILLED / CANCELED / EXPIRED) are silently skipped — they appear in the response with their current terminal status, not as errors.

Code Examples

cURL

API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="symbol=BTCUSDT&orderIdList=[2254222045,2254222046,2254222047]&timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')

curl -s -X DELETE \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.ztdx.io/fapi/v1/batchOrders?${QUERY_STRING}&signature=${SIGNATURE}"

Python

import time, hmac, hashlib, requests, json
from urllib.parse import quote

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api.ztdx.io"

def sign(msg: str) -> str:
return hmac.new(API_SECRET.encode(), msg.encode(), hashlib.sha256).hexdigest()

# Batch cancel multiple orders by orderIdList
order_ids = ["order_id_1", "order_id_2", "order_id_3"]

ts = int(time.time() * 1000)
id_list_str = json.dumps(order_ids, separators=(',', ':'))
encoded = quote(id_list_str)
qs = f"symbol=BTCUSDT&orderIdList={encoded}&timestamp={ts}"
sig = sign(qs)
resp = requests.delete(
f"{BASE_URL}/fapi/v1/batchOrders?{qs}&signature={sig}",
headers={"X-MBX-APIKEY": API_KEY},
)
print(resp.json())