> For the complete documentation index, see [llms.txt](https://docs.zero.inc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.zero.inc/features/api/merging-records.md).

# Merging Records

Duplicate records can be merged through the API. Merging keeps one record (the primary) and folds the other records into it: all related data — deals, emails, calendar events, tasks, notes, comments, files, invoices, and more — is repointed to the primary record, and the merged records are archived.

Merge endpoints are available for contacts, companies, and deals.

## Merge Contacts

```
POST /api/contacts/merge
```

Merges one or more contacts into a single primary contact.

### Request Body

| Field         | Type      | Required | Description                                                   |
| ------------- | --------- | -------- | ------------------------------------------------------------- |
| `contactId`   | string    | Yes      | ID of the contact to keep (the primary record).               |
| `mergeIds`    | string\[] | Yes      | IDs of the contacts to merge into the primary, then archive.  |
| `workspaceId` | string    | No       | Workspace ID. The workspace is also derived from the primary. |

### Example

```bash
curl -X POST "https://api.zero.inc/api/contacts/merge" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "contactId": "PRIMARY_CONTACT_UUID",
    "mergeIds": ["DUPLICATE_CONTACT_UUID_1", "DUPLICATE_CONTACT_UUID_2"]
  }'
```

### Behavior

* Field values (title, company, location, social handles, phone, type, etc.) are taken from the primary contact when set, otherwise the first non-empty value from the merged contacts is used.
* List memberships, owners, and custom properties are combined across all contacts.
* All related records (deals, email threads, calendar events, LinkedIn threads and connections, custom activities, tasks, notes, comments, files, invoices, issues, and analytics events) are repointed from the merged contacts to the primary contact.
* Each merged contact is archived and stamped with `mergedToId` (the primary contact's ID) and `mergedAt`.

### Response

```json
{
  "success": true,
  "data": {
    "id": "PRIMARY_CONTACT_UUID"
  }
}
```

The `data` object is the primary contact that the others were merged into.

## Merge Companies

```
POST /api/companies/merge
```

Identical behavior to contact merging. The primary record is identified with `companyId` instead of `contactId`.

### Example

```bash
curl -X POST "https://api.zero.inc/api/companies/merge" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "companyId": "PRIMARY_COMPANY_UUID",
    "mergeIds": ["DUPLICATE_COMPANY_UUID_1"]
  }'
```

## Merge Deals

```
POST /api/deals/merge
```

Identical behavior to contact merging. The primary record is identified with `dealId` instead of `contactId`.

### Example

```bash
curl -X POST "https://api.zero.inc/api/deals/merge" \
  -H "Authorization: Bearer YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "dealId": "PRIMARY_DEAL_UUID",
    "mergeIds": ["DUPLICATE_DEAL_UUID_1"]
  }'
```

## Notes

* All three endpoints require a Bearer token and operate only on records within your workspace.
* Merging is not reversible through the API. The merged records are archived rather than deleted, but their relations have already been repointed to the primary record.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.zero.inc/features/api/merging-records.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
