Skip to main content

Batch Cancel Orders

Description

Batch cancel orders by system order ID.

HTTP Request

DELETE /fapi/v1/batchOrders (HMAC SHA256)

Request Parameters

NameTypeRequiredDescription
symbolSTRINGYESTrading pair
orderIdListJSON LISTNOJSON array of system order IDs (UUID strings), e.g. ["3fa42833-...","1692e583-..."]
timestampLONGYESTimestamp

Cancelling by client order ID is not supported on this endpoint — origClientOrderIdList is not accepted. If orderIdList is omitted (or not parseable as a JSON array), the request succeeds with an empty array response; no orders are cancelled.

Response Example

[
{
"orderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"symbol": "BTCUSDT",
"status": "CANCELED",
"clientOrderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"price": "60000",
"avgPrice": "0",
"origQty": "0.01",
"executedQty": "0",
"cumQuote": "0",
"timeInForce": "GTC",
"type": "LIMIT",
"reduceOnly": false,
"side": "BUY",
"positionSide": "BOTH",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"priceProtect": false,
"origType": "LIMIT",
"updateTime": 1774330265238,
"time": 1774330191022
}
]

Notes

  • The response contains one element per successfully cancelled order. IDs that refer to orders in a terminal state (FILLED / CANCELED / REJECTED), IDs that don't exist, and IDs that don't parse as UUIDs are omitted from the response — they do not produce error elements.
  • clientOrderId in each response element always equals the order's UUID — the user-supplied newClientOrderId is not echoed here.
  • Each orderId may refer to a regular resting order or a trigger order placed via POST /fapi/v1/order (STOP* / TAKE_PROFIT*); the cancel path resolves the type and routes trigger orders to the trigger service.
  • Frozen margin attributable to the cancelled orders is released back to the available balance.

Code Examples

cURL

API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
ID_LIST='["3fa42833-9508-4061-8d80-b68563dcd521","1692e583-1067-4a55-8ef2-73833eb31537"]'
QUERY_STRING="symbol=BTCUSDT&orderIdList=${ID_LIST}&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.prex.world/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.prex.world"

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

# Batch cancel multiple orders by orderIdList
order_ids = [
"3fa42833-9508-4061-8d80-b68563dcd521",
"1692e583-1067-4a55-8ef2-73833eb31537",
]

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())