Orders
Cancel Order
Withdraw a resting order and release what it reserved
DELETE
/
orderbooks
/
commodities
/
api
/
orders
/
{orderId}
curl -X DELETE "https://api.trusset.org/orderbooks/commodities/api/orders/f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{ "userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" }'
const res = await fetch(
`https://api.trusset.org/orderbooks/commodities/api/orders/${orderId}`,
{
method: 'DELETE',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ userAddress: await wallet.getAddress() })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"orderId": "f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204",
"orderBookId": "clx_ob_comm_001",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "2412550000",
"quantity": "1000000",
"filledQuantity": "0",
"remainingQuantity": "1000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
Cancels an order that is still
OPEN or PARTIALLY_FILLED. Only the wallet that placed the order can cancel it: userAddress must match the order’s owner, and a mismatch reads the same as a missing order.
Filled, expired and already-cancelled orders return ORDER_NOT_FOUND, so a second attempt on the same order fails the same way as one that never existed.
The order row is marked CANCELLED first, so the depth disappears immediately. Releasing the custody lock behind it is attempted afterwards, and a failure there is logged rather than surfaced: the cancel still succeeds, and the lock is retried by the balance lock reconciler. Only the unfilled remainder is released.
Path Parameters
string
required
The order’s
orderId. Up to 100 characters.Body Parameters
string
required
Wallet that placed the order.
Response Fields
Returns the cancelled order, withstatus: "CANCELLED" and cancelReason: "USER_CANCELLED".
curl -X DELETE "https://api.trusset.org/orderbooks/commodities/api/orders/f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{ "userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" }'
const res = await fetch(
`https://api.trusset.org/orderbooks/commodities/api/orders/${orderId}`,
{
method: 'DELETE',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ userAddress: await wallet.getAddress() })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"orderId": "f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204",
"orderBookId": "clx_ob_comm_001",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "2412550000",
"quantity": "1000000",
"filledQuantity": "0",
"remainingQuantity": "1000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
Error Codes
| Code | HTTP | Cause |
|---|---|---|
VALIDATION_ERROR | 400 | userAddress is missing or not an address |
INVALID_PARAM | 400 | orderId is missing or longer than 100 characters |
ORDER_NOT_FOUND | 404 | No open order with that ID for this wallet, or the book is not reachable from your instance |
SERVICE_NOT_ENABLED | 403 | The Trading service is not enabled on this instance |
⌘I
curl -X DELETE "https://api.trusset.org/orderbooks/commodities/api/orders/f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204" \
-H "X-API-Key: trusset_your_key_here" \
-H "Content-Type: application/json" \
-d '{ "userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3" }'
const res = await fetch(
`https://api.trusset.org/orderbooks/commodities/api/orders/${orderId}`,
{
method: 'DELETE',
headers: {
'X-API-Key': 'trusset_your_key_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({ userAddress: await wallet.getAddress() })
}
);
const { data } = await res.json();
{
"success": true,
"data": {
"orderId": "f2a9c7d1-40e6-4b83-95c0-7d18a3e6b204",
"orderBookId": "clx_ob_comm_001",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "2412550000",
"quantity": "1000000",
"filledQuantity": "0",
"remainingQuantity": "1000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
