# Records API

> Timelines, merges and undo across record types. Every route, its parameters and fields.

Timelines, merges and undo across record types. 5 routes; send a bearer token with each (see [Authentication](/api/authentication.md)).

| Route | What it does |
| --- | --- |
| `POST /v1/merges` | Merge two contacts or two accounts |
| `GET /v1/merges/preview` | What a merge would move (admins) |
| `POST /v1/operations/last/undo` | Undo your latest operation |
| `POST /v1/operations/{id}/undo` | Undo an operation |
| `GET /v1/recycle-bin` | Deleted records (admins) |

## Merge two contacts or two accounts

`POST https://staging-api.naruskacrm.com/v1/merges`

Admins only. The winner keeps its values; `fields` overrides chosen winner fields. Children and links move to the winner; the loser is soft-deleted and points at the winner. A merge cannot be undone.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `type` | `contact`, `account` | yes |  |
| `winner_id` | string (uuid) | yes |  |
| `loser_id` | string (uuid) | yes |  |
| `fields` | object |  |  |
| `reason` | string |  | at most 2000 characters |

### Response 201

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## What a merge would move (admins)

`GET https://staging-api.naruskacrm.com/v1/merges/preview`

Counts of the loser's live children and links that a merge moves to the winner (emails, phones, addresses, affiliations, deals, quotes, cases, notes, activities, campaign memberships, documents, tags; for accounts also child accounts). Nothing is changed.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `type` | query | `contact`, `account` | yes |  |
| `winner_id` | query | string (uuid) | yes |  |
| `loser_id` | query | string (uuid) | yes |  |

### Response 200

Returns: [MergePreview](/api/reference/objects.md#mergepreview).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Undo your latest operation

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

Reverses your own latest operation made through the same client (the same via: the web app, a token, an integration or one MCP client) that is not itself an undo and not already undone, from the last 7 days. Call it again to go one step further back: an undone operation and its undo cancel out. A refusal of that operation (a merge, a later change by someone else) is returned; it never skips to an older one. 404 `nothing_to_undo` when nothing is left.

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 200

Returns: [UndoResult](/api/reference/objects.md#undoresult).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Undo an operation

`POST https://staging-api.naruskacrm.com/v1/operations/{id}/undo`

Reverses every change of one operation (one API request or MCP tool call) as a new operation with via = undo. Your own operations for 7 days, any operation in the company for admins for 30 days. Refused for merges and when a later change touched the same fields (the problem lists them); a later operation that was undone together with its undo doesn't count, so undos can walk back changes newest first.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `id` | path | string (uuid) | yes |  |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `reason` | string |  | at most 2000 characters |

### Response 200

Returns: [UndoResult](/api/reference/objects.md#undoresult).

Errors are problem details with a stable `code`: see [Errors](/errors.md).

## Deleted records (admins)

`GET https://staging-api.naruskacrm.com/v1/recycle-bin`

Soft-deleted contacts, accounts, opportunities, cases, campaigns, activities, notes, quotes, products and documents, newest deletion first; filter by type, search the name with q. Records are removed for good 30 days after deletion (purge_on). Restore with POST /v1/{type}/{id}/restore. Children and links come back with their parent and are not listed; merged records can't be restored.

### Parameters

| Parameter | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `type` | query | `contact`, `account`, `opportunity`, `case`, `campaign`, `activity`, `note`, `quote`, `product`, `document` |  |  |
| `q` | query | string |  | Name, subject, title or number. 1–200 characters |
| `limit` | query | integer |  | 1–200, default `50` |
| `cursor` | query | string |  | next_cursor of the previous page. 1–400 characters |

### Response 200

| Field | Type | Always present | Notes |
| --- | --- | --- | --- |
| `data` | array of [RecycleBinItem](/api/reference/objects.md#recyclebinitem) | yes |  |
| `next_cursor` | string or null | yes |  |

Errors are problem details with a stable `code`: see [Errors](/errors.md).

