---
title: "Merge Users"
method: PUT
path: "/{databaseId}/users/{targetUserId}/merge/{sourceUserId}"
tags: ["Users"]
---

# Merge Users

`PUT /{databaseId}/users/{targetUserId}/merge/{sourceUserId}`

Merges interactions (purchases, ratings, bookmarks, detail views ...) of two different users under a single user ID. This is especially useful for online e-commerce applications working with anonymous users identified by unique tokens such as the session ID. In such applications, it may often happen that a user owns a persistent account, yet accesses the system anonymously while, e.g., putting items into a shopping cart. At some point in time, such as when the user wishes to confirm the purchase, (s)he logs into the system using his/her username and password. The interactions made under anonymous session ID then become connected with the persistent account, and merging these two becomes desirable.


Merging happens between two users referred to as the *target* and the *source*. After the merge, all the interactions of the source user are attributed to the target user, and the source user is **deleted**.

By default, the *Merge Users* request is only available from server-side integrations for security reasons, to prevent potential abuse.
If you need to call this request from a client-side environment (such as a web or mobile app), please contact our support and request access to enable this feature for your database.

## Path parameters

- `databaseId` string, required
- `targetUserId` string, required
- `sourceUserId` string, required

## Query parameters

- `cascadeCreate` boolean

## Response `201`

Successful operation.

## Other responses

- `400` — The *sourceUserId* or *targetUserId* does not match ^[a-zA-Z0-9_\-:@\.]+$
- `404` — The *sourceUserId* or *targetUserId* does not exist in the database. If there is no additional info in the JSON response, you probably have an error in your URL.

---

[API](https://skmtc.dev/recombee/apis/recombee-api.md) · [All operations](https://skmtc.dev/recombee/apis/recombee-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/recombee/recombee-api/revisions/a9c9c33eb2e8/schema)
