# Users

Stream allows you to store user information and embed them inside activities or use them for personalization. When stored in activities, users are automatically enriched by Stream.

```js label="JavaScript"
const client = stream.connect(
  "{{ api_key }}",
  "{{ feed_token }}",
  "{{ app_id }}",
);

// ensure the user data is stored on Stream
await client.setUser({
  name: "John Doe",
  occupation: "Software Engineer",
  gender: "male",
});
```

## Adding Users

This endpoint allows you to insert a new user.

| Name | Type   | Description                                                                                                                                              |
| ---- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| id   | string | The unique identifier for the new user (eg. username, user id, etc.). The value is restricted to alphanumeric characters, dashes and underscore symbols. |
| data | object | The data related to the user.                                                                                                                            |

```js label="JavaScript"
// create a new user, if the user already exist an error is returned
client.user("john-doe").create({
  name: "John Doe",
  occupation: "Software Engineer",
  gender: "male",
});

// get or create a new user, if the user already exist the user is returned
client.user("john-doe").getOrCreate({
  name: "John Doe",
  occupation: "Software Engineer",
  gender: "male",
});
```

<Admonition type="info">

The size of a user object can not exceed 10kB

</Admonition>

## Retrieving Users

The retrieving users endpoint allows you to retrieve a user by their ID.

```js label="JavaScript"
client.user("123").get();
```

## Removing Users

The delete endpoint removes a user by their ID.

```js label="JavaScript"
client.user("123").delete();
```

<Admonition type="info">

When you delete a user it will be converted to a missing reference and throw an error when [enriching](https://getstream.io/activity-feeds/docs/javascript/v2/enrichment).

</Admonition>

## Updating Users

This endpoint allows you to update a user by their ID.

### Parameters

| name | type   | description                  | default | optional |
| ---- | ------ | ---------------------------- | ------- | -------- |
| id   | string | The ID of the user to update | -       |          |
| data | object | The data related to the user | -       |          |

```js label="JavaScript"
client.user("123").update({
  name: "Jane Doe",
  occupation: "Software Engineer",
  gender: "female",
});
```


---

This page was last updated at 2026-08-07T20:37:30.907Z.

For the most recent version of this documentation, visit [https://getstream.io/activity-feeds/docs/javascript/v2/users-introduction/](https://getstream.io/activity-feeds/docs/javascript/v2/users-introduction/).