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

# Last ID

> Last ID (LI) is a per-symbol sequence number used to order events and detect gaps

### Overview

**Last ID** (LI) is a sequence number Pacifica stamps on exchange events. It increases monotonically within a symbol (and within an account or order), so you can order updates, detect gaps, and correlate effects of the same event across streams. It is not a timestamp, so it is unaffected by clock drift.

It is the `li` field on WebSocket messages and snapshot rows, and the `last_order_id` key on REST snapshot responses.

### Usage

* Order events and detect gaps within the same symbol, account, or order — a larger LI is strictly later.
* Correlate effects of one event: a trade, its order update, and the resulting position change share the same LI.
* Compare LI only within the same symbol/account/order — not across them.

### Snapshots

Snapshot responses carry LI on each row (the latest event for that position or order; `null` for rows the engine has not touched yet) and once on the envelope — `last_order_id` (REST) or the outer `li` (WebSocket `account_positions`) — for the whole set. The envelope advances on closes and labels an empty set.

On reconnect, treat the snapshot as your baseline: replace local state with it, apply live snapshots with an equal or newer LI, and discard older ones.

### Where it appears

* REST: [`/api/v1/positions`](/api-documentation/api/rest-api/account/get-positions), [`/api/v1/orders`](/api-documentation/api/rest-api/orders/get-open-orders), [`/api/v1/trades`](/api-documentation/api/rest-api/markets/get-recent-trades)
* WebSocket: [`bbo`](/api-documentation/api/websocket/subscriptions/best-bid-offer-bbo), [`trades`](/api-documentation/api/websocket/subscriptions/trades), [`orderbook`](/api-documentation/api/websocket/subscriptions/orderbook), [`account_positions`](/api-documentation/api/websocket/subscriptions/account-positions), [`account_order_updates`](/api-documentation/api/websocket/subscriptions/account-order-updates), [`account_trades`](/api-documentation/api/websocket/subscriptions/account-trades)
