> 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/integration-example/limit-orders.md).

# Limit orders

Create, list, get, replace, and cancel off-chain limit orders. Public create and replace requests mirror the quote shape and add `minAmountOut` plus expiry controls.

## Prerequisites

* API key (header `Authorization: Bearer YOUR_API_KEY`)
* Base URL: `https://api.gateway.zert.com/api/v1`

## Step 1: Create a limit order

Call `POST /limit-orders/limit` with the quote-style fields `fromChain`, `toChain`, `tokenIn`, `tokenOut`, and `amount`, plus `minAmountOut`. Create requests require an `Idempotency-Key`.

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

Response includes `data.limitOrderId`, `data.status`, `data.expiresAtMs`, and `data.minAmountOut`.

## Step 2: List your limit orders

Call `GET /limit-orders/limits` to list orders for the authenticated owner. Use query `limit` (1–200) and optional `status` (e.g. `open`, `canceled`).

```bash
curl -X GET 'https://api.gateway.zert.com/api/v1/limit-orders/limits?limit=20&status=open' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

## Step 3: Get or cancel a single order

* **Get:** `GET /limit-orders/limit/{limitOrderId}` — returns full order details.
* **Cancel:** `DELETE /limit-orders/limit/{limitOrderId}` — requires `Idempotency-Key`; optional body `{"reason": "..."}`.

```bash
# Get
curl -X GET 'https://api.gateway.zert.com/api/v1/limit-orders/limit/lim_abc123' \
  -H 'Authorization: Bearer YOUR_API_KEY'

# Cancel
curl -X DELETE 'https://api.gateway.zert.com/api/v1/limit-orders/limit/lim_abc123' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Idempotency-Key: limit-cancel-001' \
  -H 'Content-Type: application/json' \
  -d '{"reason": "user_request"}'
```

## Step 4: Replace an open order

Call `POST /limit-orders/limit/{limitOrderId}/replace` with the same request shape as create. Replacement requests also require `Idempotency-Key`.

```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"
  }'
```

## Summary

| Step | Endpoint                                | Purpose                   |
| ---- | --------------------------------------- | ------------------------- |
| 1    | `POST /limit-orders/limit`              | Create limit order        |
| 2    | `GET /limit-orders/limits`              | List owner's limit orders |
| 3    | `GET /limit-orders/limit/{id}`          | Get one order             |
| 3    | `DELETE /limit-orders/limit/{id}`       | Cancel one order          |
| 4    | `POST /limit-orders/limit/{id}/replace` | Replace an open order     |

See [Create Limit Order](https://docs.zert.com/api-reference/limit-orders/limit-order-create.md), [List Limit Orders](https://docs.zert.com/api-reference/limit-orders/limit-orders-list.md), [Get or Cancel Limit Order](https://docs.zert.com/api-reference/limit-orders/limit-order-get-cancel.md), and [Replace Limit Order](https://docs.zert.com/api-reference/limit-orders/limit-order-replace.md) for full parameters and responses.


---

# 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/integration-example/limit-orders.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.
