# Worked example: a raise and a correction

> Hire someone with a start date, schedule a raise, fix a back-dated mistake, and count heads on a date, with the API, CLI and MCP.

Source: https://docs.ligament.ai/guides/effective-dating/hr-example/

This example follows one employee, Priya Raman, through a year of HR changes in a workspace whose time zone is Asia/Bangkok. Today is 2 December 2026. You’ll see:

1.  a hire with a start date in the past;
2.  a raise scheduled for next month;
3.  a promotion recorded late, and the correction of a typo in it;
4.  her history, a headcount on a date, and what a payroll export picks up.

The `employee` entity is dated with two groups: `job` (`department`, `location`, `employment_status`) and `comp` (`salary`, `pay_grade`). Pay changes need an effective date and one of the reasons `hire`, `merit`, `promotion` or `market_adjustment`. See [Effective dating](https://docs.ligament.ai/guides/effective-dating/index.md) for how groups work.

The calls use an API key in `$LIGAMENT_API_KEY` with the `records:read` and `records:write` scopes. The examples trim the responses to the parts that matter here.

## 1\. Hire with a start date

Priya joined Finance on 1 March at 84,000, grade P3. Create her record with that start date:

```bash
curl -s -X POST "https://app.ligament.ai/api/records/employee" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  -d '{"values":{"name":"Priya Raman","email":"priya.raman@northwind.example","department":"Finance","location":"Bangkok",
       "employment_status":"active","salary":84000,"pay_grade":"P3"},
       "effective":{"from":"2026-03-01","reason":"hire"}}'
```

```json
{
  "record": { "id": "cmx6ai0dx007r6x6stm9adjh5", "name": "Priya Raman", "salary": 84000, "pay_grade": "P3", "department": "Finance", "…": "…" },
  "effective": [
    { "group": "job",  "mode": "change", "version": { "from": "2026-03-01", "to": "infinity", "seq": 0, "status": "in_force" }, "…": "…" },
    { "group": "comp", "mode": "change", "version": { "from": "2026-03-01", "to": "infinity", "seq": 0, "status": "in_force" }, "…": "…" }
  ]
}
```

Each group gets a first version from 1 March. Before that date Priya isn’t in any as-of list or headcount.

## 2\. A raise from next month

Her merit raise to 90,000 takes effect on 1 January:

```bash
curl -s -X PATCH "https://app.ligament.ai/api/records/employee/cmx6ai0dx007r6x6stm9adjh5" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  -d '{"values":{"salary":90000},"effective":{"from":"2027-01-01","reason":"merit"}}'
```

```json
{
  "record": { "name": "Priya Raman", "salary": 84000, "pay_grade": "P3", "…": "…" },
  "effective": [
    {
      "group": "comp",
      "mode": "change",
      "version": { "id": "a69587f4-91a8-4de5-bf38-d650137a66c1", "from": "2027-01-01", "to": "infinity", "seq": 0, "status": "scheduled" },
      "warnings": [],
      "periods": [{ "from": "2027-01-01", "to": "infinity", "fields": ["salary"] }]
    }
  ]
}
```

The raise is `scheduled`. Today her salary is still 84,000. From midnight on 1 January it’s 90,000, without anyone touching the record again.

Only the salary changes, so this version keeps the grade she has on the day.

## 3\. A late promotion, then a correction

HR now records that Priya was promoted to P4 on 1 September, at 86,000:

```bash
curl -s -X PATCH "https://app.ligament.ai/api/records/employee/cmx6ai0dx007r6x6stm9adjh5" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  -d '{"values":{"salary":86000,"pay_grade":"P4"},"effective":{"from":"2026-09-01","reason":"promotion"}}'
```

```json
{
  "record": { "name": "Priya Raman", "salary": 86000, "pay_grade": "P4", "…": "…" },
  "effective": [
    {
      "group": "comp",
      "mode": "change",
      "version": { "id": "0839009b-afb9-4e47-b009-f78a2c578ab1", "from": "2026-09-01", "to": "2027-01-01", "seq": 0, "status": "in_force" },
      "propagated": [{ "from": "2027-01-01", "fields": ["pay_grade"] }],
      "warnings": ["The change of 2027-01-01 now carries pay_grade from this one."],
      "past": true,
      "retroPeriod": ["2026-09-01", "2026-12-02"]
    }
  ]
}
```

Two things happened:

-   Today’s values changed at once, because the promotion is in force today.
-   The scheduled January raise now carries grade P4, and the response says so. Its salary stays 90,000, because the raise set the salary itself.

The promotion reaches back 92 days, past the 90 days the pay group allows. It went through because the key belongs to an owner, who holds `effective.retro`. A key of someone without it gets `effective_backdate_needs_capability`.

Then payroll spots a typo: the offer letter says 88,000, not 86,000. The salary was never 86,000, so this is a correction, not a new change:

```bash
curl -s -X PATCH "https://app.ligament.ai/api/records/employee/cmx6ai0dx007r6x6stm9adjh5" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  -d '{"values":{"salary":88000},"effective":{"from":"2026-09-01","mode":"correction","reason":"Promotion salary keyed as 86,000; the offer letter says 88,000"}}'
```

```json
{
  "record": { "name": "Priya Raman", "salary": 88000, "pay_grade": "P4", "…": "…" },
  "effective": [
    {
      "group": "comp",
      "mode": "correction",
      "version": { "id": "a772b6fa-2bd9-46e7-9180-9277554179da", "from": "2026-09-01", "to": "2027-01-01", "seq": 0, "status": "in_force" },
      "warnings": [],
      "periods": [{ "from": "2026-09-01", "to": "2027-01-01", "fields": ["salary"] }],
      "past": true
    }
  ]
}
```

## 4\. Check the result

### Her pay history, with the CLI

```bash
ligament records history employee cmx6ai0dx007r6x6stm9adjh5 --group comp
```

```text
comp       2027-01-01 → ∞             scheduled  change (merit)  {"salary":90000,"pay_grade":"P4"}
comp       2026-09-01 → 2027-01-01    in_force   correction (Promotion salary keyed as 86,000; the offer letter says 88,000)  {"salary":88000,"pay_grade":"P4"}
comp       2026-03-01 → 2026-09-01    past       create (hire)  {"salary":84000,"pay_grade":"P3"}
```

The 86,000 that was corrected doesn’t show here. It’s still kept, and `--corrections` lists it as `superseded` for people with `records.as_recorded`.

### Her record on a date

Reading 15 October returns the corrected figure. Adding `knownAt` with a moment between the promotion and the correction returns what was on file then:

| Request | `salary` | `pay_grade` |
| --- | --- | --- |
| `GET /api/records/employee/cmx6ai0dx007r6x6stm9adjh5?asOf=2026-10-15` | 88000 | P4 |
| `…?asOf=2026-10-15&knownAt=2026-12-02T15:38:01Z` | 86000 | P4 |
| `…?asOf=2027-01-01` | 90000 | P4 |
| `…?asOf=2026-02-01` | 404 `effective_not_started` |  |

### Headcount on a date

Count active employees by department at the end of June, and at the end of January (which already includes a hire who starts on 4 January):

```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"]}]}}'
```

| `asOf` | Finance | Operations | Engineering |
| --- | --- | --- | --- |
| `2026-06-30` | 2 | 2 |  |
| `@today` (2026-12-02) | 2 | 1 |  |
| `2027-01-31` | 2 | 1 | 1 |

Operations drops to one in November because Sofia Marchetti’s termination took effect on 1 November (`employment_status` set to `terminated` from that date).

Swap `"metric":"count"` for `"metric":"sum","metricField":"salary"` to total the pay bill on the date instead. At `2027-01-31` that gives Finance 181,000, Operations 72,000 and Engineering 78,000.

An assistant connected over MCP can ask the same question with `records_query`:

```json
{ "jsonrpc": "2.0", "id": 1, "method": "tools/call",
  "params": { "name": "records_query", "arguments": {
    "entity": "employee", "asOf": "@end_of_last_quarter", "sort": "name",
    "filters": [{ "field": "department", "op": "in", "values": ["Finance", "Operations", "Engineering"] }] } } }
```

The tool returns the rows as of 30 September as text, four people with their September values:

| name | department | salary | pay\_grade | `_effective.groups.comp.from` |
| --- | --- | --- | --- | --- |
| Mei Lin Chua | Finance | 91000 | P4 | 2026-01-05 |
| Priya Raman | Finance | 88000 | P4 | 2026-09-01 |
| Sofia Marchetti | Operations | 69000 | P2 | 2025-11-03 |
| Tomás Ortega | Operations | 72000 | P2 | 2025-07-01 |

## 5\. What payroll picks up

Payroll has already paid up to 30 November. Its export asks for pay changes recorded since its last run that touch those months:

```bash
ligament records changes employee --since 2026-12-02T15:37:57Z --group comp --overlaps-before 2026-12-01
```

It gets two changes, the promotion and the correction, each with the periods to re-pay. The correction’s entry:

```json
{
  "mode": "correction",
  "reason": "Promotion salary keyed as 86,000; the offer letter says 88,000",
  "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" } }]
}
```

Payroll owes Priya the difference for September, October and November, and stores the feed’s `watermark` for its next run. See [The changes feed for exports](https://docs.ligament.ai/guides/effective-dating/as-of/index.md#the-changes-feed-for-exports).
