> For the complete documentation index, see [llms.txt](https://docs.nexus.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexus.xyz/api-reference/trading/edit-order-v1.md).

# PATCH /api/v1/orders/{order\_id}

Amend an order.

`operationId`: `editOrderV1` · CCXT method: `editOrder` · Rate-limit class: `trading`

**Authentication:** `hmacAuth`.

Atomic cancel-replace amend of a resting order: changes the price and/or size in a single operation. At least one of `price` or `size` must be supplied. Liquidation orders are not amendable, and a pre-trade margin check is applied to the projected replacement before it is accepted. That check excludes the reservation still held by the order being replaced, so an amend is sized on the margin the replacement actually adds rather than on the original and the replacement together: repricing a resting order at the same size needs no additional margin, and shrinking one frees margin rather than requiring it.

An amend does not restart execution. The replacement carries the original's `filled_qty` forward, so `quantity` stays the total you asked for and an order can never execute more than that total, across any number of amends: a Buy 5 that has filled 2 has 3 left to execute both before and after a reprice, and the replacement comes back as `PartiallyFilled` rather than `Open`. `size` sets the new TOTAL quantity, fills included, and must be greater than `filled_qty` — a size at or below it is rejected with InvalidAmend; cancel the order instead.

## Parameters

| Name        | In    | Type     | Required | Description                                       |
| ----------- | ----- | -------- | -------- | ------------------------------------------------- |
| `order_id`  | path  | `string` | Yes      | —                                                 |
| `market_id` | query | `string` | Yes      | Market the order rests on (required for routing). |

## Request body

**Required.** [`AmendOrderRequest`](/api-reference/guides/schemas.md#amendorderrequest) — `application/json`.

```json
{
  "price": "50100",
  "size": "0.2"
}
```

## Responses

| Status | Body                                              | Meaning                                                                                                                                                                                                                                                                                                                                                                                              |
| ------ | ------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `200`  | [`Order`](/api-reference/guides/schemas.md#order) | Amended order (the replacement, with a fresh id).                                                                                                                                                                                                                                                                                                                                                    |
| `400`  | — *(no schema declared)*                          | Invalid amend (empty body, invalid price/size, order not amendable, or margin breach)                                                                                                                                                                                                                                                                                                                |
| `401`  | — *(no schema declared)*                          | —                                                                                                                                                                                                                                                                                                                                                                                                    |
| `403`  | — *(no schema declared)*                          | —                                                                                                                                                                                                                                                                                                                                                                                                    |
| `404`  | — *(no schema declared)*                          | Order not found                                                                                                                                                                                                                                                                                                                                                                                      |
| `409`  | — *(no schema declared)*                          | The market-lifecycle admission gate, evaluated on the replacement before the original is touched: `MarketHalted` when the market is halted, `MarketReduceOnly` when the market is in reduce-only and the replacement is neither `reduce_only` nor a liquidation, and `MarketSuspended` when the market is settling or delisted. Rejected atomically — the original order is left resting, untouched. |
| `429`  | — *(no schema declared)*                          | —                                                                                                                                                                                                                                                                                                                                                                                                    |

## Example

```bash
curl -X PATCH 'https://exchange.nexus.xyz/api/exchange/api/v1/orders/{order_id}' \
  -H 'X-API-Key: nx_7f3a1b...' \
  -H 'X-Timestamp: 1776033911836' \
  -H 'X-Signature: <hmac-sha256>' \
  -H 'Content-Type: application/json'
```

***

<sub>Generated from</sub> <sub></sub><sub>`eng/apps/exchange/api/openapi.json`</sub> <sub></sub><sub>(spec</sub> <sub></sub><sub>`0.9.27`</sub><sub>). Do not edit by hand — regenerate with</sub> <sub></sub><sub>`python3 product/docs/tools/api-reference/generate.py`</sub><sub>. Hand-authored context lives in the Guides pages.</sub>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.nexus.xyz/api-reference/trading/edit-order-v1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
