Skip to main content

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

  1. Server calls matcher.cancelOrder over gRPC. NOT_FOUND is treated as idempotent success.
  2. 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.
  3. Double-cancel protection via the conditional WHERE.

Cancellation states

ConditionFinal statusNotes
Order was OPEN or PARTIALCANCELLEDResidual refunded
Order was FILLEDnot_found from APITerminal — nothing to cancel
Order was already CANCELLEDnot_found from APIIdempotent
Market was RESOLVED / CANCELLEDCANCELLED_BY_RESOLVE (set by admin-api)Your DELETE returns not_found