Skip to main content

Cancel Order

Description

Cancel a single open or partially-filled order that belongs to the caller. The order is returned in its final canceled state.

HTTP Request

DELETE /spot/orders/:id (JWT or API Key)

Weight

0 — order endpoints are not subject to per-IP weight limits. A per-engine mpsc backlog is enforced; on overflow the response is 503 ENGINE_BUSY.

Request Parameters

NameTypeRequiredDescription
idSTRING (path)YESUUID of the order to cancel. Returned as id by New Order.

Response Example

200 OK

{
"id": "9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10",
"symbol": "DFUSDT",
"side": "buy",
"type": "limit",
"tif": "gtc",
"price": "0.5000",
"quantity": "100",
"quote_quantity": null,
"filled_qty": "30",
"avg_fill_price": "0.499",
"status": "canceled",
"reject_reason": null,
"created_at": 1778400000,
"updated_at": 1778400120
}
FieldNotes
statusAlways canceled on a successful response. See Order Status.
filled_qtyAmount filled before the cancel; may be non-zero for partially-filled orders.
avg_fill_priceVolume-weighted average price of fills that occurred before cancellation. "0" if no fills.
created_at, updated_atUnix seconds. updated_at reflects the cancellation time.

Error Responses

HTTPerrorWhen
400invalid id:id is not a valid UUID.
403FORBIDDENThe order exists but belongs to a different user.
404ORDER_NOT_FOUNDOrder does not exist, or is already in a terminal state (filled / canceled / rejected).
503ENGINE_BUSY, ENGINE_RESTARTING, spot trading disabledTransient; retry with backoff.

Full list: Error Codes.

Code Examples

cURL (JWT)

JWT="your_jwt_token"
ORDER_ID="9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"

curl -s -X DELETE "https://api-sepolia.p99.world/api/v1/spot/orders/${ORDER_ID}" \
-H "Authorization: Bearer ${JWT}"

cURL (HMAC API Key)

API_KEY="your_api_key"
API_SECRET="your_api_secret"
ORDER_ID="9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"
TIMESTAMP=$(date +%s%3N)
PAYLOAD="timestamp=${TIMESTAMP}"
SIGNATURE=$(echo -n "${PAYLOAD}" | openssl dgst -sha256 -hmac "${API_SECRET}" | awk '{print $2}')

curl -s -X DELETE \
-H "X-MBX-APIKEY: ${API_KEY}" \
"https://api-sepolia.p99.world/api/v1/spot/orders/${ORDER_ID}?timestamp=${TIMESTAMP}&signature=${SIGNATURE}"

Python

import time, hmac, hashlib, requests

API_KEY = "your_api_key"
API_SECRET = "your_api_secret"
BASE_URL = "https://api-sepolia.p99.world/api/v1"

def signed_delete(path: str) -> dict:
ts = int(time.time() * 1000)
payload = f"timestamp={ts}"
sig = hmac.new(API_SECRET.encode(), payload.encode(), hashlib.sha256).hexdigest()
r = requests.delete(
f"{BASE_URL}{path}?timestamp={ts}&signature={sig}",
headers={"X-MBX-APIKEY": API_KEY},
timeout=5,
)
r.raise_for_status()
return r.json()

order_id = "9f2a1c4e-5b67-4d8a-bf93-2e1f4a6c8d10"
canceled = signed_delete(f"/spot/orders/{order_id}")
print(canceled["id"], canceled["status"], canceled["filled_qty"], "/", canceled["quantity"])