> ## 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 Stop Order

> Changes the trigger price, and for some stop orders the quantity, of a take profit or stop loss in place. The stop order keeps its `orderId`. The `orderID` path parameter is the stop order's internal order ID: Set Stop Order returns it as `orderId`, and Get Orders lists stop orders with their IDs.

Send `triggerPrice`, `quantity`, or both, with the stop order's current `version`. A field you omit keeps its current value. A take profit and a stop loss are separate stop orders, so changing both takes two requests.

**Which stop orders.** You can amend a stop order that has not triggered:

- A position take profit or stop loss set with Set Stop Order (`status: untriggered`).
- A take profit or stop loss attached to an order with `takeProfit` or `stopLoss`, while that order rests on the book, filled or not (`status: pending`), and after the order has fully filled and the stop order is armed (`status: untriggered`).

A stop order that has triggered or been canceled returns `order_not_amendable`, as does an order that is not a stop order: amend a limit order with Amend Order (`PATCH /v1/perps/orders/{orderID}`).

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

**Trigger price.** A new trigger price must be aligned to the market's price increment. An untriggered stop order is checked as a new one is: a trigger price that the mark price has already reached, or that crosses the position's other stop order, returns `invalid_stop_order`. A pending stop order is checked against its order's limit price, as when the order was placed: for a buy order, a take profit above the price and a stop loss below it (for a sell order, the other way round), or the request returns `stop_order_crosses_order_price`. A pending stop order arms at its new trigger price when its order fills, and a later price amend of the order must stay between its trigger prices.

**Quantity.** `quantity` applies to an untriggered stop order that closes part of the position: one set with a `quantity`, or one attached to an order that has filled. It must be aligned to the market's size increment and no larger than the position. A stop order that closes the whole position has no quantity, and a pending stop order always has its order's total size, so both return `amend_field_not_supported` for `quantity`. To change a pending stop order's size, amend its order's size.

Each amend counts as one order addition against your account's order-action rate limit. The amended stop order is published on `ordersPerps` in its current status, never as a cancel. Subscribe to `orderAmendsPerps` to receive each amend with the stop order's previous trigger price and size.




## OpenAPI

````yaml /api-reference/rest-spec.json patch /v1/perps/stop_order/{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/stop_order/{orderID}:
    patch:
      tags:
        - Stop Orders
      summary: Amend Stop Order
      description: >
        Changes the trigger price, and for some stop orders the quantity, of a
        take profit or stop loss in place. The stop order keeps its `orderId`.
        The `orderID` path parameter is the stop order's internal order ID: Set
        Stop Order returns it as `orderId`, and Get Orders lists stop orders
        with their IDs.


        Send `triggerPrice`, `quantity`, or both, with the stop order's current
        `version`. A field you omit keeps its current value. A take profit and a
        stop loss are separate stop orders, so changing both takes two requests.


        **Which stop orders.** You can amend a stop order that has not
        triggered:


        - A position take profit or stop loss set with Set Stop Order (`status:
        untriggered`).

        - A take profit or stop loss attached to an order with `takeProfit` or
        `stopLoss`, while that order rests on the book, filled or not (`status:
        pending`), and after the order has fully filled and the stop order is
        armed (`status: untriggered`).


        A stop order that has triggered or been canceled returns
        `order_not_amendable`, as does an order that is not a stop order: amend
        a limit order with Amend Order (`PATCH /v1/perps/orders/{orderID}`).


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


        **Trigger price.** A new trigger price must be aligned to the market's
        price increment. An untriggered stop order is checked as a new one is: a
        trigger price that the mark price has already reached, or that crosses
        the position's other stop order, returns `invalid_stop_order`. A pending
        stop order is checked against its order's limit price, as when the order
        was placed: for a buy order, a take profit above the price and a stop
        loss below it (for a sell order, the other way round), or the request
        returns `stop_order_crosses_order_price`. A pending stop order arms at
        its new trigger price when its order fills, and a later price amend of
        the order must stay between its trigger prices.


        **Quantity.** `quantity` applies to an untriggered stop order that
        closes part of the position: one set with a `quantity`, or one attached
        to an order that has filled. It must be aligned to the market's size
        increment and no larger than the position. A stop order that closes the
        whole position has no quantity, and a pending stop order always has its
        order's total size, so both return `amend_field_not_supported` for
        `quantity`. To change a pending stop order's size, amend its order's
        size.


        Each amend counts as one order addition against your account's
        order-action rate limit. The amended stop order is published on
        `ordersPerps` in its current status, never as a cancel. Subscribe to
        `orderAmendsPerps` to receive each amend with the stop order's previous
        trigger price and size.
      operationId: amendStopOrder
      parameters:
        - name: orderID
          in: path
          description: The stop order's internal order ID
          required: true
          schema:
            type: string
            example: 3f1c2b9a7d4e4f6a8b0c1d2e3f4a5b6c
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AmendStopOrderReq'
            example:
              triggerPrice: '195.00'
              version: 0
      responses:
        '200':
          description: Amended stop order
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/GenericResponse'
                  - type: object
                    properties:
                      result:
                        $ref: '#/components/schemas/ApiOrder'
              example:
                success: true
                result:
                  orderId: 3f1c2b9a7d4e4f6a8b0c1d2e3f4a5b6c
                  side: sell
                  price: '0'
                  market: AAPL-USD.P
                  filledSize: '0'
                  lastFillSize: '0'
                  filledCost: '0'
                  fee: '0'
                  status: untriggered
                  createdAt: '2025-03-05T14:30:00Z'
                  type: stopMarket
                  closePosition: true
                  stopOrderType: stopLoss
                  triggerPrice: '195.00'
                  version: 1
        '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
                    enum:
                      - amend_field_not_supported
                      - amend_invalid_size
                      - amend_no_change
                      - amend_version_required
                      - basis_trade_order_type_not_allowed
                      - invalid_stop_order
                      - market_halted
                      - order_invalid_price
                      - order_invalid_size
                      - order_not_amendable
                      - price_over_ui_limit_10MM
                      - 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, the
            account cannot manage stop orders (for example, it is closed, or it
            is a subaccount with trading turned off), or the account or API key
            lacks permission. A disabled or offboarding account can still amend
            its stop orders.
          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
                      - trading_disabled
              example:
                success: false
                error: Description of the error
                error_code: feature_disabled
        '404':
          description: The stop 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 stop order was amended after the `version` you sent. Nothing
            changed; read the stop 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 stop order is at version 1, not 0: it was amended since'
                error_code: amend_version_mismatch
        '429':
          $ref: '#/components/responses/TooManyRequests'
      security:
        - BearerAuth: []
        - ApiKeyAuth: []
components:
  schemas:
    AmendStopOrderReq:
      type: object
      required:
        - version
      description: >-
        Send `triggerPrice`, `quantity`, or both. Any other field returns
        `amend_field_not_supported`.
      properties:
        triggerPrice:
          type: string
          description: >-
            New trigger price, aligned to the market's price increment. Omit to
            keep the current trigger price.
          example: '195.00'
        quantity:
          type: string
          description: >-
            New quantity of an untriggered stop order that closes part of the
            position, aligned to the market's size increment and no larger than
            the position. Omit to keep the current quantity. A stop order that
            closes the whole position, and a pending stop order, which has its
            order's size, return `amend_field_not_supported`.
          example: '0.5'
        version:
          type: integer
          minimum: 0
          description: >-
            The stop order's `version` from your latest view of it: the number
            of times it has been amended, `0` if never. If the stop order was
            amended since, the request returns `amend_version_mismatch`.
          example: 0
    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
  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.