# Reviewing access changes

> Before a change to access is applied, see who gains or loses what.

Source: https://docs.ligament.ai/guides/access/reviewing-access-changes/

You see the effect of an access change before it happens. Before you apply a new role, an edited permission set, a restriction, a group mapping or a hierarchy, Ligament plans it and shows the **effective access diff**: which roles and which people gain or lose which actions, on which entities, and how many records that is. Read this page before you change a set that many people hold, or when an agent proposes an access change.

## Plan, then apply

Every access editor in Settings › Access (roles, permission sets, restrictions, group mappings, hierarchies) has the same three buttons:

| Button | Does |
| --- | --- |
| **Plan** | Shows what applying the draft would change. Nothing is written. |
| **Apply** | Applies the draft. The change takes effect on the next request and is recorded in the history and the access audit. |
| **Save as changeset** | Keeps the draft as a changeset in Build › Changes, so someone else can review and apply it. See [Changesets](https://docs.ligament.ai/guides/building-apps/changesets/index.md). |

Applying an access change needs the `build:access` permission. Owners always have it; any other role has it when it’s among the role’s Build permissions, which the Roles list shows as “Apply access”. In Northwind Group that’s the admin role.

## Read the diff

In Northwind Group, the set `people.my_team` lets team leads update everyone below them in the reporting line. Restricting it to direct reports means adding `depth` `{ "max": 1 }` to the condition. Clicking **Plan** on that draft shows:

\[Screenshot: The Plan dialog for people.my\_team: 1 role and 1 member affected, 0 gains, 3 losses; Vic Viewer loses update on person, rows 3 to 2\]

The top part lists each item and what changes in its document (`change grants[entity=person].where.all`). The **Effective access** part is the diff:

-   **Role** rows show what every holder of a role gains or loses, as conditions in words. Here every Team lead goes from “below the member in the hierarchy” to “exactly 1 level”, for read and for update.
-   **Member** rows show real people, with how they hold the role (“through team\_lead (direct)”), and the number of records before and after. Vic Viewer can update 3 people today and would update 2.
-   Each change is a gain, a loss or a change. The header counts them: “1 role, 1 member: 0 gains, 3 losses”.

Vic doesn’t lose read on person, because Vic’s viewer seat already reads every person; the diff only lists what really changes for each person.

A diff can also be all gains. Mapping the group Service desk leads to the role Service desk lead showed:

```text
Member  Alex Agent  through service_desk_lead (group: Service desk leads)
Gains:  incident · delete   no access → every row   rows 0 → 39
```

The diff covers record access: entities, actions, rows and field levels. Capabilities such as `logs:read` aren’t listed in it, so check the set’s Capabilities section yourself when you add one.

## Changes made with an API key

Agents and scripts can propose access changes, but by default a person has to apply them. When an API key applies an access change, nothing is applied: the change becomes a changeset and the call answers `202`:

```bash
curl -X POST "https://app.ligament.ai/api/spec/apply" \
  -H "authorization: Bearer $LIGAMENT_API_KEY" -H "content-type: application/json" \
  -d '{"items":[{"address":"permissionSet/people.my_team","baseHash":"2c5aaa1ac2c17330","doc":{ ... }}]}'
```

```json
{
  "ok": true,
  "proposed": true,
  "applied": false,
  "code": "spec.human_apply_required",
  "message": "Nothing was applied: a person must apply this change. It is waiting in Build → Changes.",
  "changeset": { "id": "cmx6akvt800b86x6sil2wvggg", "url": "/build/changes/cmx6akvt800b86x6sil2wvggg", "status": "ready" }
}
```

The change waits in **Build › Changes**, marked **Ready for review** and “Proposed via API”, with who proposed it and through which key:

\[Screenshot: Build › Changes: a permission set change proposed via API by Ada Admin, ready for review, with the policy note that access and code changes need a person to apply them\]

The review page lists the items, the permissions needed and the policy. Someone who holds `build:access` clicks **Apply**, or **Discard** to drop it. The review page doesn’t show the effective access diff; to see it, open the set in its editor and plan the same change, or plan the changeset through the API (`POST /api/changesets/<id>/plan`, which returns `accessDiff`).

Which key-made changes wait is a workspace setting in **Settings › Building and agents**:

| Policy | Key-made changes that wait for a person |
| --- | --- |
| Access and code changes need a person to apply them (default) | access and code changes |
| Every change an API key makes needs a person to apply it | every change |
| API keys with spec:apply may apply anything their creator may | none |

## Plan through the API and MCP

`POST /api/spec/plan` takes the same items as apply and writes nothing. The key needs `spec:read`. The answer says whether a person must apply it and includes the diff:

```json
{
  "plan": {
    "ok": true,
    "humanApplyRequired": true,
    "policy": "review_access_code",
    "accessDiff": {
      "principals": [
        { "kind": "user", "label": "Vic Viewer", "via": ["team_lead (direct)"],
          "changes": [
            { "entity": "person", "action": "update",
              "before": "id is below Vic Viewer in the hierarchy",
              "after": "id is below Vic Viewer in the hierarchy (exactly 1 level)",
              "kind": "loss", "rows": { "before": 3, "after": 2 } }
          ] }
      ],
      "summary": { "roles": 1, "members": 1, "gains": 0, "losses": 3, "changes": 0 }
    }
  }
}
```

(Trimmed: the role entry and the item details are left out.)

Agents use the MCP tool [`access_plan`](https://docs.ligament.ai/reference/mcp-tools/index.md#access_plan), which takes the same `items` and returns the same plan. Addresses are `role/<key>`, `permissionSet/<key>`, `restriction/<key>`, `groupMapping/<group id>` and `hierarchy/<key>`; read the current document and its hash first with `GET /api/spec/<address>`. Endpoints: [Spec store](https://docs.ligament.ai/reference/rest-api/index.md#spec-store) and [Changesets](https://docs.ligament.ai/reference/rest-api/index.md#changesets).
