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

# Replace Limit Order

Atomically creates a replacement order and cancels the referenced open order. The replacement receives a new `limitOrderId`.

**Endpoint:** `POST /api/v1/limit-orders/limit/{limitOrderId}/replace`\
**Auth:** Required (`Authorization: Bearer YOUR_API_KEY`)

## Headers

| Header            | Type   | Required | Description                                                                                                                   |
| ----------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
| `Idempotency-Key` | string | Yes      | Required opaque dedupe token. Use UUIDv4 or ULID. Allowed characters: `A-Z`, `a-z`, `0-9`, `.`, `_`, `:`, `-`. Max 200 chars. |

## Path parameters

| Parameter      | Type   | Required | Description                    | Example      |
| -------------- | ------ | -------- | ------------------------------ | ------------ |
| `limitOrderId` | string | Yes      | Existing open order to replace | `lim_abc123` |

## Request body

Request shape matches `POST /api/v1/limit-orders/limit`.

| Field           | Type    | Required | Description                       | Example         |
| --------------- | ------- | -------- | --------------------------------- | --------------- |
| `fromChain`     | string  | Yes      | Source chain identifier           | `"arbitrum"`    |
| `toChain`       | string  | Yes      | Destination chain identifier      | `"avax"`        |
| `tokenIn`       | string  | Yes      | Input token identifier            | `"TBTC"`        |
| `tokenOut`      | string  | Yes      | Output token identifier           | `"WETH"`        |
| `amount`        | string  | Yes      | Human amount string               | `"100.00"`      |
| `minAmountOut`  | string  | Yes      | Minimum output amount             | `"1"`           |
| `timeInForce`   | string  | No       | `GTC`, `GTD`, `IOC`, or `FOK`     | `"GTC"`         |
| `expiresAtMs`   | integer | No       | Absolute expiry in ms since epoch | `1745407200000` |
| `expireAfterMs` | integer | No       | Relative expiry in ms             | `86400000`      |
| `network`       | string  | No       | `mainnet` or `testnet`            | `"mainnet"`     |
| `slippageBps`   | integer | No       | Quote-time slippage hint          | `75`            |
| `recipient`     | string  | No       | Recipient address                 | `"0x1234..."`   |

## Example

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST 'https://api.gateway.zert.com/api/v1/limit-orders/limit/lim_abc123/replace' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Idempotency-Key: limit-replace-001' \
  -d '{
    "timeInForce": "GTC",
    "minAmountOut": "2",
    "fromChain": "arbitrum",
    "toChain": "avax",
    "tokenIn": "TBTC",
    "tokenOut": "WETH",
    "network": "mainnet",
    "amount": "100.00",
    "slippageBps": 75,
    "recipient": "0x1234567890123456789012345678901234567890"
  }'
```

{% endtab %}

{% tab title="Example Response" %}

```json
{
  "data": {
    "limitOrderId": "lim_replacement_456",
    "status": "open",
    "expiresAtMs": 1745407200000,
    "minAmountOut": "2",
    "replacesLimitOrderId": "lim_abc123"
  },
  "meta": {
    "requestId": "req_xyz",
    "timestamp": "2026-04-23T12:00:00.000Z"
  }
}
```

{% endtab %}
{% endtabs %}

## Responses

| Code | Description                                   |
| ---- | --------------------------------------------- |
| 200  | Replaced                                      |
| 400  | Invalid request                               |
| 401  | Unauthorized                                  |
| 403  | Forbidden                                     |
| 404  | Not found                                     |
| 409  | Order not replaceable or idempotency conflict |
| 503  | PG unavailable                                |

{% embed url="<https://api.gateway.zert.com/docs>" %}
Zert API — Replace Limit Order
{% endembed %}


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.zert.com/api-reference/limit-orders/limit-order-replace.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
