Cancel a single order
DELETE /api/orders/{orderId}
X-Api-Key: ps_live_<keyId>_<secret> # needs `orders:write` scope
Response:
{ "orderId": "0x...", "status": "cancelled", "unfilledQty": "42" }
If the order already reached a terminal state before your DELETE
arrived:
{ "orderId": "0x...", "status": "not_found" }
Cancel all your open orders
DELETE /api/orders
X-Api-Key: ps_live_<keyId>_<secret> # needs `orders:write` scope
Content-Type: application/json
{ "marketId": "UAE-CUP-FINAL-20260425" }
Omit marketId to cancel every open order for the authenticated
wallet (authenticated associatedWallet or the API-key’s associatedWallet).
Response:
{ "cancelled": 17, "marketId": "UAE-CUP-FINAL-20260425" }
Cancel-all is rate-limited more strictly (5/min/wallet). Use for
operational interventions, not normal per-order cleanup.
Under the hood
- Server calls
matcher.cancelOrder over gRPC. NOT_FOUND is
treated as idempotent success.
- PG authoritative flip in a single tx:
UPDATE orders SET status='CANCELLED' WHERE id=$1 AND status IN ('PENDING','OPEN','PARTIAL')
refundResidualLocked() — sums remaining locked, refunds to available.
- Double-cancel protection via the conditional WHERE.
Cancellation states
| Condition | Final status | Notes |
|---|
Order was OPEN or PARTIAL | CANCELLED | Residual refunded |
Order was FILLED | not_found from API | Terminal — nothing to cancel |
Order was already CANCELLED | not_found from API | Idempotent |
Market was RESOLVED / CANCELLED | CANCELLED_BY_RESOLVE (set by admin-api) | Your DELETE returns not_found |