# Change the record through change sets

> Start a change set, add edits, check it and publish it, and know what happens when it waits for approval or something changed underneath.

Every change to the record goes through a change set: ground rules, proof points, facts, concepts, copy, pages, creatives, experiments and forms. Nothing in a change set is visible outside it until it is published, and publishing applies every edit at once, or none.

Starting and editing needs the `propose` scope; publishing needs `publish`.

## Make a change

::::steps
:::step[Start a change set]
Call `changeSets_start` with a `title` that says what the change does and the `reason` for it. It returns the change set's `id`.
:::
:::step[Add the edits]
Call `changeSets_edit` with the `changeSetId` and up to 50 `edits` at once. Send several in one call.
:::
:::step[Check it]
Call `changeSets_check`. Fix every blocking finding with more edits, then check again. See [fix check findings](/docs/agents/checks).
:::
:::step[Publish it]
Call `changeSets_publish`. A change set with a blocking finding is refused.
:::
::::

## Write an edit

Each edit names the item's `type`, the `op` and, except for a new item, its `id`.

| `op` | Send | Does |
| --- | --- | --- |
| `create` | `data`: the whole item | Adds an item. Handline returns its new id; use it in later edits in the same change set. |
| `update` | `patch`: only the fields to change, or `data` to replace the item | Changes an item. |
| `delete` | nothing else | Removes an item. A fact is refused while anything quotes it. |

The types are `groundRules` (id `current`, update only), `proofPoint`, `fact` (the id is its key, such as `price.monthly`), `concept`, `copy`, `page`, `creative`, `experiment` and `form`. Their fields are in [record items](/docs/reference/record-items).

```json title="changeSets_edit"
{
  "changeSetId": "cs_…",
  "edits": [
    { "type": "concept", "op": "create", "data": { "name": "Know who accepted", "audienceId": "finance-leads", "promise": "Know who accepted which terms", "proofPointIds": ["pp_…"], "hypothesis": "Finance leads lose track of acceptances." } },
    { "type": "groundRules", "op": "update", "id": "current", "patch": { "countryRules": { "google-search": { "allow": ["ES", "GB"], "deny": [] } } } }
  ]
}
```

To drop one item's edit, call `changeSets_removeEdit`. To throw the whole change set away, call `changeSets_discard`.

## When a publish waits for a person

The product's approval rules say which kinds of change wait for an owner or admin, such as new proof points or ground rules. Then `changeSets_publish` leaves the live record unchanged and returns `"status": "awaiting_approval"`. A person approves or declines it in the web app; an agent never can. When they decide, a `change_set_decided` work item tells you. A declined change set goes back to draft with the person's note.

## When something changed underneath

Each live item has a revision. If another change set published over an item you edited, `changeSets_check` says what changed and puts your edits on top of the new version. Check again before you publish.

## Undo a published change set

Call `changeSets_revert` with its id. It starts a new change set that puts back what was there before. Check it and publish it like any other.

## Read change sets

`changeSets_list` lists them, newest first, by status. `changeSets_get` shows one: its edits, the difference from the live record, and its last check.
