Modify Order
Description
Modify an active order's price and / or quantity. Internally implemented as
cancel-and-resubmit: the previous resting order is removed from the book,
margin freezing is recomputed for the new size, and a fresh order is queued
under the same orderId (so callers don't see the id change). The updateTime
timestamp is refreshed. Already-filled quantity is preserved — modify is
rejected with AMOUNT_BELOW_FILLED if quantity < executedQty.
Only LIMIT, STOP, STOP_MARKET, TAKE_PROFIT, and TAKE_PROFIT_MARKET
orders can be modified; MARKET and trailing-stop orders cannot.
HTTP Request
PUT /fapi/v1/order (HMAC SHA256)
Weight
1
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | STRING | YES | Trading pair |
| orderId | LONG | NO | System order ID |
| origClientOrderId | STRING | NO | User-defined order ID |
| side | ENUM | NO | Order side: BUY, SELL. Optional — defaults to the existing order's side. |
| quantity | DECIMAL | NO | New total order quantity (must be ≥ already-filled quantity). |
| price | DECIMAL | NO | New limit price. |
| stopPrice | DECIMAL | NO | New trigger price (for STOP* / TAKE_PROFIT*). |
| recvWindow | LONG | NO | See Endpoint Security Type |
| timestamp | LONG | YES | Timestamp |
At least one of quantity, price, or stopPrice must be sent — otherwise
the request is a no-op and rejected. Either orderId or origClientOrderId
must be sent to identify the target order.
Response Example
{
"orderId": 2254222045,
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "testOrderModify1",
"price": "60000",
"origQty": "0.1",
"cumQty": "0",
"cumQuote": "0",
"timeInForce": "GTC",
"type": "LIMIT",
"side": "BUY",
"stopPrice": "0",
"workingType": "CONTRACT_PRICE",
"updateTime": 1623910239123
}
Code Examples
cURL
API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
QUERY_STRING="symbol=BTCUSDT&orderId=2254222045&side=BUY&quantity=0.1&price=60000×tamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${QUERY_STRING}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -X PUT \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.ztdx.io/fapi/v1/order?${QUERY_STRING}&signature=${SIGNATURE}"
Python
import time, hmac, hashlib, requests, json
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()
def signed_put(path, body={}):
ts = int(time.time() * 1000)
qs = f"timestamp={ts}"
body_str = json.dumps(body, separators=(',', ':'))
sig = sign(qs + body_str)
return requests.put(
f"{BASE_URL}{path}?timestamp={ts}&signature={sig}",
data=body_str,
headers={"X-MBX-APIKEY": API_KEY, "Content-Type": "application/json"},
)
# Modify an existing order's quantity and price
resp = signed_put("/fapi/v1/order", body={
"symbol": "BTCUSDT",
"orderId": "2254222045",
"side": "BUY",
"quantity": "0.1",
"price": "60000",
})
print(resp.json())