---
url: https://talkjs.com/docs/Concepts/Users/
title: "Users | Concepts | TalkJS Docs"
---

For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

# Users

Learn about users, IDs, and data privacy in TalkJS.

A TalkJS user is a person or a group of people who uses your app.

## Control user data

It's usually best practice to map a user in your own database one-to-one to a TalkJS user.

TalkJS only collects the user data needed to make TalkJS work, and nothing else. This includes, for example, information to display a user's name, or send them email notifications.

In the [JavaScript Data API](https://talkjs.com/docs/Data_APIs/JavaScript/), you can create a user with the [`createIfNotExists` method](https://talkjs.com/docs/Data_APIs/JavaScript/Users/#UserRef__createIfNotExists), or [set](https://talkjs.com/docs/Data_APIs/JavaScript/Users/#UserRef__set) user properties to create or update data.

If you're using the [Classic JavaScript SDK](https://talkjs.com/docs/UI_Components/JavaScript/Classic/) to [create a user](https://talkjs.com/docs/UI_Components/JavaScript/Classic/Classic_Data_API/#User__Constructor__1), then TalkJS automatically [synchronizes](https://talkjs.com/docs/Features/Security/Browser_Synchronization/) user data while the user is logged into your app. As a result, TalkJS always holds an up-to-date copy of your user.

You can also use the [REST API](https://talkjs.com/docs/REST_API/) to programmatically [create or update](https://talkjs.com/docs/REST_API/Users/#create-or-update-a-user) user data.

## User ID

When you send user data to TalkJS, you need to provide a user ID for each user. Each user ID must be:

-   **Unique**: No two distinct users can have the same user ID.
-   **Permanent**: Once assigned, a user must always keep the same user ID. If you change a user's user ID, the user might lose access to their chat.

A best practice is just to use the user ID that's already used inside your own database.

Any time someone loads TalkJS and identifies with a specific user ID, TalkJS can load that user's old messages — even on different devices. [Authentication (Identity verification)](https://talkjs.com/docs/Features/Security/Authentication/) makes this secure.

### Map multiple users to a single TalkJS user

Sometimes it can be effective to make a group of users act as a single TalkJS user. For example, a team of colleagues may want to chat on your platform with another person, but it should appear as if it's a single person talking.

In this case, send a user ID to TalkJS that is **not** the same as your users' real ID. For instance, it might be appropriate to use the team ID for a TalkJS user ID.

Make sure that user IDs don't collide. If you use increasing numbers for both your user IDs and your team IDs, then TalkJS will think that user 5 and team 5 is the same user. If this might happen, it may be better to prefix your TalkJS user IDs, for example turn it into `"team_5"` and `"user_5"` or something like that.

## Privacy and data security

TalkJS takes privacy seriously, and only uses your user data where TalkJS features require it. Because of this:

-   TalkJS doesn't track your user's behavior
-   Sensitive data is `[suppressed]` when obtained from the JavaScript Data API or Classic Javascript SDK. To access these fields, you can use the [REST API](https://talkjs.com/docs/REST_API/Users/).
-   TalkJS doesn't contact your users, except to send them chat notifications.

If you want to ban a user, follow this tutorial on [how to ban a user from all chats](https://talkjs.com/resources/how-to-ban-users-from-all-chats-with-talkjs/). The tutorial also showcases how to ensure the integrity of your user's data by using [authentication (identity verification)](https://talkjs.com/docs/Features/Security/Authentication/) and [disabling client-side conversation syncing](https://talkjs.com/docs/Features/Security/Browser_Synchronization/).

## Further reading

-   [UserRef and UserSnapshot](https://talkjs.com/docs/Data_APIs/JavaScript/Users/) in the JavaScript Data API reference
-   [`/users` in the REST API](https://talkjs.com/docs/REST_API/Users/)
