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

# Order Status & History

## Record self-submitted order tx

```
POST /api/v1/orders/tx
```

| Field    | Type   | Required | Description                |
| -------- | ------ | -------- | -------------------------- |
| `txHash` | string | Yes      | On-chain transaction hash. |

Indexer backfills `orderId` from chain events.

> Same `txHash` from the same API key returns the existing mapping. A `txHash` already owned by another key returns an error.

## Query orders

### List mappings

```
GET /api/v1/orders?page=1&limit=10
```

### By tx hash

```
GET /api/v1/orders/tx/{txHash}
```

### By order ID

```
GET /api/v1/orders/{orderId}
```

`orderId` must belong to a mapping recorded by the current API key.

## Order detail fields

**Top level:**

| Field                | Type          | Description                                                                                                            |
| -------------------- | ------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `status`             | string        | Broker mapped order status.                                                                                            |
| `deferred`           | boolean       | `true` if this is a [deferred sell](/trading-api/trading/deferred-sell.md) (sell-before-holding, debt-creating) order. |
| `brokerFailedReason` | string        | Failure reason, when applicable.                                                                                       |
| `mapping`            | object        | Partner order-tx mapping.                                                                                              |
| `openOrder`          | object / null | Present while the order is open.                                                                                       |
| `historyOrder`       | object / null | Present once the order has settled.                                                                                    |

**openOrder:**

| Field           | Type   | Description                                                       |
| --------------- | ------ | ----------------------------------------------------------------- |
| `orderId`       | string | On-chain order ID.                                                |
| `userAddress`   | string | User address.                                                     |
| `side`          | string | `Buy` or `Sell`.                                                  |
| `type`          | string | `Market` or `Limit`.                                              |
| `tif`           | string | Time in force.                                                    |
| `symbol`        | string | Symbol.                                                           |
| `placeNotional` | string | Order notional (`0` for limit orders, which use `placeQuantity`). |
| `placeQuantity` | string | Order quantity.                                                   |
| `pay`           | string | Payment amount.                                                   |
| `placePrice`    | string | Order (limit) price.                                              |
| `status`        | string | `placing` or `canceling`.                                         |

**historyOrder** adds:

| Field           | Type          | Description      |
| --------------- | ------------- | ---------------- |
| `settleTxHash`  | string / null | Settlement tx.   |
| `settlePrice`   | string        | Execution price. |
| `settlePay`     | string / null | Actual payment.  |
| `settleReceive` | string / null | Actual received. |
| `mintFee`       | string        | Mint fee.        |
| `protocolFee`   | string        | Protocol fee.    |

See [reference/enums.md](/trading-api/reference/enums.md) for status values.
