# Change routes: merge, revert, review

URL: /code/api/change/verbs · Id: `page:code/api/change/verbs`

> The Change Verbs merge, revert, review as api.sb routes, with inputs, result, refusals and an example.

Reference for [Change](/business/nouns/change), one group of [Change routes](/code/api/change).

### Change.merge
Merge applies a Change to live data with a three-way, field-level merge against its base Version. [Verb page](/business/nouns/change/merge?interface=api).

```text
POST /{namespace}/changes/{change}/merge
```

Path: `change`. Emits [`Change.merged`](/business/events/Change.merged).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The reviewed Change. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `version` | [Version](/business/nouns/version) | Yes | The new Version. |
| `change` | [Change](/business/nouns/change) | Yes | The Change, now merged into live data. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record changed since it was read, so the write would overwrite a newer version. | [`conflict`](/code/api/errors/conflict) | Read the record again, then retry the write against its current state. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ/merge \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "version": {
    "$id": "https://api.sb/leaseline.app/versions/version_4HTEMs14G4",
    "$type": "Version",
    "fingerprint": "sha256:9f2c4e1a7b3d"
  },
  "change": {
    "$id": "https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ",
    "$type": "Change",
    "status": "Merged",
    "base": "version_4HTEMs14G4"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Change.merge",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Change.revert
Revert undoes a merged Change with a new Change and a superseding Decision, deleting nothing. [Verb page](/business/nouns/change/revert?interface=api).

```text
POST /{namespace}/changes/{change}/revert
```

Path: `change`. Body, as JSON: the other inputs. Emits [`Change.reverted`](/business/events/Change.reverted).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The merged Change to undo. |
| `reason` | `text` | Yes | Why it is undone. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `revert` | [Change](/business/nouns/change) | Yes | The Change that undoes it. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ/revert \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reason":"Example reason"}'
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "revert": {
    "$id": "https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ",
    "$type": "Change",
    "status": "Open",
    "base": "version_4HTEMs14G4"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Change.revert",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```

### Change.review
Review runs every Evaluator on a Change’s preview and records each verdict on the Change. [Verb page](/business/nouns/change/review?interface=api).

```text
POST /{namespace}/changes/{change}/review
```

Path: `change`. Emits [`Change.reviewed`](/business/events/Change.reviewed).

**Inputs**

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The open Change. |

**Returns**

| Output | Type | Required | Description |
| --- | --- | --- | --- |
| `change` | [Change](/business/nouns/change) | Yes | The Change with its verdicts. |

**Refuses when**

| Check | Error | Fix | Then call |
| --- | --- | --- | --- |
| The key is valid, but its scopes do not allow this operation. | [`forbidden`](/code/api/errors/forbidden) | Use a key whose scopes cover the operation, or ask an owner of the namespace to grant them. | None. |
| The record is not in a state that allows this Verb, so the call is refused. | [`refused`](/code/api/errors/refused) | Read the record, run the Verb that moves it to an allowed state, then retry. | None. |

**Example**

```bash
curl -X POST https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ/review \
  -H "Authorization: Bearer $STARTUP_BUILDER_API_KEY"
```

```json
{
  "api": "https://api.sb/leaseline.app",
  "change": {
    "$id": "https://api.sb/leaseline.app/changes/change_3Ex8uVSOyQ",
    "$type": "Change",
    "status": "Open",
    "base": "version_4HTEMs14G4"
  },
  "action": {
    "$id": "https://api.sb/leaseline.app/actions/act_br07HsG8MG",
    "operation": "Change.review",
    "status": "done"
  },
  "links": {
    "self": "https://api.sb/leaseline.app/actions/act_br07HsG8MG"
  }
}
```