# Agents propose, people approve

> Let AI agents and scripts draft changes with an API key while people keep the final say.

Source: https://docs.ligament.ai/guides/building-apps/agents-propose/

AI assistants connected over [MCP](https://docs.ligament.ai/developers/mcp/index.md), scripts and the [CLI](https://docs.ligament.ai/developers/cli/index.md) change your workspace with an API key. They use the same spec store as the builders, so everything they do is planned, versioned and attributed to the key. You decide two things: what each key may do (its scopes), and which key-made changes go live by themselves and which wait for a person to apply them (a workspace setting).

## Choose what a key may do

Three scopes cover the spec store:

| Scope | Lets the key |
| --- | --- |
| `spec:read` | Read artefacts, their history, schemas and the catalog, and plan changes |
| `spec:propose` | Create and edit changesets for a person to review. It never applies anything. |
| `spec:apply` | Apply changes directly and apply changesets, within what the key’s creator may do and the workspace setting below |

A key acts as the person who created it, and never with more rights than that person has today. A key with `spec:apply` created by someone without `build:access` can’t apply access changes, whatever the setting says. Every spec scope also needs the creator’s role to have the Build capability: create agent keys as someone who uses Build (an admin, or a role whose permission set has `build:use`).

For an AI assistant that should only ever suggest changes, give it `spec:read` and `spec:propose`. Its attempt to apply is refused:

```json
{
  "error": "This API key lacks the \"spec:apply\" scope.",
  "code": "insufficient_scope",
  "required": ["spec:apply"],
  "route": "/api/spec/apply"
}
```

Create keys in **Settings › API keys**; see [API keys](https://docs.ligament.ai/developers/api-keys/index.md) and the [scope reference](https://docs.ligament.ai/reference/scopes/index.md).

## Decide which changes need a person

Open **Settings › Building and agents**. Under **Changes made with API keys**, pick one:

| Option | Value | Effect |
| --- | --- | --- |
| **Access and code changes need a person to apply them** (default) | `review_access_code` | A key with `spec:apply` applies pages directly. Changes to roles, permission sets, restrictions, group mappings, hierarchies and shares wait in Build › Changes. |
| **Every change an API key makes needs a person to apply it** | `review_all` | Every key-made change waits as a changeset marked Ready for review, whatever scopes the key has. |
| **API keys with spec:apply may apply anything their creator may** | `allow_all` | Nothing waits. Use this only for keys you trust as much as their creators. |

\[Screenshot: Settings › Building and agents, with the three options for changes made with API keys and the default selected\]

Only a signed-in admin can change this setting. An API key can read it (`GET /api/spec/policy`) but can’t change it, so a key can’t lift its own review:

```json
{
  "error": "PUT /api/spec/policy only accepts a signed-in browser session, not an API key.",
  "code": "session_required"
}
```

## What the agent sees

When a key applies a change the setting holds back, nothing is applied. Ligament turns the change into a changeset marked ready for review and answers with `202`:

```bash
curl -s -X POST -H "Authorization: Bearer $LIGAMENT_API_KEY" -H 'content-type: application/json' \
  https://app.ligament.ai/api/spec/apply \
  -d '{ "title": "New role: Loans coordinator",
        "items": [ { "address": "role/loans_coordinator", "baseHash": null,
                     "doc": { "key": "loans_coordinator", "name": "Loans coordinator",
                              "description": "Runs the IT equipment loans desk.",
                              "permissionSets": [], "params": {} } } ] }'
```

```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": "cmx6b346y00mo6x6srbbxd3g1", "url": "/build/changes/cmx6b346y00mo6x6srbbxd3g1", "status": "ready" }
}
```

The optional `title` names the changeset; without it the title is *Proposed via API:* followed by the addresses. An agent should treat `proposed: true` as a normal result: tell the user that the change is waiting for review and where. The other clients report it the same way:

-   The MCP tool `spec_apply` returns `proposed: true` with the changeset link in its message.
    
-   The CLI prints the changeset and exits with code 3:
    
    ```text
    Proposed, waiting for a person: this workspace requires a person to apply this change. Nothing was applied.
    Changeset cmx6bg3rz00ro6x6sxldk2kuu: https://app.ligament.ai/build/changes/cmx6bg3rz00ro6x6sxldk2kuu
    ```
    

The key can’t then apply the changeset itself: `POST /api/changesets/<id>/apply` with a key answers `403 spec.human_apply_required`.

Changes the setting lets through apply as usual (`200` with the new versions), and each version names the key: *Ada Admin via API key Loans desk agent (…MT63)*.

## Review what an agent proposed

Proposals from keys appear in **Build › Changes** like any other changeset. The header says who proposed it and through which key, and the plan carries the reason it’s waiting:

\[Screenshot: A changeset New role: Loans coordinator, Ready for review, proposed by Ada Admin via API key Loans desk agent, with the notice that the workspace requires a person to apply access and code changes made with an API key\]

Read the plan and the Impact panel, then **Apply** it or **Discard** it. Applying it in the app makes you the person who applied it; the activity keeps the key as the proposer. See [Changesets](https://docs.ligament.ai/guides/building-apps/changesets/index.md) for the review page in detail.

## A setup that works

-   Give each agent its own key, named after what it does (“Loans desk agent”), so its changes are easy to spot in history and in Build › Changes.
-   Start agents on `spec:read` and `spec:propose`. Add `spec:apply` only when you’re happy for their page changes to go live without review.
-   Keep the default setting, so access changes always wait for a person, or choose `review_all` while you’re trying an agent out.
-   Revoke a key in **Settings › API keys** when the agent no longer needs it. Its past changes keep their attribution.
