> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fyno.io/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fyno.io/docs/_mcp/server.

# 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.

Reference: https://fyno.io/docs/api-reference/merge-user-profiles

## Authentication

- `Authorization` header (bearer token, 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

## Request

### Path parameters

- `WSID` (string, required) — Enter your workspace ID. You can obtain this value from the API Keys page within your Fyno account.
- `version` (string, required) — Specify the version for which you would like to manage the user profile.
- `source_distinct_id` (string, required) — Enter the source distinct ID that you wish to merge from.
- `target_distinct_id` (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)

## Errors

### 400 Bad Request Error

Source distinct ID does not exist

- `_message` (string, required)
- `status` (string, required)

### 401 Unauthorized Error

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

- `_message` (string, required)
- `status` (string, required)

## Examples

**Response**

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

**SDK Code**

```python
import requests

url = "https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX"

headers = {"Authorization": "Bearer <apiKey>"}

response = requests.patch(url, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX';
const options = {method: 'PATCH', headers: {Authorization: 'Bearer <apiKey>'}};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX"

	req, _ := http.NewRequest("PATCH", url, nil)

	req.Header.Add("Authorization", "Bearer <apiKey>")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <apiKey>'

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.patch("https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX")
  .header("Authorization", "Bearer <apiKey>")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('PATCH', 'https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX', [
  'headers' => [
    'Authorization' => 'Bearer <apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = ["Authorization": "Bearer <apiKey>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.fyno.io/v1/FYXXXXXXXX/version/profiles/XXXXXXXX/merge/XXXXXXXX")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```