<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/online-api/contacts/merge-contacts

# Merge Contacts

`POST https://online.99digital.co.il/api/v1/accounts/{account_id}/actions/contact_merge`

Merges the mergee contact into the base contact, then deletes the mergee.

The base contact takes over all conversations, messages, contact inboxes, list memberships, form submissions, notes, tickets, CSAT responses, files and labels. For attributes, the base contact's non-empty values win, and empty ones are filled from the mergee. An active block on the mergee is carried over if it is longer than the base contact's.

| Setting | Value |
| --- | --- |
| **Method** | `POST` |
| **Path** | `/api/v1/accounts/{account_id}/actions/contact_merge` |
| **Authorization** | User token. Requires **delete** permission on the mergee and **update** permission on the base contact (legacy: `administrator`; new rules: **Contacts → delete** and **Contacts → update**). Agent-bot tokens: not allowed. |

**Body parameters (JSON)**

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `base_contact_id` | integer | Yes | Contact that is kept. |
| `mergee_contact_id` | integer | Yes | Contact that is merged and then deleted. |

**Example request**

```bash
curl -X POST 'https://online.99digital.co.il/api/v1/accounts/12/actions/contact_merge' \
  -H 'api_access_token: <YOUR_API_ACCESS_TOKEN>' \
  -H 'Content-Type: application/json' \
  -d '{ "base_contact_id": 801, "mergee_contact_id": 802 }'
```

**Example response** (`200 OK`): the base contact. It is **not** wrapped in `payload`, and has no `contact_inboxes`.

```json
{
  "additional_attributes": {
    "company_name": "Example Ltd",
    "city": "Tel Aviv"
  },
  "availability_status": "offline",
  "email": "dana.cohen@example.com",
  "id": 801,
  "name": "Dana Cohen",
  "phone_number": "+972501234567",
  "identifier": "crm-801",
  "thumbnail": "",
  "custom_attributes": {
    "customer_tier": "gold"
  },
  "blocked": false,
  "is_whatsapp_contact": false,
  "created_at": 1794470500
}
```

After the merge, `GET /contacts/802` returns `404`.

## Authentication

`api_access_token` in the header — Your access token. A user token is in the dashboard under **Profile settings → Access Token**, and grants exactly what that agent's role allows. An agent-bot token may call only the endpoints marked for agent bots. See [Getting Started](https://docs.99digital.co.il/online-api/getting-started#authentication).

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `account_id` | path | integer | Yes | The numeric ID of your account: the number after `/app/accounts/` in the dashboard URL. Example: `12`. |

## Request body

Content type: `application/json` (required)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `base_contact_id` | integer | Yes | The contact that is kept. Example: `801`. |
| `mergee_contact_id` | integer | Yes | The contact that is merged into the base contact, then deleted. Example: `802`. |

### Example (generated from the schema)

```json
{
  "base_contact_id": 801,
  "mergee_contact_id": 802
}
```

## Responses

### 200 — The base contact after the merge.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `id` | integer | The contact's numeric ID. |
| `name` | string | The full name of the contact. |
| `email` | string \| null | The email address of the contact, stored in lower case, or `null`. |
| `phone_number` | string \| null | The phone number of the contact in E.164 format (`+` and the country code, then the number, for example `+972501234567`), or `null`. Israeli mobile numbers are normalized automatically: `0501234567`, `501234567` and `972501234567` are all saved as `+972501234567`. |
| `identifier` | string \| null | A unique identifier for the contact in your external system (your own ID for the contact), unique in the account, or `null`. |
| `thumbnail` | string | The avatar URL of the contact, or an empty string. |
| `availability_status` | string | The availability status of the contact: whether the contact is connected right now (website widget). One of: `online` — The contact is connected right now (website widget); `offline` — The contact is not connected. |
| `additional_attributes` | object | Object containing the additional attributes related to the contact: standard extra fields, such as `company_name`, `city`, `country`, `country_code`, `description` and `social_profiles`. Blocking data (`blocked`, `blocked_at`, `block_source`) is kept here too. |
| `custom_attributes` | object | Object containing the custom attributes related to the contact: values of the account's contact custom attributes (Settings → Custom attributes), plus any free-form keys you sent. |
| `blocked` | boolean | Indicates whether the contact is blocked — `true` while the contact is blocked. |
| `is_whatsapp_contact` | boolean | `true` if the contact belongs to a WhatsApp API inbox. |
| `created_at` | integer | The time at which the contact was created (Unix timestamp, in seconds). |
| `last_activity_at` | integer | The time of the contact's last activity (Unix timestamp, in seconds). Present only when set. |
| `email_or_phone_optional` | boolean | `true` when the contact has a WhatsApp ID, so email and phone may both be empty. Returned only together with `contact_inboxes`. |
| `contact_inboxes` | array of object | Array of contact inbox objects: the inboxes the contact is linked to, each with the contact's `source_id` there and the inbox's details. Returned by the endpoints that return one contact, and by the list, search and filter endpoints unless you send `include_contact_inboxes=false`. |
| `contact_inboxes[].source_id` | string | The contact inbox's source ID: the contact's ID on the inbox's channel (a phone number, an email address, or a generated ID for API and website inboxes). |
| `contact_inboxes[].inbox` | object | Object containing the details of the inbox. |
| `contact_inboxes[].inbox.id` | integer | The numeric ID of the inbox. |
| `contact_inboxes[].inbox.channel_id` | integer | The numeric ID of the inbox's channel. |
| `contact_inboxes[].inbox.account_id` | integer | The numeric ID of the account. |
| `contact_inboxes[].inbox.name` | string | The name of the inbox. |
| `contact_inboxes[].inbox.channel_type` | string | The type of the inbox (its channel), for example `Channel::Api`, `Channel::Whatsapp` or `Channel::Email`. |
| `contact_inboxes[].inbox.enable_auto_assignment` | boolean | Whether auto-assignment is enabled: new conversations in the inbox are assigned to agents automatically. |
| `contact_inboxes[].inbox.timezone` | string | The inbox's time zone. |
| `contact_inboxes[].inbox.webhook_url` | string | For API inboxes, the inbox's own webhook URL. |
| `contact_inboxes[].inbox.api_type` | string | For API inboxes, the kind of API inbox, for example `incoming_calls`. |
| `conversations` | array of object | The contact's conversations, each a conversation object as returned by [Get Conversation](https://docs.99digital.co.il/online-api/conversations/get-conversation). Returned only by [Filter Contacts](https://docs.99digital.co.il/online-api/contacts/filter-contacts) with `include_conversations=true`. |

#### Example

```json
{
  "additional_attributes": {
    "company_name": "Example Ltd",
    "city": "Tel Aviv"
  },
  "availability_status": "offline",
  "email": "dana.cohen@example.com",
  "id": 801,
  "name": "Dana Cohen",
  "phone_number": "+972501234567",
  "identifier": "crm-801",
  "thumbnail": "",
  "custom_attributes": {
    "customer_tier": "gold"
  },
  "blocked": false,
  "is_whatsapp_contact": false,
  "created_at": 1794470500
}
```

### 401 — The access token is missing or wrong, or its user does not belong to this account.

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: Invalid token

The api_access_token header is missing or wrong.

```json
{
  "error": "Invalid Access Token"
}
```

#### Example: Another account

A valid token, for a user who is not in this account.

```json
{
  "error": "You are not authorized to access this account"
}
```

### 403 — The token's role does not have the permission this endpoint needs, or the endpoint is not open to agent-bot tokens. See [Authorization](https://docs.99digital.co.il/online-api/getting-started#authorization).

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `error` | string | The error message. |

#### Example: No permission

The role lacks the permission.

```json
{
  "error": "You are not authorized to do this action"
}
```

#### Example: Agent bot

An agent-bot token on an endpoint that is not open to bots.

```json
{
  "error": "Access to this endpoint is not authorized for bots"
}
```
