> ## 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.

# Modify order | Hyperliquid exchange

> Modifies an existing order on the Hyperliquid exchange. You can change the price, size, and other parameters without canceling and replacing the order.

<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>

Modifies an existing order on the Hyperliquid exchange. You can change the price, size, and other parameters without canceling and replacing the order.

## Parameters

### Required parameters

* `action` (object, required) — The modify action object containing:
  * `type` (string) — Must be `"modify"`
  * `oid` (number or string) — Order ID to modify, or cloid if using client order ID
  * `order` (object) — New order parameters:
    * `a` (number) — Asset index
    * `b` (boolean) — Is buy order (true for buy/long, false for sell/short)
    * `p` (string) — New limit price
    * `s` (string) — New size in units of the base asset
    * `r` (boolean) — Reduce only order
    * `t` (object) — Order type specification:
      * For limit orders: `{"limit": {"tif": "Alo" | "Ioc" | "Gtc"}}`
      * For trigger orders: `{"trigger": {"isMarket": boolean, "triggerPx": string, "tpsl": "tp" | "sl"}}`
    * `c` (string, optional) — New client order ID (128-bit hex string)

* `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 modification status:

* `status` — `"ok"` if request processed
* `response` — Contains modification details:
  * `type` — `"modify"`
  * `data` — Modification result information

## Example request

<CodeGroup>
  ```shell cURL theme={"system"}
  curl -X POST https://api.hyperliquid.xyz/exchange \
    -H "Content-Type: application/json" \
    -d '{
      "action": {
        "type": "modify",
        "oid": 77738308,
        "order": {
          "a": 0,
          "b": true,
          "p": "51000",
          "s": "0.02",
          "r": false,
          "t": {"limit": {"tif": "Gtc"}}
        }
      },
      "nonce": 1234567890123,
      "signature": {...}
    }'
  ```

  ```python Python (hyperliquid-python-sdk) 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)

  # Modify an existing order
  modify_result = exchange.modify_order(
      oid=77738308,
      name="BTC",
      is_buy=True,
      sz=0.02,
      limit_px=51000,
      order_type={"limit": {"tif": "Gtc"}},
      reduce_only=False,
  )

  print(modify_result)
  ```

  ```typescript TypeScript (@nktkas/hyperliquid) theme={"system"}
  import { ExchangeClient, HttpTransport } from "@nktkas/hyperliquid";
  import { privateKeyToAccount } from "viem/accounts";

  // Initialize with your private key
  const wallet = privateKeyToAccount("0x..."); // viem or ethers
  const transport = new HttpTransport(); // public Hyperliquid API
  const exchange = new ExchangeClient({ transport, wallet });

  // Modify an existing order
  const modifyResult = await exchange.modify({
    oid: 77738308,
    order: {
      a: 0,
      b: true,
      p: "51000",
      s: "0.02",
      r: false,
      t: { limit: { tif: "Gtc" } },
    },
  });

  console.log(modifyResult);
  ```
</CodeGroup>

## Modification behavior

* **Priority preservation** — Modifying only the size preserves queue priority
* **Price changes** — Changing the price moves the order to the back of the queue
* **Partial fills** — Can modify partially filled orders (remaining size only)
* **Order types** — Can change between different order types

## Use cases

* **Price adjustment** — Update limit price based on market movements
* **Size scaling** — Increase or decrease order size
* **Strategy updates** — Adjust orders without losing position in queue
* **Risk management** — Convert orders to reduce-only

<Note>
  Modifying an order is more efficient than cancel-and-replace, especially when only changing the size, as it can preserve your position in the order queue.
</Note>

<Warning>
  Some modifications may cause loss of queue priority. Price changes always move the order to the back of the queue at the new price level.
</Warning>


## OpenAPI

````yaml openapi/hyperliquid_node_api/hypercore_exchange/exchange_modify_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: Modify order
      operationId: modifyOrder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                action:
                  type: object
                  properties:
                    type:
                      type: string
                      default: modify
                      enum:
                        - modify
                      description: Action type for modifying orders
                    oid:
                      type: integer
                      description: Order ID to modify
                    order:
                      type: object
                      description: New order parameters
                      properties:
                        a:
                          type: integer
                          description: >-
                            Asset index (use universe index for perps, 10000 +
                            index for spot)
                        b:
                          type: boolean
                          description: >-
                            Is buy order (true for buy/long, false for
                            sell/short)
                        p:
                          type: string
                          description: Limit price (use '0' for market orders)
                        s:
                          type: string
                          description: Size in units of the base asset
                        r:
                          type: boolean
                          description: Reduce only order
                        t:
                          type: object
                          description: Order type specification
                          oneOf:
                            - type: object
                              properties:
                                limit:
                                  type: object
                                  properties:
                                    tif:
                                      type: string
                                      enum:
                                        - Alo
                                        - Ioc
                                        - Gtc
                                      description: >-
                                        Time in force: Alo (add liquidity only),
                                        Ioc (immediate or cancel), Gtc (good til
                                        canceled)
                                  required:
                                    - tif
                            - type: object
                              properties:
                                trigger:
                                  type: object
                                  properties:
                                    isMarket:
                                      type: boolean
                                      description: >-
                                        Whether to place market order when
                                        triggered
                                    triggerPx:
                                      type: string
                                      description: Price at which to trigger the order
                                    tpsl:
                                      type: string
                                      enum:
                                        - tp
                                        - sl
                                      description: Take profit (tp) or stop loss (sl)
                                  required:
                                    - isMarket
                                    - triggerPx
                                    - tpsl
                        c:
                          type: string
                          description: Client order ID (128-bit hex string, optional)
                      required:
                        - a
                        - b
                        - p
                        - s
                        - r
                        - t
                  required:
                    - type
                    - oid
                    - order
                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: modify
                oid: 123456789
                order:
                  a: 0
                  b: true
                  p: '27.5'
                  s: '1.0'
                  r: false
                  t:
                    limit:
                      tif: Gtc
                  c: '0x1234567890abcdef1234567890abcdef'
              nonce: 1705234567890
              signature:
                r: >-
                  0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef
                s: >-
                  0xfedcba0987654321fedcba0987654321fedcba0987654321fedcba0987654321
                v: 27
              vaultAddress: null
      responses:
        '200':
          description: Order modification 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: object
                                  properties:
                                    resting:
                                      type: object
                                      properties:
                                        oid:
                                          type: integer
                                          description: Order ID
                                - type: object
                                  properties:
                                    filled:
                                      type: object
                                      properties:
                                        totalSz:
                                          type: string
                                          description: Total size filled
                                        avgPx:
                                          type: string
                                          description: Average fill price
                                        oid:
                                          type: integer
                                          description: Order ID
                                - type: object
                                  properties:
                                    error:
                                      type: string
                                      description: Error message
                example:
                  status: ok
                  response:
                    type: modify
                    data:
                      statuses:
                        - resting:
                            oid: 77738309

````