Skip to main content
DELETE
/
order
Cancel Order
curl --request DELETE \
  --url https://api.example.com/order \
  --header 'Content-Type: application/json' \
  --data '
{
  "orderId": "<string>"
}
'
{
  "success": true,
  "error": "<string>"
}

Overview

The Cancel Order endpoint allows authenticated users to cancel their open orders that have not yet been filled or expired.

Authentication

This endpoint requires CLOB authentication with HMAC signature verification. Required Headers:
  • KUEST_ADDRESS - User’s wallet address
  • KUEST_API_KEY - API key from trading auth credentials
  • KUEST_PASSPHRASE - Passphrase from trading auth credentials
  • KUEST_TIMESTAMP - Current Unix timestamp (seconds)
  • KUEST_SIGNATURE - HMAC signature of the request
  • Content-Type: application/json
  • Accept: application/json

Request Body

orderId
string
required
The unique identifier of the order to cancel. This is the orderID returned when the order was placed.

Response

Success Response

On successful cancellation, the endpoint returns a 200 status with an empty or success payload.
success
boolean
Indicates the order was successfully cancelled (may be omitted)

Error Response

error
string
Error message if cancellation failed

Error Codes

Status CodeDescription
404Order not found
409Order is already filled or cancelled
401Unauthorized - invalid credentials
403Forbidden - order belongs to different user
500Internal server error

Common Error Messages

  • Order not found - The order ID does not exist or has been deleted
  • Order is already filled or cancelled - The order is no longer in an active state
  • Unauthenticated - User session is invalid
  • Deploy your proxy wallet before trading - User needs to deploy proxy wallet
  • Unable to cancel this order right now - Temporary system issue

Order States

Orders can only be cancelled when in these states:
  • live - Active and waiting for matches
  • partially_filled - Partially executed, remainder is active
Orders cannot be cancelled when:
  • filled - Completely executed
  • cancelled - Already cancelled
  • expired - Past expiration time
  • rejected - Failed validation

Example Request

cURL
curl -X DELETE 'https://api.kuest.io/order' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'KUEST_ADDRESS: 0x1234...' \
  -H 'KUEST_API_KEY: your-api-key' \
  -H 'KUEST_PASSPHRASE: your-passphrase' \
  -H 'KUEST_TIMESTAMP: 1709467200' \
  -H 'KUEST_SIGNATURE: computed-hmac-signature' \
  -d '{
    "orderId": "ord_abc123xyz789"
  }'
```bash

## Example Success Response

```json
{
  "success": true
}
```bash

## Example Error Response

```json
{
  "error": "Order is already filled or cancelled."
}
```bash

## HMAC Signature Generation

The `KUEST_SIGNATURE` header must contain an HMAC-SHA256 signature of:

```bash
{timestamp}{method}{path}{body}
```bash

Where:
- `timestamp` - Unix timestamp in seconds (same as KUEST_TIMESTAMP header)
- `method` - HTTP method (`DELETE`)
- `path` - Request path (`/order`)
- `body` - JSON request body as string

**Example signature input:**
```bash
1709467200DELETE/order{"orderId":"ord_abc123xyz789"}
```bash

Use your CLOB secret key to generate the HMAC signature.

## Bulk Cancellation

To cancel multiple orders:
- Make multiple DELETE requests (can be done in parallel)
- Each order requires a separate cancellation request
- Failed cancellations don't affect other requests

## Rate Limiting

Order cancellation requests are subject to rate limits:
- Maximum 100 cancellations per minute per user
- Exceeded limits return 429 status code

## Best Practices

1. **Verify Order State** - Check order status before attempting cancellation
2. **Handle 404 Gracefully** - Order may have been filled between status check and cancellation
3. **Retry Logic** - Implement exponential backoff for temporary failures
4. **Track Cancelled Orders** - Update local state after successful cancellation
5. **WebSocket Updates** - Subscribe to order updates for real-time status changes

## See Also

- [Place Order](/api/trading/place-order) - Submit a new order
- [Get Orders](/api/trading/get-orders) - Retrieve user's orders
- [Orderbook](/api/trading/orderbook) - View market orderbook

Build docs developers (and LLMs) love