Skip to main content

Cancel Order

info

DELETE /orders/{order_id} removes a resting order. The body carries a fresh trading-key signature over the order id and a cancel nonce, proving the caller owns the order. Only the trading key that placed the order can cancel it.

DELETE /orders/{order_id}

Auth: Authorization: Bearer <token> and a trading-key cancel signature in the body.

Path parameters

ParameterTypeDescription
order_idstringThe 16-byte order id (hex) to cancel.

Request body

{
"trading_key": "…",
"cancel_nonce": 1,
"trading_key_signature": "…"
}
FieldTypeRequiredDescription
trading_keystringYes32-byte hex. Must be the key that placed the order.
cancel_nonceintegerYesA nonce bound into the signed cancel body (replay protection).
trading_key_signaturestringYes64-byte hex. Ed25519 signature over the canonical cancel body - { order_id, trading_key, cancel_nonce }.

The cancel nonce is part of the signed bytes, so a captured cancel request cannot be replayed to cancel a different (later, same-id) order - the canonical body, and therefore the signature, differs.

Example

curl -s -X DELETE "$GATEWAY/orders/$ORDER_ID" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"trading_key": "…",
"cancel_nonce": 1,
"trading_key_signature": "…"
}'

Success response

{
"order_id": "aa00000000000000000000000000000001",
"status": "cancelled"
}
FieldTypeDescription
order_idstringThe cancelled order's id.
statusstring"cancelled".

When an order is cancelled, the engine releases its collateral note and discards its continuation anchor pool. A cancelled event is also emitted on the Orders Channel so a streaming client sees the order leave without polling.

Errors

ConditionStatus
Malformed order_id / trading_key / signature hex400
Missing or invalid bearer token401
The signature does not verify, or the key does not own the order403
No such (resting) order - already filled, expired, or cancelled404
Cancelling races the match

An order can match in a batch between when you decide to cancel and when the cancel lands. If the order has already left the book, the cancel returns 404. Treat a 404 on cancel as "the order is no longer resting" and reconcile via GET /orders/{order_id} or the orders stream.