Skip to content

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.


Remove a single order by its ID.

let resp = client.cancel_order("ORDER_ID").await?;
println!("Canceled: {:?}", resp.canceled);

REST:

Terminal window
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": {}
}

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:

Terminal window
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.


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:

Terminal window
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": {}
}

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:

Terminal window
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:

FieldRequiredDescription
marketNoCondition ID to filter by
asset_idNoToken ID to filter by

Both fields are optional. Omitting both behaves identically to DELETE /cancel-all.


When an order is cancelled:

  1. The database record’s status is set to CANCELED
  2. The order is removed from the in-memory matching engine book via engine.cancel_order(token_id, order_id)
  3. Only orders owned by the authenticated API key can be cancelled
  4. Orders that are already MATCHED or CANCELED cannot be cancelled again — they appear in notCanceled

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.


SituationResult
Order not foundAppears in notCanceled with reason
Order already cancelledAppears in notCanceled
Order fully matchedAppears in notCanceled
Invalid order ID formatAppears in notCanceled with “invalid order ID”
Wrong ownerAppears in notCanceled with “not found or already canceled”