# Reading as of a date

> Read records as they were on a date, as they were recorded at a moment, their history, and the changes feed for exports.

Source: https://docs.ligament.ai/guides/effective-dating/as-of/

Add `asOf` to a read to see dated fields as they were, or will be, on that date. Use it for month-end figures, for checking what applied when an invoice or payslip was produced, and for previews of scheduled changes. This page covers:

-   `asOf` on records, lists and reports;
-   `knownAt`, to read data as it was recorded at an earlier moment, before later corrections;
-   a record’s history;
-   the changes feed, for exports to payroll or finance systems.

The examples use the API. Every parameter has an MCP and a CLI equivalent: see [As-of parameters](https://docs.ligament.ai/developers/as-of/index.md).

## As of a date

```bash
curl -s "https://app.ligament.ai/api/records/employee?asOf=2026-06-30&sort=name" \
  -H "authorization: Bearer $LIGAMENT_API_KEY"
```

On a dated entity, `asOf` changes three things:

-   Dated fields show the value in force on that date. Fields that aren’t dated show today’s value.
-   Records that hadn’t started on that date, or whose first version was rescinded, are left out.
-   Filters, sorting, grouping, counts and sums use the values on that date.

Access doesn’t change. Who may see a record, and which of its fields, is decided by today’s roles and today’s data, whatever date you read.

Each record in the answer gains an `_effective` object that says which version of each group you’re looking at:

```json
{
  "name": "Priya Raman",
  "salary": 88000,
  "pay_grade": "P4",
  "department": "Finance",
  "_effective": {
    "asOf": "2026-10-15",
    "groups": {
      "job": { "from": "2026-03-01", "to": null, "seq": 0, "versionId": "5754af2f-0291-4069-abea-b2803c8030c9", "kind": "create", "reason": "hire" },
      "comp": { "from": "2026-09-01", "to": "2027-01-01", "seq": 0, "versionId": "a772b6fa-2bd9-46e7-9180-9277554179da", "kind": "correction", "reason": "Promotion salary keyed as 86,000; the offer letter says 88,000" }
    },
    "current": ["name", "email"],
    "dated": true
  }
}
```

`current` lists the fields shown at today’s value. `to: null` means the version has no end date yet.

Asking for one record on a date before it started returns 404:

```json
{ "code": "effective_not_started", "message": "This employee didn't exist yet on 2026-02-01", "details": { "asOf": "2026-02-01" } }
```

On an entity that isn’t dated, `asOf` returns today’s values, and `_effective.dated` is `false`.

### What `asOf` accepts

| Value | Means |
| --- | --- |
| `2026-06-30` | That date, from midnight in your workspace’s time zone. |
| `@today` | Today in your workspace’s time zone. |
| `@today-7d`, `@today+2w` | Days (`d`) or weeks (`w`) before or after today. Encode `+` as `%2B` in a URL. |
| `@end_of_last_month` | The last day of the previous month. |
| `@end_of_last_quarter`, `@end_of_last_year` | The last day of the previous quarter or year. |
| `2026-08-31T23:30:00Z` | An instant, read as the date it falls on in your workspace’s time zone (in Bangkok, 1 September). |

Anything else is refused with `effective_bad_as_of`.

**Tip**

A list without `asOf` shows the stored values of every record, including people whose start date is still ahead. Use `asOf=@today` to list only records that are in force today.

### Headcount and totals on a date

Reports take `asOf` too. This counts active employees in three departments at the end of June:

```bash
curl -s -X POST "https://app.ligament.ai/api/reports/run" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  -d '{"spec":{"entityKey":"employee","metric":"count","groupBy":"department","viz":"bar","asOf":"2026-06-30",
       "filters":[{"field":"employment_status","op":"eq","value":"active"},
                  {"field":"department","op":"in","values":["Finance","Operations","Engineering"]}]}}'
```

```json
{
  "data": {
    "buckets": [
      { "key": "Finance", "value": 2, "label": "Finance" },
      { "key": "Operations", "value": 2, "label": "Operations" }
    ],
    "effective": { "asOf": "2026-06-30", "knownAt": null, "dated": true }
  }
}
```

For a figure at several dates, use `series` instead of `asOf`. It evaluates the report at the end of each period (or the start, with `"at": "start"`), up to 120 points:

```json
{ "spec": { "entityKey": "employee", "metric": "count", "viz": "line",
            "filters": [{ "field": "employment_status", "op": "eq", "value": "active" },
                        { "field": "department", "op": "in", "values": ["Finance", "Operations", "Engineering"] }],
            "series": { "every": "month", "from": "2026-07", "to": "2027-01" } } }
```

```json
{
  "data": {
    "series": [
      { "at": "2026-07-31", "value": 4 }, { "at": "2026-08-31", "value": 4 }, { "at": "2026-09-30", "value": 4 },
      { "at": "2026-10-31", "value": 4 }, { "at": "2026-11-30", "value": 3 }, { "at": "2026-12-31", "value": 3 },
      { "at": "2027-01-31", "value": 4 }
    ],
    "effective": { "asOf": null, "knownAt": null, "dated": true }
  }
}
```

`every` is `day`, `week`, `month`, `quarter` or `year`. `from` and `to` take `YYYY`, `YYYY-MM` or a full date. Dates after today read scheduled changes, so the last point already counts a hire who starts on 4 January.

## As recorded at an earlier moment

`asOf` reads the data as it is known now, corrections included. `knownAt` reads it as it was **recorded** at an earlier moment, before later corrections. Use it to explain a figure someone saw last week, or to reproduce an export exactly.

Priya’s salary for October was recorded as 86,000 and corrected to 88,000 two seconds later. Reading October as recorded between the two writes:

```bash
curl -s "https://app.ligament.ai/api/records/employee/cmx6ai0dx007r6x6stm9adjh5?asOf=2026-10-15&knownAt=2026-12-02T15:38:01Z" \
  -H "authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "record": {
    "name": "Priya Raman",
    "salary": 86000,
    "pay_grade": "P4",
    "_effective": {
      "asOf": "2026-10-15",
      "knownAt": "2026-12-02T15:38:01.000Z",
      "groups": { "comp": { "from": "2026-09-01", "to": "2027-01-01", "kind": "change", "reason": "promotion", "…": "…" } }
    }
  }
}
```

`knownAt` takes an instant, or a date, which means “everything recorded by the end of that day” in your workspace’s time zone. You can combine it with `asOf` on records and lists.

Reading as recorded is limited, because it shows values that were later corrected:

-   People need the `records.as_recorded` capability. Owners and admins have it; grant it to others through a [permission set](https://docs.ligament.ai/guides/access/roles-and-permission-sets/index.md).
-   An API key may use it if it holds the `audit:read` scope.

Anyone else gets 403 `effective_known_at_forbidden`.

## A record’s history

`GET /api/records/<entity>/<id>/history` lists a record’s versions, newest first, one group or all of them:

```bash
curl -s "https://app.ligament.ai/api/records/employee/cmx6ai0dx007r6x6stm9adjh5/history?group=comp" \
  -H "authorization: Bearer $LIGAMENT_API_KEY"
```

```json
{
  "entity": "employee",
  "recordId": "cmx6ai0dx007r6x6stm9adjh5",
  "entries": [
    { "group": "comp", "from": "2027-01-01", "to": null, "kind": "change", "reason": "merit", "status": "scheduled",
      "values": { "salary": 90000, "pay_grade": "P4" }, "recordedAt": "2026-12-02T15:38:00.168Z", "…": "…" },
    { "group": "comp", "from": "2026-09-01", "to": "2027-01-01", "kind": "correction",
      "reason": "Promotion salary keyed as 86,000; the offer letter says 88,000", "status": "in_force",
      "values": { "salary": 88000, "pay_grade": "P4" }, "…": "…" },
    { "group": "comp", "from": "2026-03-01", "to": "2026-09-01", "kind": "create", "reason": "hire", "status": "past",
      "values": { "salary": 84000, "pay_grade": "P3" }, "…": "…" }
  ],
  "proposed": null,
  "knownAt": null
}
```

Each entry also carries `versionId` (what you name in a correction or rescind), `seq`, `retro`, `changeId`, `by` and `recordedAt`.

| Status | Means |
| --- | --- |
| `scheduled` | Starts after today. |
| `in_force` | Applies today. |
| `past` | Ended before today. |
| `same_day` | An earlier change of a day that was changed again the same day. |
| `superseded` | Replaced by a correction, a rescind or a later rewrite. Only shown with `include=corrections`. |

Add `include=corrections` to see superseded versions too, with `supersededAt` and `supersededBy`, or `knownAt` to see the history as it stood at a moment. Both need `records.as_recorded` or an `audit:read` key.

The history follows field access: fields you can’t read are removed from every version, and a group whose fields you can’t read doesn’t appear at all.

## The changes feed for exports

A payroll or finance export has to send every change since its last run, including corrections to periods it has already sent. The changes feed gives you exactly that:

```bash
curl -s "https://app.ligament.ai/api/records/employee/changes?group=comp&recordedSince=2026-12-02T15:37:57Z&overlapsBefore=2026-12-01" \
  -H "authorization: Bearer $LIGAMENT_API_KEY"
```

It lists every change **recorded** after `recordedSince` (new changes, corrections and rescinds), oldest first, on records you can read now. `overlapsBefore=2026-12-01` keeps only changes that touch a period before 1 December, the periods already paid. One of the two changes it returned:

```json
{
  "changes": [
    { "changeId": "8e34d954-4c1a-4ab8-9fb2-6e5891f7d52a", "mode": "change", "reason": "promotion", "…": "…" },
    {
      "changeId": "b63d8809-b089-4864-b265-cae2b6f364ff",
      "recordId": "cmx6ai0dx007r6x6stm9adjh5",
      "group": "comp",
      "mode": "correction",
      "recordedAt": "2026-12-02T15:38:02.433Z",
      "reason": "Promotion salary keyed as 86,000; the offer letter says 88,000",
      "retro": false,
      "periods": [{ "from": "2026-09-01", "to": "2027-01-01", "fields": ["salary"] }],
      "after": [{ "from": "2026-09-01", "to": "2027-01-01", "values": { "salary": 88000, "pay_grade": "P4" } }],
      "before": [{ "from": "2026-09-01", "to": "2027-01-01", "values": { "salary": 86000, "pay_grade": "P4" } }]
    }
  ],
  "nextCursor": null,
  "watermark": "2026-12-02T15:38:02.433Z"
}
```

For each change, `periods` says which dates and fields changed: those are what your export re-sends. `after` holds the values now. `before` holds the values they replaced, for readers with `records.as_recorded` or an `audit:read` key (`null` for everyone else).

To run an export on a schedule:

1.  Keep the `watermark` of your last run. On the first run, use the moment you start exporting.
2.  Call the feed with `recordedSince=<watermark>`. Narrow it with `group`, `effectiveFrom` and `effectiveTo` (only changes whose periods overlap those dates), or `overlapsBefore`.
3.  Follow `nextCursor` (pass it as `cursor`) until it’s `null`. Pages hold up to 100 changes by default, 500 with `limit`.
4.  Store the new `watermark`. When nothing changed, the feed returns `"watermark": null`: keep the old one.
