# Users

> Source: https://docs.recombee.com/api/users

> For the complete documentation index, see [llms.txt](/llms.txt).

# Users

The following methods allow you to manage users in your database. User ID `undefined` is forbidden.

put

## Add User

Adds a new user to the database.

```js
client.send(new requests.AddUser(userId));
```

---

### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

userId

String

Located in: **path**

Required: **Yes**

ID of the user to be added.

---

### Responses

201

Successful operation.

---

400

The `userId` does not match ^\[a-zA-Z0-9\_-:@.\]+$.

---

409

User of the given userId is already present in the database. In many cases, you may consider this code a success – it only tells you that nothing has been written to the database.

---

delete

## Delete User

Deletes a user of the given _userId_ from the database.

If there are any purchases, ratings, bookmarks, cart additions or detail views made by the user present in the database, they will be deleted in cascade as well.

```js
client.send(new requests.DeleteUser(userId));
```

---

### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

userId

String

Located in: **path**

Required: **Yes**

ID of the user to be deleted.

---

### Responses

200

Successful operation.

---

400

The _userId_ does not match ''^\[a-zA-Z0-9\_-:@.\]+$''.

---

404

User of the given `userId` is not present in the database. In many cases, you may consider this code a success – it only tells you that nothing has been deleted from the database since the user was already not present. If there is no additional info in the JSON response, you probably have an error in your URL.

---

put

## Merge Users

Allowed on Client-Side

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.

```js
client.send(new recombee.MergeUsers(targetUserId, sourceUserId, {
  // optional parameters:
  cascadeCreate: true,  // boolean
}));
```

---

Calls Limit Per Minute

100

---

### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

targetUserId

String

Located in: **path**

Required: **Yes**

ID of the target user.

---

sourceUserId

String

Located in: **path**

Required: **Yes**

ID of the source user.

---

cascadeCreate

Boolean

Located in: **query**

Required: **No**

Sets whether the user _targetUserId_ should be created if not present in the database.

---

### Responses

201

Successful operation.

---

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.

---

get

## List Users

Gets a list of IDs of users currently present in the catalog.

```js
const result = await client.send(new requests.ListUsers({
  // optional parameters:
  filter: '\'country\' == "US"',                // string
  count: 10,                                    // integer
  offset: 0,                                    // integer
  returnProperties: true,                       // boolean
  includedProperties: ['username', 'country'],  // array
}));
```

---

Calls Limit Per Minute

100

---

### Parameters

databaseId

String

Located in: **path**

Required: **Yes**

ID of your database.

---

filter

String

Located in: **query**

Required: **No**

Boolean-returning [ReQL](https://docs.recombee.com/reql) expression, which allows you to filter users to be listed. Only the users for which the expression is _true_ will be returned.

---

count

Integer

Located in: **query**

Required: **No**

The number of users to be listed.

---

offset

Integer

Located in: **query**

Required: **No**

Specifies the number of users to skip (ordered by `userId`).

---

returnProperties

Boolean

Located in: **query**

Required: **No**

Since version: **1.4.0**

With `returnProperties=true`, property values of the listed users are returned along with their IDs in a JSON dictionary.

Example response:

```
  [
    {
      "userId": "user-81",
      "country": "US",
      "sex": "M"
    },
    {
      "userId": "user-314",
      "country": "CAN",
      "sex": "F"
    }
  ]
```

---

includedProperties

Array

Located in: **query**

Required: **No**

Since version: **1.4.0**

Allows specifying which properties should be returned when `returnProperties=true` is set. The properties are given as a comma-separated list.

Example response for `includedProperties=country`:

```
  [
    {
      "userId": "user-81",
      "country": "US"
    },
    {
      "userId": "user-314",
      "country": "CAN"
    }
  ]
```

---

### Responses

200

Successful operation.

```
[
  "user-1",
  "user-2",
  "user-3"
]
```

---

404

Invalid URL.

---