# Undo

> How to undo a change made through the API, by operation id or as your latest change.

Every change in Naruska CRM can be undone, whichever way it was made: the web app, an AI tool or the API. An undo is a change of its own, logged with who made it.

## Operations

One request is one **operation**: everything it changed, across records, belongs to it. To undo a particular request later, give it your own id: send an `Operation-Id` header with a UUID you generate, and keep it.

```
curl -X PATCH "https://staging-api.naruskacrm.com/v1/opportunities/<id>" \
  -H "Authorization: Bearer $NARUSKA_TOKEN" \
  -H "Operation-Id: 0193f2c4-8d2e-7c1a-9b3e-2f6d1a4c5e70" \
  -H "Content-Type: application/json" \
  -d '{"amount": 12000, "amount_source": "estimate"}'
```

Webhook events carry the same id as `data.operation_id`.

## Undo one operation

`POST https://staging-api.naruskacrm.com/v1/operations/<operation_id>/undo`

- Your own operations can be undone for 7 days; admins can undo any operation in the company for 30 days.
- A merge can't be undone ([`undo_merge`](/errors/undo_merge.md)).
- If someone changed the same fields later, the undo is refused with [`undo_conflict`](/errors/undo_conflict.md), which lists the later operations. Undo those first, newest first.

## Undo your latest change

`POST https://staging-api.naruskacrm.com/v1/operations/last/undo`

Undoes your own latest operation made through the same client (the same token, integration or AI tool), within 7 days. Call it again to go one more step back. When there is nothing left, the answer is [`nothing_to_undo`](/errors/nothing_to_undo.md). This is what an AI tool does when you say "undo that".

The answer names the operation it undid (`undone_operation_id`) and the records it changed back.
