# Undo a change

> Undoes a change, as Undo does, and needs the permissions of the operation that made it.

`POST /v1/changes/{changeId}/revert`

Undoes a change, as Undo does, and needs the permissions of the operation that made it. It is conditional: if anything the change touched was edited since, it refuses with a 409 and changes nothing (the change stays `applied`). If a LATER step is refused, the change becomes `failed` and the error says `partial: true`. Only an `applied` change can be undone, and an undo cannot itself be undone: make the change again.

**Permissions:** any valid key · **Kind:** write · **Cost:** 1 unit · MCP tool [`undo_change`](https://api.bymundi.com/docs/mcp/tools/undo_change.md)

Cannot be undone.

## Path parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `changeId` | uuid | yes |  |

## Body

_None._

## Response `200`

| Field | Type | Required | Description |
|---|---|---|---|
| `object` | "change" | yes |  |
| `id` | uuid | yes |  |
| `operationId` | string | yes |  |
| `surface` | "rest" \| "mcp" | yes |  |
| `status` | "applying" \| "applied" \| "failed" \| "reverting" \| "reverted" | yes |  |
| `tripIds` | string[] | yes |  |
| `credentialId` | string \| null | yes |  |
| `error` | string \| null | yes |  |
| `createdAt` | string | yes |  |
| `updatedAt` | string | yes |  |
| `revertedAt` | string \| null | yes |  |

## Errors

Errors are [problem details](https://api.bymundi.com/docs/guides/errors.md). Besides the refusals described above, any call like this one can return:

- [`invalid_request`](https://api.bymundi.com/problems/invalid_request.md) — Invalid request
- [`unauthorized`](https://api.bymundi.com/problems/unauthorized.md) — Missing or invalid API key
- [`insufficient_scope`](https://api.bymundi.com/problems/insufficient_scope.md) — Missing permission
- [`rate_limited`](https://api.bymundi.com/problems/rate_limited.md) — Rate limit reached
- [`not_found`](https://api.bymundi.com/problems/not_found.md) — Not found
- [`idempotency_key_reused`](https://api.bymundi.com/problems/idempotency_key_reused.md) — Idempotency-Key reused
- [`request_in_progress`](https://api.bymundi.com/problems/request_in_progress.md) — Request in progress

## Examples

#### curl

```bash
curl -X POST https://api.bymundi.com/v1/changes/$CHANGE_ID/revert \
  -H "Authorization: Bearer $BYMUNDI_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{}'
```

#### JavaScript

```javascript
const res = await fetch(`https://api.bymundi.com/v1/changes/${changeId}/revert`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BYMUNDI_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({}),
});
if (!res.ok) throw new Error((await res.json()).detail);
const data = await res.json();
```

#### Python

```python
import os, uuid, requests

res = requests.post(
    f"https://api.bymundi.com/v1/changes/{changeId}/revert",
    headers={"Authorization": f"Bearer {os.environ['BYMUNDI_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={},
)
res.raise_for_status()
data = res.json()
```
