# As-of parameters

> Read and write effective-dated records over the API, MCP and the CLI: asOf, knownAt, effective, history, the changes feed and error codes.

Source: https://docs.ligament.ai/developers/as-of/

This page lists every parameter for effective-dated records. For what the modes mean and when to use them, start with the guides: [Changes, corrections and rescinds](https://docs.ligament.ai/guides/effective-dating/changes-and-corrections/index.md) and [Reading as of a date](https://docs.ligament.ai/guides/effective-dating/as-of/index.md). The [worked example](https://docs.ligament.ai/guides/effective-dating/hr-example/index.md) shows real calls end to end.

Effective dating is switched on per entity (see [Effective dating](https://docs.ligament.ai/guides/effective-dating/index.md#turning-it-on)). On an entity that isn’t dated, `asOf` returns today’s values. Send `effective` in writes to dated entities only.

## Scopes

| Call | API key scope |
| --- | --- |
| Reads, history, changes feed | `records:read` or `records:read:<entity>` |
| Writes, batch | `records:write` or `records:write:<entity>` |
| `knownAt`, `include=corrections`, `before` values in the feed | `audit:read`, or a key whose creator holds `records.as_recorded` |

A key acts as the person who created it, capped at their current role, so access rules and capabilities apply as they would to that person. See [API keys](https://docs.ligament.ai/developers/api-keys/index.md) and [Scopes](https://docs.ligament.ai/reference/scopes/index.md).

## Dates

-   A date `YYYY-MM-DD` means 00:00 on that day in the workspace’s time zone.
-   A version runs from its `from` date up to, not including, its `to` date. `to` is `null` (or `"infinity"` in write responses) when the version has no end.

## Reading: `asOf` and `knownAt`

These query parameters work on `GET /api/records/<entity>` (with `filters`, `sort`, `q`, `groupBy` and `summary=1`) and on `GET /api/records/<entity>/<id>`.

| Parameter | Accepts | Effect |
| --- | --- | --- |
| `asOf` | `YYYY-MM-DD`, an ISO instant, `@today`, `@today±N[d|w]`, `@end_of_last_month`, `@end_of_last_quarter`, `@end_of_last_year` | Dated fields show the version in force on that date; other fields show today’s value. Records not started on that date are left out of lists, and `GET` one returns 404 `effective_not_started`. Filters, sorting, grouping and summary sums use the as-of values. |
| `knownAt` | An ISO instant, or a date (= the end of that day in the workspace’s zone) | Reads the versions as they were recorded at that moment. Combine with `asOf`; without `asOf`, the date is today. Needs `records.as_recorded` or an `audit:read` key, else 403 `effective_known_at_forbidden`. |

Access is always decided now, on today’s data. In a URL, encode `+` in `@today+2w` as `%2B`.

Each record read with either parameter has an `_effective` object:

| Field | Contains |
| --- | --- |
| `asOf` | The resolved date. |
| `knownAt` | The resolved instant, when asked for. |
| `groups` | Per dated group: `{ from, to, seq, versionId, kind, reason }` of the version shown, or `null` when the group has no version on that date. Groups whose fields you can’t read are left out. |
| `current` | The fields shown at today’s value (not dated). |
| `dated` | `false` on an entity that isn’t dated. |

### Reports

`POST /api/reports/run` takes `asOf` or `series` inside `spec`:

| Field | Accepts |
| --- | --- |
| `spec.asOf` | The same values as the `asOf` parameter. |
| `spec.series` | `{ every: "day"|"week"|"month"|"quarter"|"year", from, to, at?: "end"|"start" }`. `from` and `to` are `YYYY`, `YYYY-MM` or `YYYY-MM-DD`. Evaluates the report at each period’s end (or start), at most 120 points, else 422 `effective_bad_series`. |

The answer has `data.buckets` (with `asOf`) or `data.series: [{ at, value }]` (or `{ at, buckets }` with `groupBy`), plus `data.effective: { asOf, knownAt, dated }`.

## Writing: `effective`

`POST /api/records/<entity>` and `PATCH /api/records/<entity>/<id>` take an `effective` object next to the values. Send the values flat (`{ "salary": 90000, "effective": { … } }`) or in an envelope (`{ "values": { "salary": 90000 }, "effective": { … } }`). Use the envelope only together with `effective`.

| Field | Type | Meaning |
| --- | --- | --- |
| `from` | `YYYY-MM-DD` | `change`: the date the values apply from (default today). `correction`: a date the version to correct is in force on, or with `version`, its new start date. `rescind`: a date the version to remove is in force on. On create: the record’s start date. |
| `reason` | string | A reason slug from the group’s list for a change. Any text for a correction or rescind. |
| `mode` | `change` | `correction` | `rescind` | Default `change`. A create takes only `change`. |
| `version` | version id | The version to correct (re-time) or rescind, from the history. |
| `group` | group key | The group of a rescind by date. |
| `baseVersion` | version id | The version your client showed. If it was replaced meanwhile, 409 `effective_conflict` with the current versions in `details.current`. |

Without `effective`, a write to dated fields is a change from today, unless a group requires an effective date. Only dated values that differ from today’s are recorded. Non-dated fields in the same request are always written as today.

The response adds `effective`, one entry per group written:

| Field | Contains |
| --- | --- |
| `group`, `mode`, `changeId` | What was written. `changeId` matches the history and the changes feed. |
| `version` | `{ id, from, to, seq, status }` of the version written (`null` for a rescind). `status` is `scheduled`, `in_force` or `past`. |
| `rescinded` | `{ id, from, to }` of the version a rescind removed. |
| `propagated` | Later versions this write rewrote: `[{ from, fields }]`. |
| `warnings` | Human-readable notes: a later change that now carries these values, a second change on the same day. |
| `periods` | The date ranges whose values changed, with their fields. |
| `past`, `retroPeriod` | Whether the write changed a date before today, and that past range. |
| `retro` | The write went through a [locked period](https://docs.ligament.ai/guides/effective-dating/locked-periods/index.md). |

`record` in the response always shows today’s values.

### Batch

`POST /api/records/batch` writes several dated records as one change, all or nothing:

```json
{ "items": [ { "entity": "employee", "id": "<id>", "values": { "location": "Chiang Mai" }, "effective": { "from": "2027-03-01", "reason": "transfer" } } ] }
```

Up to 200 items, dated fields only (`effective_batch_plain` otherwise). The key needs `records:write` and write access to each item’s entity. The answer is `{ items: [{ entity, id, record, effective }] }`.

## History

`GET /api/records/<entity>/<id>/history`

| Parameter | Meaning |
| --- | --- |
| `group` | One group. Default: all. |
| `include=corrections` | Also list superseded versions. Needs `records.as_recorded` or `audit:read`. |
| `knownAt` | The history as recorded at that instant. Same rights. |

Answer: `{ entity, recordId, groups: [{ key, label, fields }], entries, proposed: null, knownAt }`. Each entry has `versionId, group, from, to, seq, kind, reason, retro, changeId, by, recordedAt, supersededAt, supersededBy, status, values`, newest first. `status` is `scheduled`, `in_force`, `past`, `same_day` or `superseded`. Fields you can’t read are removed from `values`.

## Changes feed

`GET /api/records/<entity>/changes`

| Parameter | Meaning |
| --- | --- |
| `recordedSince` | Required. An ISO instant: your last run’s `watermark`. |
| `recordedUntil` | Optional upper bound. |
| `group` | Comma-separated groups. |
| `effectiveFrom`, `effectiveTo` | Only changes whose changed periods overlap these dates. |
| `overlapsBefore` | Only changes touching a period that starts before this date (periods you’ve already exported). |
| `cursor`, `limit` | Paging: pass `nextCursor` back as `cursor`. `limit` defaults to 100, at most 500. |

Answer: `{ changes, nextCursor, watermark }`, oldest first. Each change has `changeId, recordId, group, mode, recordedAt, by, reason, retro, periods, after, before`. `before` is `null` unless you have `records.as_recorded` or an `audit:read` key. `watermark` is `null` when nothing changed.

## MCP tools

The [MCP server](https://docs.ligament.ai/developers/mcp/index.md) has five record tools with dating built in. Each call needs the scope of the matching REST route for its entity.

| Tool | Arguments |
| --- | --- |
| [`records_query`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_query) | `entity`, `filters`, `match`, `sort`, `q`, `limit`, `offset`, `asOf`, `knownAt` |
| [`records_get`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_get) | `entity`, `id`, `asOf`, `knownAt` |
| [`records_history`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_history) | `entity`, `id`, `group`, `include` (`["corrections"]`), `knownAt` |
| [`records_changes`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_changes) | `entity`, `recordedSince`, `recordedUntil`, `group` (array), `effectiveFrom`, `effectiveTo`, `overlapsBefore`, `cursor`, `limit` |
| [`records_change`](https://docs.ligament.ai/reference/mcp-tools/index.md#records_change) | `entity`, `id`, `values`, `effective` (as above) |

Results come back as JSON text, the same shapes as the REST answers. Errors come back with `isError: true` and the error body, for example:

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

## CLI

The [`ligament records`](https://docs.ligament.ai/reference/cli/index.md#records) commands call the same API. Set `LIGAMENT_URL` and `LIGAMENT_API_KEY` first (see [CLI](https://docs.ligament.ai/developers/cli/index.md)).

| Command | Options |
| --- | --- |
| `ligament records list <entity>` | `--as-of`, `--known-at`, `-f, --filter field.op.value` (repeatable; `in` takes `a~b~c`), `--match`, `--sort`, `-q`, `-n, --limit`, `--json` |
| `ligament records get <entity> <id>` | `--as-of`, `--known-at` |
| `ligament records history <entity> <id>` | `-g, --group`, `--corrections`, `--known-at`, `--json` |
| `ligament records changes <entity>` | `--since` (required), `--until`, `-g, --group`, `--overlaps-before`, `--cursor`, `--json` |
| `ligament records change <entity> <id>` | `-s, --set field=value` (repeatable), `--from`, `--reason`, `--mode`, `--version-id`, `--group` |

```bash
ligament records change employee cmx6ai5t300816x6sb6mvjpvu --set salary=95000 --from 2027-02-01
```

```text
Error: Pay changes need a reason (hire, merit, promotion, market_adjustment) (effective_reason_required)
```

The commands exit with 0 on success and 1 on an error.

## Errors

Errors have the shape `{ error, code, path, message, fix?, details? }`.

| Code | Status | When |
| --- | --- | --- |
| `effective_bad_as_of` | 422 | `asOf` isn’t a date, an instant or a token. |
| `effective_bad_known_at` | 422 | `knownAt` isn’t an instant or a date. |
| `effective_bad_series` | 422 | A report `series` is malformed or has more than 120 points. |
| `effective_known_at_forbidden` | 403 | `knownAt` or `include=corrections` without `records.as_recorded` or `audit:read`. |
| `effective_not_started` | 404 | `GET` one record with `asOf` before it started. |
| `effective_not_dated` | 422 | History, changes feed or batch on an entity that isn’t dated. |
| `effective_not_found` | 404 | History of, or a batch item for, a record you can’t read or that doesn’t exist. |
| `effective_invalid` | 422 | A malformed `effective` object or feed parameter (see `path`). |
| `effective_group_unknown` | 422 | `group` isn’t a dated group of the entity. |
| `effective_group_required` | 422 | A rescind or re-time names neither `version` nor `group`. |
| `effective_one_group` | 422 | A correction or rescind touches more than one group. |
| `effective_no_values` | 422 | Nothing to write: no values of a dated group. |
| `effective_date_required` | 422 | The group requires `effective.from`. |
| `effective_reason_required` | 422 | A reason is missing (always required for corrections and rescinds). |
| `effective_reason` | 422 | The reason isn’t in the group’s list (`details.reasons`). |
| `effective_future_too_far` | 422 | `from` is further ahead than the group allows (`details.maxDays`). |
| `effective_backdate_needs_capability` | 422 | The change reaches further back than the group allows without `effective.retro`. |
| `effective_locked` | 422 | The change touches a locked period (`details.lockedThrough`, `setBy`, `reason`). |
| `effective_no_version` | 422 | Nothing is in force on `from` (the record starts later). |
| `effective_rescind_first` | 422 | The first version of a record can’t be rescinded. |
| `effective_retime_conflict` | 422 | A version can’t move to that date (past the next version, or onto another change). |
| `effective_batch_plain` | 422 | A batch item has fields that aren’t dated. |
| `effective_conflict` | 409 | The version named in `version` or `baseVersion` was replaced meanwhile. |

See [Errors](https://docs.ligament.ai/developers/errors/index.md) for the platform’s other error codes.
