> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sx.bet/llms.txt
> Use this file to discover all available pages before exploring further.

# Order Lifecycle

> How order status, fill amounts, and pending fills transition during an order's lifetime.

## Overview

Once an order is on the book, its `status`, `fillAmount`, and `pendingFillAmount` fields tell you where it is in its lifecycle. This page is the reference for what each combination means and how transitions are reported on the [`active_orders`](/api-reference/centrifugo-active-order-updates) and [`order_book`](/api-reference/centrifugo-order-book-updates) WebSocket channels.

## Order status reference

Orders can have one of three statuses:

| Status     | Meaning                                             |
| ---------- | --------------------------------------------------- |
| `ACTIVE`   | Order is live and available to be filled            |
| `INACTIVE` | Order has been cancelled and is no longer available |
| `FILLED`   | Order has been fully filled                         |

## Order fill precision

When an order is fully filled, `fillAmount` may be slightly less than `totalBetSize` due to on-chain arithmetic rounding. An order is considered fully filled — and will receive `status: "FILLED"` — when the remaining unfilled amount is within a small precision tolerance (\~0.001% of `totalBetSize`).

<Warning>Do not use `fillAmount === totalBetSize` to detect a fully filled order. Use `status === "FILLED"` instead.</Warning>

## WebSocket order update sequence

When a taker fills your order, you'll receive the following sequence of updates on the [`active_orders`](/api-reference/centrifugo-active-order-updates) and [`order_book`](/api-reference/centrifugo-order-book-updates) channels.

**1. Fill in progress**

```json theme={null}
{
  "status": "INACTIVE",
  "fillAmount": "0",
  "pendingFillAmount": "2681511700",
  "totalBetSize": "2681520865"
}
```

When a fill that exhausts the remaining order size has been submitted but not yet confirmed on-chain, the order temporarily shows `status: "INACTIVE"` with a non-zero `pendingFillAmount`. This does **not** mean the order was cancelled. The order is being held — no further fills will be accepted against it while it is pending.

**2. Fill confirmed**

```json theme={null}
{
  "status": "FILLED",
  "fillAmount": "2681511700",
  "pendingFillAmount": "0",
  "totalBetSize": "2681520865"
}
```

Once the fill is confirmed on-chain, the order transitions to `FILLED`. Note that `fillAmount` may be marginally less than `totalBetSize` (see [Order fill precision](#order-fill-precision)).

Rarely, a pending fill is rejected on-chain. You'll see a final update where `pendingFillAmount` returns to `0` without `fillAmount` increasing.

## Order states

Read `status` and `pendingFillAmount` together to understand an order's current state.

| `status`   | `pendingFillAmount` | Meaning                                                                                                  |
| ---------- | ------------------- | -------------------------------------------------------------------------------------------------------- |
| `ACTIVE`   | `"0"`               | Live, no fill in progress                                                                                |
| `ACTIVE`   | `> "0"`             | Live, fill in progress                                                                                   |
| `INACTIVE` | `"0"`               | Cancelled, no fill in progress                                                                           |
| `INACTIVE` | `> "0"`             | Fill in progress — either being held mid-confirmation, or the maker cancelled while a fill was in flight |
| `FILLED`   | `"0"`               | Fully filled                                                                                             |

`INACTIVE` with a non-zero `pendingFillAmount` does not by itself tell you whether the maker cancelled or a fill is simply in flight. Both can be true at once — see below.

## Cancelling an order with a pending fill

A maker can cancel an order *after* the [betting delay](/developers/betting-delays) has elapsed and the fill has been submitted to chain, but *before* the fill is confirmed. When this happens:

* The order shows `status: "INACTIVE"` (because you cancelled it) **and** `pendingFillAmount > 0` (because the fill is still in flight).
* The pending fill may still confirm on-chain. If it does, the next update will show an updated `fillAmount` — so a cancelled order can end up with a non-zero final `fillAmount`.
* Once the pending fill resolves on-chain, `pendingFillAmount` returns to `"0"` and `fillAmount` reflects whatever the on-chain settlement ended up being (which may be zero in the rare case that the pending fill was rejected). The order remains `INACTIVE`.

The [cancel endpoints](/api-reference/post-cancel-orders) also return a `pendingFills` array on their response, listing any fills awaiting confirmation against the orders you just cancelled. Use this to know upfront which cancelled orders still have in-flight work.

## Order auto-cancellation

Orders may be automatically cancelled (set to `INACTIVE`) by the exchange when the remaining unfilled size drops below the minimum taker amount. This can occur after a partial fill. The resulting `INACTIVE` update is indistinguishable in structure from a maker-initiated cancellation — both have `pendingFillAmount: "0"` once resolved.

## Related

<CardGroup cols={2}>
  <Card title="Order Management →" icon="list-check" href="/developers/order-management">
    Subscribing to order updates, cancelling, and the heartbeat safety mechanism.
  </Card>

  <Card title="Active Order Updates →" icon="bell" href="/api-reference/centrifugo-active-order-updates">
    WebSocket channel reference for a maker's own orders.
  </Card>

  <Card title="Order Book Updates →" icon="book-open" href="/api-reference/centrifugo-order-book-updates">
    WebSocket channel reference for a market's full order book.
  </Card>

  <Card title="Betting Delays →" icon="clock" href="/developers/betting-delays">
    Why there's a delay between fill submission and on-chain confirmation.
  </Card>
</CardGroup>
