# Lists, filters and pagination

> Filter, sort, search and page through records.

Source: https://docs.ligament.ai/developers/pagination/

`GET /api/records/<entity>` lists records. With query parameters you can filter, combine filters with AND or OR, sort, search, group with totals and page through any number of rows. Use it for exports, syncs and dashboards. Every example on this page lists incidents with a read-only key, and every response is real (rows trimmed).

The list only ever returns records the key’s creator can read, and leaves out fields they can’t see. Filters, sorting and grouping on a hidden field match nothing rather than revealing what’s in it.

## Parameters

| Parameter | Example | What it does |
| --- | --- | --- |
| `limit` | `limit=50` | Rows per page. Default 100, at most 1000 |
| `cursor` | `cursor=MjAy…` | Fetch the page after this cursor (keyset paging) |
| `offset` | `offset=100` | Skip this many rows (offset paging) |
| `filters` | `filters=[{"field":"priority","op":"eq","value":"high"}]` | JSON array of filters, URL-encoded |
| `filterField`, `filterValue` | `filterField=state&filterValue=in_progress` | Shorthand for one `eq` filter |
| `match` | `match=any` | Combine `filters` with OR instead of AND |
| `sort` | `sort=-priority,createdAt` | Sort by up to five fields; `-` means descending |
| `q` | `q=vpn` | Free-text search across the fields you can read |
| `groupBy` | `groupBy=priority` | Order rows by a field’s groups and add per-group counts |
| `count` | `count=0` | Skip counting the total |

Dated entities also take `asOf` and `knownAt`; see [Reading records as of a date](https://docs.ligament.ai/developers/as-of/index.md).

## The response

```json
{
  "rows": [ … ],
  "total": 39,
  "nextCursor": "MjAyNi0xMS0zMFQwNTozOTo1Mi40MDJafGNteDJ1OWl2bDAwMzdqdzFoZ2h2ZWxpYm8",
  "nextOffset": 3
}
```

| Field | Meaning |
| --- | --- |
| `rows` | The records on this page |
| `total` | How many records match, or `null` when it wasn’t counted (cursor pages and `count=0`) |
| `nextCursor` | Pass as `cursor` to get the next page. `null` on the last page, and when you sort, search or group |
| `nextOffset` | Pass as `offset` to get the next page, when you page by offset. `null` on the last page |
| `summary` | Only with `groupBy` (or `summary=1`), on the first page: counts and numeric totals |

## Paging

The default order is newest first. In that order, page with the cursor. It’s fast at any depth, and rows created while you page don’t shift the pages you haven’t fetched yet.

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=3" -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "rows": [
    { "number": "INC0000050", "priority": "high", "state": "new", … },
    { "number": "INC0000049", "priority": "low", "state": "new", … },
    { "number": "INC0000042", "priority": "medium", "state": "new", … }
  ],
  "total": 39,
  "nextCursor": "MjAyNi0xMS0zMFQwNTozOTo1Mi40MDJafGNteDJ1OWl2bDAwMzdqdzFoZ2h2ZWxpYm8"
}
```

Send the cursor back for the next page, with the same filters:

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=3&cursor=MjAyNi0xMS0zMFQwNTozOTo1Mi40MDJafGNteDJ1OWl2bDAwMzdqdzFoZ2h2ZWxpYm8" \
  -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "rows": [
    { "number": "INC0000035", "priority": "critical", "state": "in_progress", … },
    { "number": "INC0000034", "priority": "critical", "state": "in_progress", … },
    { "number": "INC0000033", "priority": "low", "state": "new", … }
  ],
  "total": null,
  "nextCursor": "MjAyNi0xMS0yOVQxMzozNjo1My40NjVafGNteDF2djRkNDAxMXFmZXV0Z2lxanZwM2I"
}
```

Cursor pages don’t count the total (`total: null`), so keep the one from the first page. Stop when `nextCursor` is `null`.

As soon as you `sort`, search with `q` or `groupBy`, paging switches to offsets: `nextCursor` is `null` and `nextOffset` tells you where the next page starts. You can also use `offset` in the default order. To save a count on every page of a long offset scroll, add `count=0` after the first page:

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=3&offset=3&count=0" -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{ "rows": [ … 3 rows … ], "total": null, "nextOffset": 6, … }
```

## Filters

`filters` is a JSON array, URL-encoded. Each filter has a `field`, an `op` and a `value` (or `values` for `in`):

| `op` | Matches when the field |
| --- | --- |
| `eq` / `ne` | equals / doesn’t equal `value` |
| `contains` | contains `value`, ignoring case |
| `in` | equals one of `values` |
| `lt`, `lte`, `gt`, `gte` | is less / greater than `value`. Numbers compare as numbers, dates and date-times as dates, anything else as text |
| `empty` / `not_empty` | has no value / has a value |

You can filter on any field you can read, and on `id`, `state`, `createdAt`, `updatedAt`, `createdBy` and `updatedBy`. Values are compared as text, so send `"true"` for a checkbox and `"2026-11-30"` for a date.

Open incidents that are critical or high:

```sh
curl -s -G "https://app.ligament.ai/api/records/incident" \
  -H "Authorization: Bearer $LIGAMENT_API_KEY" \
  --data-urlencode 'filters=[{"field":"priority","op":"in","values":["critical","high"]},{"field":"state","op":"ne","value":"closed"}]' \
  --data-urlencode 'limit=3'
```

```json
{
  "rows": [
    { "number": "INC0000050", "priority": "high", "state": "new", … },
    { "number": "INC0000035", "priority": "critical", "state": "in_progress", … },
    { "number": "INC0000034", "priority": "critical", "state": "in_progress", … }
  ],
  "total": 17,
  "nextCursor": "MjAyNi0xMS0yOVQxMzozNjo1My41MTFafGNteDF2djRlZjAxMXZmZXV0b3ZhbHNjZDg"
}
```

Incidents created on or after 30 November:

```sh
--data-urlencode 'filters=[{"field":"createdAt","op":"gte","value":"2026-11-30"}]'
```

Filters on a field that doesn’t exist are ignored, and so is a `filters` value that isn’t valid JSON. If a list comes back larger than you expected, check the field keys and the JSON first.

### `@me`

`@me` as a `value` (or one of the `values`) means the person the key acts for, its creator. With a key Ada created, the incidents assigned to her:

```sh
--data-urlencode 'filters=[{"field":"assigneeId","op":"eq","value":"@me"}]'
```

`@me` only changes what your filter asks for. What the key may read is still decided by its scopes and its creator’s role. The same applies to `filters` in a report spec (`POST /api/reports/run`).

### Any instead of all

Filters are combined with AND. Add `match=any` to combine them with OR. The same two filters, critical **and** escalated, then critical **or** escalated:

```sh
--data-urlencode 'filters=[{"field":"priority","op":"eq","value":"critical"},{"field":"escalated","op":"eq","value":"true"}]'
```

| Matching | `total` |
| --- | --- |
| default (all) | 12 |
| `match=any` | 24 |

## Sorting

`sort` takes a comma-separated list of up to five fields, each optionally prefixed with `-` for descending. Choice fields sort in the order their options are defined, and lifecycle states in lifecycle order, so `-priority` puts critical first:

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=3&sort=-priority,createdAt" -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "rows": [
    { "number": "INC0000056", "priority": "critical", "title": "VPN drops every 15-20 minutes for the Ba…", … },
    { "number": "INC0000005", "priority": "critical", "title": "Inference latency p95 above 2s", … },
    { "number": "INC0000012", "priority": "critical", "title": "Staging cluster nodes NotReady", … }
  ],
  "total": 39,
  "nextCursor": null,
  "nextOffset": 3
}
```

Empty values sort last.

## Search

`q` searches the text of the fields you can read, ignoring case. It combines with filters.

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=3&q=vpn" -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "rows": [
    { "number": "INC0000042", "title": "VPN keeps disconnecting on macOS", … },
    { "number": "INC0000031", "title": "VPN disconnects every 10 minutes (#30)", … },
    { "number": "INC0000016", "title": "VPN disconnects every 10 minutes (#15)", … }
  ],
  "total": 5,
  "nextCursor": null,
  "nextOffset": 3
}
```

## Grouping and totals

`groupBy=<field>` orders the rows group by group and, on the first page, adds a `summary` with the count per group and the sum of each number field, overall and per group. It’s what you need for a chart or a board without fetching every row:

```sh
curl -s "https://app.ligament.ai/api/records/incident?limit=2&groupBy=priority" -H "Authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "rows": [ … ],
  "total": 39,
  "nextCursor": null,
  "nextOffset": 2,
  "summary": {
    "total": 39,
    "sums": { "resolution_minutes": null, "reopen_count": 6 },
    "groups": [
      { "key": "low", "count": 10, "sums": { "resolution_minutes": null, "reopen_count": 2 } },
      { "key": "medium", "count": 10, "sums": { "resolution_minutes": null, "reopen_count": 2 } },
      { "key": "high", "count": 6, "sums": { "resolution_minutes": null, "reopen_count": 2 } },
      { "key": "critical", "count": 13, "sums": { "resolution_minutes": null, "reopen_count": null } }
    ]
  }
}
```

A sum is `null` when no record in that group has a value for the field. Add `summary=1` without `groupBy` to get the overall totals only.

## The same from MCP and the CLI

The MCP tool [`records_query`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_query) takes the same filters, `match`, `sort`, `q`, `limit` and `offset` as JSON arguments. The CLI’s `ligament records list` takes filters as `field.op.value`:

```sh
ligament records list incident -f priority.eq.critical -f state.eq.in_progress --sort=-createdAt -n 2
```
