Skip to main content
DELETE
/
api
/
v1
/
trading
/
orders
/
{order_id}
Cancel Order
curl --request DELETE \
  --url https://api.example.com/api/v1/trading/orders/{order_id}
{
  "message": "<string>",
  "refund_amount": 123
}

Usage

result = client.cancel_order(order_id="ord_abc123")

Parameters

order_id
string
required
The order ID to cancel.

Response

message
string
Cancellation result message.
refund_amount
number
Amount refunded to available balance (for buy orders).

Example

from polyhush import PolyhushClient, PolyhushAPIError

client = PolyhushClient(api_key="your-api-key")

try:
    result = client.cancel_order(order_id="ord_abc123")
    
    print(f"✅ {result['message']}")
    if result.get('refund_amount'):
        print(f"   Refunded: ${result['refund_amount']:.2f}")
        
except PolyhushAPIError as e:
    if "already" in e.message.lower():
        print("Order was already cancelled or filled")
    else:
        print(f"Cancel failed: {e.message}")

Response

{
  "message": "Order cancelled successfully",
  "refund_amount": 55.00
}

Refund Behavior

Order TypeRefund
Buy orderReserved USDC is refunded to available balance
Sell orderReserved shares are released back to position
Partially filledOnly unfilled portion is refunded
Cancellation requests are processed asynchronously. In rare cases, an order may fill between your cancel request and processing. Always check the response to confirm cancellation.