Cancel Order
Every cancel endpoint requires L2 authentication. Responses include a canceled list (successfully cancelled order IDs) and a notCanceled map (order IDs paired with failure reasons).
When an order is cancelled, it is removed from both the database (status set to CANCELED) and the in-memory matching engine.
DELETE /order
Section titled “DELETE /order”Remove a single order by its ID.
let resp = client.cancel_order("ORDER_ID").await?;println!("Canceled: {:?}", resp.canceled);REST:
curl -X DELETE "https://api.openfish.fun/order" \ -H "Content-Type: application/json" \ -H "OPENFISH_ADDRESS: ..." \ -H "OPENFISH_SIGNATURE: ..." \ -H "OPENFISH_TIMESTAMP: ..." \ -H "OPENFISH_API_KEY: ..." \ -H "OPENFISH_PASSPHRASE: ..." \ -d '{"orderID": "a1b2c3d4-..."}'Request body:
{ "orderID": "a1b2c3d4-..."}The server accepts both orderID and orderId as field names.
Response:
{ "canceled": ["a1b2c3d4-..."], "notCanceled": {}}DELETE /orders
Section titled “DELETE /orders”Remove multiple orders in a single request.
let resp = client.cancel_orders(&["ORDER_ID_1", "ORDER_ID_2"]).await?;println!("Canceled: {:?}", resp.canceled);println!("Not canceled: {:?}", resp.not_canceled);REST:
curl -X DELETE "https://api.openfish.fun/orders" \ -H "Content-Type: application/json" \ -H "OPENFISH_ADDRESS: ..." \ -H "OPENFISH_SIGNATURE: ..." \ -H "OPENFISH_TIMESTAMP: ..." \ -H "OPENFISH_API_KEY: ..." \ -H "OPENFISH_PASSPHRASE: ..." \ -d '["a1b2c3d4-...", "e5f6g7h8-..."]'Request body: A JSON array of order ID strings.
Each cancellation is processed independently. If one fails (already cancelled, not found, etc.), the rest still go through.
DELETE /cancel-all
Section titled “DELETE /cancel-all”Wipe every open order across all markets for the authenticated user.
let resp = client.cancel_all_orders().await?;println!("Canceled {} orders", resp.canceled.len());REST:
curl -X DELETE "https://api.openfish.fun/cancel-all" \ -H "OPENFISH_ADDRESS: ..." \ -H "OPENFISH_SIGNATURE: ..." \ -H "OPENFISH_TIMESTAMP: ..." \ -H "OPENFISH_API_KEY: ..." \ -H "OPENFISH_PASSPHRASE: ..."No request body needed. The server loads every order belonging to the authenticated API key, marks them CANCELED in the database, and pulls them from the in-memory engine.
Response:
{ "canceled": ["a1b2c3d4-...", "e5f6g7h8-...", "i9j0k1l2-..."], "notCanceled": {}}DELETE /cancel-market-orders
Section titled “DELETE /cancel-market-orders”Cancel all open orders within a particular market, with an optional filter down to a single token.
use openfish_client_sdk::clob::types::request::CancelMarketOrderRequest;
let request = CancelMarketOrderRequest::builder() .market("CONDITION_ID".parse()?) .build();let resp = client.cancel_market_orders(&request).await?;REST:
curl -X DELETE "https://api.openfish.fun/cancel-market-orders" \ -H "Content-Type: application/json" \ -H "OPENFISH_ADDRESS: ..." \ -H "OPENFISH_SIGNATURE: ..." \ -H "OPENFISH_TIMESTAMP: ..." \ -H "OPENFISH_API_KEY: ..." \ -H "OPENFISH_PASSPHRASE: ..." \ -d '{"market": "0xbd31dc8a...", "asset_id": "52114319501245..."}'Request body:
| Field | Required | Description |
|---|---|---|
market | No | Condition ID to filter by |
asset_id | No | Token ID to filter by |
Both fields are optional. Omitting both behaves identically to DELETE /cancel-all.
Cancellation Mechanics
Section titled “Cancellation Mechanics”When an order is cancelled:
- The database record’s status is set to
CANCELED - The order is removed from the in-memory matching engine book via
engine.cancel_order(token_id, order_id) - Only orders owned by the authenticated API key can be cancelled
- Orders that are already
MATCHEDorCANCELEDcannot be cancelled again — they appear innotCanceled
Ownership Check
Section titled “Ownership Check”The server confirms that the API key in the request matches the order’s owner field. Trying to cancel someone else’s order produces not found or already canceled in the notCanceled map.
Error Cases
Section titled “Error Cases”| Situation | Result |
|---|---|
| Order not found | Appears in notCanceled with reason |
| Order already cancelled | Appears in notCanceled |
| Order fully matched | Appears in notCanceled |
| Invalid order ID format | Appears in notCanceled with “invalid order ID” |
| Wrong owner | Appears in notCanceled with “not found or already canceled” |
Next Steps
Section titled “Next Steps”- Create Order — Build and submit orders -> create
- Attribution — Builder order attribution -> attribution