Source: https://fyno.docs.pageloop.ai/api-reference/manage-user-profiles/patch-wsid-version-profiles-source-distinct-id-merge-target-distinct-id

# Merge user profiles

PATCH `https://api.fyno.io/v1/{WSID}/{version}/profiles/{source_distinct_id}/merge/{target_distinct_id}`

This API enables you to merge the attributes of a user profile to another user profile. The profile with source distinct ID is merged with the target profile, after which the source profile is automatically deleted. If the target distinct ID does not exist, the source distinct ID is updated to target distinct ID.

## Authorization

#### Authorization (header, string, required)

Enter your API Key. If you don't have it already, you can create one from the API Keys page within your Fyno account

## Path Parameters

#### WSID (path, string, required)

Enter your workspace ID. You can obtain this value from the API Keys page within your Fyno account.

#### version (path, enum (string), required) — allowed: live, test

Specify the version for which you would like to manage the user profile.

#### source\_distinct\_id (path, string, required)

Enter the source distinct ID that you wish to merge from.

#### target\_distinct\_id (path, string, required)

Enter the target distinct ID to which the profile should merge into.

## Response

#### 200

Profiles merged successfully and the source profile is deleted

#### \_message (string, required)

#### status (string, required)

#### 400

Source distinct ID does not exist

#### \_message (string, required)

#### status (string, required)

#### 401

API Key or Workspace ID is invalid. User is unauthorised.

#### \_message (string, required)

#### status (string, required)

#### Request

```bash cURL
curl -X PATCH 'https://api.fyno.io/v1/{WSID}/{version}/profiles/{source_distinct_id}/merge/{target_distinct_id}' \
  -H 'Authorization: Bearer <token>'
```

```javascript JavaScript
const res = await fetch('https://api.fyno.io/v1/{WSID}/{version}/profiles/{source_distinct_id}/merge/{target_distinct_id}', {
  method: 'PATCH',
  headers: {
    'Authorization': 'Bearer <token>',
  },
});
const data = await res.json();
```

```python Python
import requests

res = requests.patch(
    'https://api.fyno.io/v1/{WSID}/{version}/profiles/{source_distinct_id}/merge/{target_distinct_id}',
    headers={'Authorization': 'Bearer <token>'}
)
data = res.json()
```

#### Response

```json 200
{
  "_message": "1 Record(s) updated and 1 Records(s) deleted",
  "status": "ok"
}
```

```json 400
{
  "_message": "merge from id does not exist",
  "status": "error"
}
```

```json 401
{
  "_message": "Invalid API details",
  "status": "error"
}
```
