Orders
Cancel Order
Withdraw a resting order and release what it reserved
DELETE
/
orderbooks
/
stocks
/
api
/
orders
/
{orderId}
curl -X DELETE "https://api.trusset.org/orderbooks/stocks/api/orders/b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77" \
-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/stocks/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": "b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77",
"orderBookId": "clx_ob_stock_002",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "182350000",
"quantity": "5000000",
"filledQuantity": "1000000",
"remainingQuantity": "4000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
{
"success": false,
"data": null,
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found or already closed"
}
}
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. Cancelling is idempotent in effect. A second attempt on the same order fails the same way as an order that never existed.
Orders placed through the off-chain surface belong to a customer reference rather than a wallet and are cancelled with Cancel Off-Chain Order.
Path Parameters
string
required
The order’s
orderId, as returned when it was submitted. Up to 100 characters.Body Parameters
string
required
Wallet that placed the order.
Releasing the reservation
The order row is markedCANCELLED 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. A lock that is already PENDING, FAILED or RELEASED is left alone.
Response Fields
Returns the cancelled order.object
Show child attributes
Show child attributes
string
Order ID.
string
Book the order was on.
string
Owning wallet, lower-cased.
string
BUY or SELL.string
LIMIT or MARKET.string
Limit price in order book units, or
null.string
Original quantity.
string
Quantity filled before the cancel.
string
Quantity withdrawn.
string
CANCELLED.string
USER_CANCELLED.string
ISO 8601 timestamp.
curl -X DELETE "https://api.trusset.org/orderbooks/stocks/api/orders/b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77" \
-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/stocks/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": "b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77",
"orderBookId": "clx_ob_stock_002",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "182350000",
"quantity": "5000000",
"filledQuantity": "1000000",
"remainingQuantity": "4000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
{
"success": false,
"data": null,
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found or already closed"
}
}
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/stocks/api/orders/b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77" \
-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/stocks/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": "b7c1e0d4-6f2a-4f1e-9d33-5c8a1f0b2e77",
"orderBookId": "clx_ob_stock_002",
"userAddress": "0xabc7f1093d5e26b804a1c3f78de025916b47c0d3",
"side": "BUY",
"orderType": "LIMIT",
"price": "182350000",
"quantity": "5000000",
"filledQuantity": "1000000",
"remainingQuantity": "4000000",
"status": "CANCELLED",
"cancelReason": "USER_CANCELLED",
"updatedAt": "2025-06-15T12:06:00.000Z"
}
}
{
"success": false,
"data": null,
"error": {
"code": "ORDER_NOT_FOUND",
"message": "Order not found or already closed"
}
}
