Modify Order
Description
Modify an active order's price and 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 -1102 (New quantity ... cannot be smaller than already-filled ...)
if quantity < executedQty.
Only resting LIMIT orders can be modified. Any other order type — and any
order that is no longer in NEW / PARTIALLY_FILLED status — is rejected with
-2013 (Order does not exist or cannot be modified.).
HTTP Request
PUT /fapi/v1/order (HMAC SHA256)
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| symbol | STRING | YES | Trading pair |
| orderId | STRING | NO | System order ID (UUID) |
| origClientOrderId | STRING | NO | User-defined order ID |
| side | ENUM | NO | Order side: BUY, SELL. Optional — the side of an order is immutable; if sent, it must match the resting order's side, otherwise -1102. |
| quantity | DECIMAL | YES | New total order quantity (must be ≥ already-filled quantity). |
| price | DECIMAL | YES | New limit price. |
| recvWindow | LONG | NO | Accepted but ignored — the server enforces a fixed ±60 second timestamp window instead. |
| timestamp | LONG | YES | Timestamp |
Both quantity and price are required. Either orderId or
origClientOrderId must be sent to identify the target order.
Response Example
{
"orderId": "3fa42833-9508-4061-8d80-b68563dcd521",
"symbol": "BTCUSDT",
"status": "NEW",
"clientOrderId": "testOrderModify1",
"price": "60000",
"avgPrice": "0",
"origQty": "0.1",
"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
}
Errors
| Code | Cause |
|---|---|
| -1100 | quantity / price not positive or unparsable |
| -1102 | quantity below already-filled amount, or side does not match the resting order |
| -2011 | Order raced out of the matching engine (filled / cancelled mid-flight) — cannot modify |
| -2013 | Order does not exist, is not a LIMIT order, or is not in a modifiable status |
| -2019 | Margin insufficient for the enlarged order |
Code Examples
cURL
API_KEY="your_api_key"
API_SECRET="your_api_secret"
TIMESTAMP=$(date +%s%3N)
BODY='{"symbol":"BTCUSDT","orderId":"3fa42833-9508-4061-8d80-b68563dcd521","side":"BUY","quantity":"0.1","price":"60000"}'
SIGNATURE=$(echo -n "timestamp=${TIMESTAMP}${BODY}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')
curl -s -X PUT \
-H "X-MBX-APIKEY: ${API_KEY}" \
-H "Content-Type: application/json" \
-d "${BODY}" \
"https://api.prex.world/fapi/v1/order?timestamp=${TIMESTAMP}&signature=${SIGNATURE}"
Python
import time, hmac, hashlib, requests, json
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()
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": "3fa42833-9508-4061-8d80-b68563dcd521",
"side": "BUY",
"quantity": "0.1",
"price": "60000",
})
print(resp.json())