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

# Amend Order

> Changes the size, the price, or both of an open limit order in place. The order keeps its `orderId`, `clientOrderId`, and `createdAt`. The `orderID` path parameter can be:

- An internal order ID (e.g. `197ec08e001658690721be129e7fa595`).
- A client order ID prefixed with `client:` (e.g. `client:abc123`).

Send `size`, `price`, or both, with the order's current `version`. A field you omit keeps its current value. `size` is the new total size, including any quantity already filled, so it must be greater than `filledSize`. To drop the rest of an order, cancel it instead.

**Versions.** Every amend increments the order's `version`. An order that was never amended is at version `0` and omits the field. If the order was amended after the version you send, the request returns 409 `amend_version_mismatch` and changes nothing. Read the order again before you retry.

**Queue priority.** Reducing the size at the same price keeps the order's place in the queue. Increasing the size moves the order to the back of its price level. Changing the price moves it to the back of the new price level.

**Crossing the book.** A new price that crosses the book trades immediately, as a new order would, and any remainder rests at the new price. These fills pay the taker fee. As with a new order, your own resting orders that it would match are canceled first (`selfMatchPrevention`). To reject such an amend with `post_only_has_match` instead, set `postOnly: true`. It applies to this amend only and does not change the order's own post-only setting. An order placed as post-only is always amended as post-only: an amend whose new price would match returns `post_only_has_match`, whatever `postOnly` says.

**Validation.** An amend that increases the size or changes the price is validated like a new order, so Create Order's validation errors, such as `insufficient_margin` or `order_price_outside_safe_bounds`, can also be returned. Only open limit orders resting on the book can be amended. Market and IOC orders, stop orders, TWAP child orders, and liquidation orders return `order_not_amendable`. To amend a take profit or stop loss, use Amend Stop Order (`PATCH /v1/perps/stop_order/{orderID}`).

**Take profit and stop loss.** You can amend an order with an attached take profit or stop loss. A new price must stay between their trigger prices (for a buy, above the stop loss and below the take profit), or the request returns `stop_order_crosses_order_price`. The attached orders keep their trigger prices and follow the order's new size. To change a trigger price, use Amend Stop Order. See [Take profit and stop loss](/take-profit-and-stop-loss).

**Order delay.** If an order delay applies to your account, a price amend waits for it before it is applied. Size-only amends and amends with `postOnly: true` are applied without the delay. The delay follows the request, not the order: send `postOnly: true` to amend the price of a post-only order without it.

Each amend counts as one order addition against your account's order-action rate limit. Subscribe to `orderAmendsPerps` to receive each amend with the order's previous size and price.




## OpenAPI

````yaml /api-reference/rest-spec.json patch /v1/perps/orders/{orderID}
openapi: 3.0.3
info:
  title: Ondo Perps REST API
  version: '1.0'
  description: >-
    REST API for Ondo Perps: account, wallet, deposits/withdrawals, API keys,
    Spot trading, internal transfers, and perpetual futures trading.
servers:
  - url: https://api.ondoperps.xyz
security:
  - BearerAuth: []
paths:
  /v1/perps/orders/{orderID}:
    patch:
      tags:
        - Orders
      summary: Amend Order
      description: >
        Changes the size, the price, or both of an open limit order in place.
        The order keeps its `orderId`, `clientOrderId`, and `createdAt`. The
        `orderID` path parameter can be:


        - An internal order ID (e.g. `197ec08e001658690721be129e7fa595`).

        - A client order ID prefixed with `client:` (e.g. `client:abc123`).


        Send `size`, `price`, or both, with the order's current `version`. A
        field you omit keeps its current value. `size` is the new total size,
        including any quantity already filled, so it must be greater than
        `filledSize`. To drop the rest of an order, cancel it instead.


        **Versions.** Every amend increments the order's `version`. An order
        that was never amended is at version `0` and omits the field. If the
        order was amended after the version you send, the request returns 409
        `amend_version_mismatch` and changes nothing. Read the order again
        before you retry.


        **Queue priority.** Reducing the size at the same price keeps the
        order's place in the queue. Increasing the size moves the order to the
        back of its price level. Changing the price moves it to the back of the
        new price level.


        **Crossing the book.** A new price that crosses the book trades
        immediately, as a new order would, and any remainder rests at the new
        price. These fills pay the taker fee. As with a new order, your own
        resting orders that it would match are canceled first
        (`selfMatchPrevention`). To reject such an amend with
        `post_only_has_match` instead, set `postOnly: true`. It applies to this
        amend only and does not change the order's own post-only setting. An
        order placed as post-only is always amended as post-only: an amend whose
        new price would match returns `post_only_has_match`, whatever `postOnly`
        says.


        **Validation.** An amend that increases the size or changes the price is
        validated like a new order, so Create Order's validation errors, such as
        `insufficient_margin` or `order_price_outside_safe_bounds`, can also be
        returned. Only open limit orders resting on the book can be amended.
        Market and IOC orders, stop orders, TWAP child orders, and liquidation
        orders return `order_not_amendable`. To amend a take profit or stop
        loss, use Amend Stop Order (`PATCH /v1/perps/stop_order/{orderID}`).


        **Take profit and stop loss.** You can amend an order with an attached
        take profit or stop loss. A new price must stay between their trigger
        prices (for a buy, above the stop loss and below the take profit), or
        the request returns `stop_order_crosses_order_price`. The attached
        orders keep their trigger prices and follow the order's new size. To
        change a trigger price, use Amend Stop Order. See [Take profit and stop
        loss](/take-profit-and-stop-loss).


        **Order delay.** If an order delay applies to your account, a price
        amend waits for it before it is applied. Size-only amends and amends
        with `postOnly: true` are applied without the delay. The delay follows
        the request, not the order: send `postOnly: true` to amend the price of
        a post-only order without it.


        Each amend counts as one order addition against your account's
        order-action rate limit. Subscribe to `orderAmendsPerps` to receive each
        amend with the order's previous size and price.
      operationId: amendOrder
      parameters:
        - name: orderID
          in: path
          description: >-
            Internal order ID, or `client:{clientOrderID}` for client order ID
            lookup
          required: true
          schema:
            type: string
            example: 197ec08e001658690721be129e7fa595
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AmendOrderReq'
            example:
              size: '12.00'
              price: '228.00'
              version: 0
      responses:
        '200':
          description: Amended order
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/GenericResponse'
                  - type: object
                    properties:
                      result:
                        $ref: '#/components/schemas/ApiOrder'
              example:
                success: true
                result:
                  orderId: 197ec08e001658690721be129e7fa595
                  side: buy
                  price: '228.00'
                  size: '12.00'
                  market: AAPL-USD.P
                  filledSize: '0.00'
                  lastFillSize: '0.00'
                  filledCost: '0.00'
                  fee: '0.00'
                  status: open
                  createdAt: '2025-03-05T14:30:00Z'
                  amendedAt: '2025-03-05T14:32:00Z'
                  version: 1
                  type: limit
                  timeInForce: GTC
        '400':
          description: Bad request. The request was malformed or failed validation.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    description: Human-readable error message
                  error_code:
                    type: string
                    description: >-
                      Amend errors are listed here. An amend that increases the
                      size or changes the price can also return Create Order's
                      validation errors.
                    enum:
                      - amend_field_not_supported
                      - amend_invalid_size
                      - amend_no_change
                      - amend_version_required
                      - order_invalid_price
                      - order_not_amendable
                      - post_only_has_match
                      - stop_order_crosses_order_price
              example:
                success: false
                error: Description of the error
                error_code: amend_no_change
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          description: >-
            Access denied. Order amendment is not enabled for the account, or
            the account or API key lacks permission.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    description: Human-readable error message
                  error_code:
                    type: string
                    enum:
                      - account_closed
                      - account_not_allowed
                      - feature_disabled
                      - forbidden
                      - ip_not_permitted
                      - key_doesnt_have_scope
              example:
                success: false
                error: Description of the error
                error_code: feature_disabled
        '404':
          description: The order does not exist or belongs to another account.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    description: Human-readable error message
                  error_code:
                    type: string
                    enum:
                      - order_not_found
              example:
                success: false
                error: Description of the error
                error_code: order_not_found
        '409':
          description: >-
            The order was amended after the `version` you sent. Nothing changed;
            read the order again before you retry.
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: false
                  error:
                    type: string
                    description: Human-readable error message
                  error_code:
                    type: string
                    enum:
                      - amend_version_mismatch
              example:
                success: false
                error: 'the order is at version 1, not 0: it was amended since'
                error_code: amend_version_mismatch
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    AmendOrderReq:
      type: object
      required:
        - version
      description: >-
        Send `size`, `price`, or both. Any other field returns
        `amend_field_not_supported`.
      properties:
        size:
          type: string
          description: >-
            New total order size in base currency, including any quantity
            already filled. Must be greater than the order's `filledSize` and
            aligned to the market's size increment. Omit to keep the current
            size.
          example: '12.00'
        price:
          type: string
          description: >-
            New limit price, aligned to the market's price increment. Omit to
            keep the current price.
          example: '228.00'
        version:
          type: integer
          minimum: 0
          description: >-
            The order's `version` from your latest view of it: the number of
            times it has been amended, `0` if never. If the order was amended
            since, the request returns `amend_version_mismatch`.
          example: 0
        postOnly:
          type: boolean
          description: >-
            If `true`, the amend returns `post_only_has_match` instead of
            trading when the new price would match. Applies to this amend only
            and does not change the order's own post-only setting. An order
            placed as post-only is always amended as post-only, so `false` does
            not let it trade.
          default: false
          example: false
    GenericResponse:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          description: Whether the request was successful
          example: true
        error:
          type: string
          description: Error message, present only on failure
          example: ''
        error_code:
          type: string
          description: >-
            Semantic error code. See each endpoint's error responses for the
            specific codes it can return.
        deprecated:
          type: string
          description: Deprecation notice, if applicable
          example: ''
    ApiOrder:
      type: object
      required:
        - orderId
        - side
        - price
        - size
        - market
        - filledSize
        - lastFillSize
        - filledCost
        - fee
        - status
        - createdAt
        - type
      properties:
        orderId:
          type: string
          description: Internal order ID
          example: 70a37d8f972f2494837f9dba8364cbb4
        clientOrderId:
          type: string
          description: Client-provided order ID (if set)
          example: order123
        parentOrderId:
          type: string
          description: Parent order ID (e.g. for TWAP child orders)
          example: twap_70a37d8f972f2494837f9dba8364cbb4
        side:
          type: string
          description: buy or sell
          enum:
            - buy
            - sell
          example: buy
        price:
          type: string
          description: Limit price
          example: '1.55'
        size:
          type: string
          description: Order quantity in base currency
          example: '20.30'
        market:
          type: string
          description: Trading market
          example: AAPL-USD.P
        filledSize:
          type: string
          description: Quantity of the order that has been filled
          example: '5.403'
        lastFillSize:
          type: string
          description: Quantity filled in the most recent trade
          example: '5.403'
        filledCost:
          type: string
          description: Cost of the filled portion of the order (filledSize × fill price)
          example: '8.37465'
        realizedPnl:
          type: string
          description: Realized PNL for this order (perps only)
          example: '1.2345'
        fee:
          type: string
          description: Fees incurred on this order
          example: '0.0837'
        feeRebate:
          type: string
          description: Fee rebate earned on this order (perps only)
          example: '0.0042'
        status:
          type: string
          description: Order status
          enum:
            - open
            - fullyfilled
            - canceled
            - pending
            - untriggered
          example: open
        createdAt:
          type: string
          format: date-time
          description: Order creation time
          example: '2022-06-16T12:35:11.123456Z'
        filledAt:
          type: string
          format: date-time
          description: Time when the order was fully filled (if applicable)
          example: '2022-06-16T12:35:11.123456Z'
        canceledAt:
          type: string
          format: date-time
          description: Order cancellation time (if cancelled)
          example: '2022-06-16T12:35:11.123456Z'
        amendedAt:
          type: string
          format: date-time
          description: Time of the order's most recent amend (if amended)
          example: '2026-10-20T08:25:52.581560822Z'
        version:
          type: integer
          description: >-
            Number of times the order has been amended. Omitted until the first
            amend; treat a missing value as `0`. Send it as `version` when you
            amend the order.
          example: 1
        cancelReason:
          type: string
          description: >
            Reason the order was cancelled. Possible values: "" (user
            cancelled), "liquidation", "selfmatchprevention",
            "cancelaftertimeout", "startupbadprice", "immediateorcancel"
          example: liquidation
          enum:
            - ''
            - liquidation
            - selfMatchPrevention
            - cancelAfterTimeout
            - startupBadPrice
            - immediateOrCancel
            - cancelAfterTimeoutOnShutdown
            - cancelOnStartup
            - cancelByAdmin
            - positionClosed
            - stopOrderPositionNeutral
            - stopOrderPositionDirectionMismatch
            - stopOrderInLiquidation
            - stopOrderInternalError
        type:
          type: string
          description: Order type
          enum:
            - limit
            - market
            - stopMarket
            - takeProfitMarket
          example: limit
        timeInForce:
          type: string
          description: Time in force (GTC or IOC). Not returned for market orders.
          enum:
            - GTC
            - IOC
          example: GTC
        reduceOnly:
          type: boolean
          description: Whether the order is reduce-only
          example: false
        liquidationId:
          type: string
          description: ID of the liquidation event this order participated in (perps only)
          example: a1b2c3d4e5f60718293a4b5c6d7e8f90
        closePosition:
          type: boolean
          description: True if this is a position-level TP/SL order
          example: false
        stopOrderType:
          type: string
          description: Stop order type (stopLoss or takeProfit), if applicable
          enum:
            - stopLoss
            - takeProfit
        triggerPrice:
          type: string
          description: Trigger price for stop orders
          example: '125.50'
  responses:
    Unauthorized:
      description: Authentication required. Provide a valid JWT or API key.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                description: Human-readable error message
              error_code:
                type: string
                enum:
                  - api_key_not_found
                  - auth_expired
                  - auth_invalid
                  - auth_missing
                  - failed_to_decode_hex_signature
                  - failed_to_parse_timestamp
                  - signature_mismatch
                  - timestamp_too_far
          example:
            success: false
            error: Description of the error
            error_code: auth_missing
    TooManyRequests:
      description: Rate limit exceeded. Slow down request frequency.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                description: Human-readable error message
              error_code:
                type: string
                enum:
                  - too_many_requests
          example:
            success: false
            error: Description of the error
            error_code: too_many_requests
    InternalServerError:
      description: Internal server error.
      content:
        application/json:
          schema:
            type: object
            properties:
              success:
                type: boolean
                example: false
              error:
                type: string
                description: Human-readable error message
              error_code:
                type: string
                enum:
                  - server_is_busy
                  - service_unavailable
                  - unknown
          example:
            success: false
            error: Description of the error
            error_code: unknown
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
    ApiKeyAuth:
      type: apiKey
      in: header
      name: ONDO-KEY-ID
      description: >-
        Also send ONDO-TIMESTAMP and ONDO-SIGN. See
        /api-reference/api_key_authentication for exact HMAC signing; the key ID
        alone is insufficient.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.