> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Cancel order | Hyperliquid exchange

<Info>
  You can only use this endpoint on the official Hyperliquid public API. It is not available through Chainstack, as the open-source node implementation does not support it yet. See [Hyperliquid methods](/docs/hyperliquid-methods) for the full availability breakdown.
</Info>

<Note>
  This endpoint requires signature authentication. See our comprehensive [Authentication via Signatures guide](/docs/hyperliquid-authentication-guide) for implementation details.
</Note>

Cancels one or multiple open orders by order ID (oid) on the Hyperliquid exchange.

<Check>
  **Get your own node endpoint today**

  [Start for free](https://console.chainstack.com/) and get your app to production levels immediately. No credit card required.

  You can sign up with your GitHub, X, Google, or Microsoft account.
</Check>

## Parameters

### Required parameters

* `action` (object, required) — The cancel action object containing:
  * `type` (string) — Must be `"cancel"`
  * `cancels` (array) — Array of cancel objects with:
    * `a` (number) — Asset index
    * `o` (number) — Order ID to cancel

* `nonce` (number, required) — Current timestamp in milliseconds (must be recent)

* `signature` (object, required) — EIP-712 signature of the action

### Optional parameters

* `vaultAddress` (string, optional) — Address when trading on behalf of a vault or subaccount
* `expiresAfter` (number, optional) — Timestamp in milliseconds after which the request is rejected

## Returns

Returns an object with cancellation status:

* `status` — `"ok"` if request processed
* `response` — Contains cancellation details:
  * `type` — `"cancel"`
  * `data.statuses` — Array of status results:
    * `"success"` — Order successfully canceled
    * `error` — Object with error message if cancellation failed

## Example request

<CodeGroup>
  ```shell cURL theme={"system"}
  curl -X POST https://api.hyperliquid.xyz/exchange \
    -H "Content-Type: application/json" \
    -d '{
      "action": {
        "type": "cancel",
        "cancels": [{
          "a": 0,
          "o": 77738308
        }]
      },
      "nonce": 1234567890123,
      "signature": {...}
    }'
  ```

  ```python Python theme={"system"}
  from hyperliquid.exchange import Exchange
  from hyperliquid.utils import constants
  import eth_account

  # Initialize with your private key
  account = eth_account.Account.from_key("0x...")
  exchange = Exchange(account, constants.MAINNET_API_URL)

  # Cancel an order by ID
  cancel_result = exchange.cancel(
      coin="BTC",
      oid=77738308
  )

  # Cancel multiple orders
  cancel_results = exchange.cancel_multiple([
      {"coin": "BTC", "oid": 77738308},
      {"coin": "ETH", "oid": 77738309}
  ])

  print(cancel_result)
  ```
</CodeGroup>

## Response examples

### Successful cancellation

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": [
        "success"
      ]
    }
  }
}
```

### Failed cancellation

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": [{
        "error": "Order was never placed, already canceled, or filled."
      }]
    }
  }
}
```

### Multiple orders mixed results

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "cancel",
    "data": {
      "statuses": [
        "success",
        {
          "error": "Order was never placed, already canceled, or filled."
        }
      ]
    }
  }
}
```

## Use cases

* **Risk management** — Quickly cancel orders when market conditions change
* **Order management** — Clean up open orders that are no longer needed
* **Algorithmic trading** — Programmatically manage order lifecycle
* **Portfolio rebalancing** — Cancel orders before placing new ones

<Note>
  You can cancel multiple orders in a single request by including multiple objects in the `cancels` array. Each cancellation is processed independently.
</Note>

<Warning>
  Attempting to cancel an order that doesn't exist, was already canceled, or was filled will return an error but won't affect other cancellations in the same request.
</Warning>


## OpenAPI

````yaml /openapi/hyperliquid_node_api/exchange_cancel_order.json post /exchange
openapi: 3.0.0
info:
  title: Hyperliquid Exchange API
  version: 1.0.0
  description: >-
    API for trading operations on Hyperliquid exchange requiring authentication.
    ⚠️ WARNING: These endpoints require EIP-712 signatures for authentication.
    The example values provided will NOT work without proper cryptographic
    signing. You must implement EIP-712 signing to use these endpoints
    successfully.
servers:
  - url: https://api.hyperliquid.xyz
security: []
paths:
  /exchange:
    post:
      tags:
        - hyperliquid exchange
      summary: Cancel order
      operationId: cancelOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: object
                  properties:
                    type:
                      type: string
                      default: cancel
                      enum:
                        - cancel
                      description: Action type for canceling orders
                    cancels:
                      type: array
                      description: Array of cancel objects
                      items:
                        type: object
                        properties:
                          a:
                            type: integer
                            description: Asset index
                          o:
                            type: integer
                            description: Order ID to cancel
                        required:
                          - a
                          - o
                  required:
                    - type
                    - cancels
                nonce:
                  type: integer
                  description: Current timestamp in milliseconds
                signature:
                  type: object
                  description: EIP-712 signature of the action with r, s, v components
                  properties:
                    r:
                      type: string
                      description: ECDSA signature r component (hex string)
                      example: >-
                        0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
                    s:
                      type: string
                      description: ECDSA signature s component (hex string)
                      example: >-
                        0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
                    v:
                      type: integer
                      description: ECDSA recovery id (27 or 28)
                      example: 27
                  required:
                    - r
                    - s
                    - v
                vaultAddress:
                  type: string
                  description: >-
                    Address when trading on behalf of a vault or subaccount
                    (optional)
                  nullable: true
                expiresAfter:
                  type: integer
                  description: >-
                    Timestamp in milliseconds after which the request is
                    rejected (optional)
              required:
                - action
                - nonce
                - signature
            example:
              action:
                type: cancel
                cancels:
                  - a: 0
                    o: 123456789
              nonce: 1705234567890
              signature:
                r: >-
                  0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
                s: >-
                  0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
                v: 27
              vaultAddress: null
      responses:
        '200':
          description: Cancellation result
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    description: Request status
                  response:
                    type: object
                    properties:
                      type:
                        type: string
                      data:
                        type: object
                        properties:
                          statuses:
                            type: array
                            items:
                              oneOf:
                                - type: string
                                  enum:
                                    - success
                                - type: object
                                  properties:
                                    error:
                                      type: string
                                      description: Error message
                example:
                  status: ok
                  response:
                    type: cancel
                    data:
                      statuses:
                        - success

````