Skip to content
Warning:
You are viewing the Feeds v2 documentation. Feeds v2 is in maintenance mode and no longer receives new features. New projects should use Feeds v3, a major upgrade in performance, capabilities, and developer experience. To move an existing app, follow the migration guide.

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.

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.
// create a new user, if the user already exist an error is returned
const userData = new Dictionary<string, object>
{
  {"name", "John Doe" },
  {"occupation", "Software Engineer"},
  {"gender", "male"},
};

await client.Users.AddAsync("john-doe", userData);

// get or create a new user, if the user already exist the user is returned
await client.Users.AddAsync("john-doe", userData, true);
Info:

The size of a user object can not exceed 10kB

Retrieving Users

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

await client.Users.GetAsync("123");

Removing Users

The delete endpoint removes a user by their ID.

await client.Users.DeleteAsync("123")
Info:

When you delete a user it will be converted to a missing reference and throw an error when enriching.

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 -
var userData = new Dictionary<string, object>
{
  {"name", "Jane Doe" },
  {"occupation", "Software Engineer"},
  {"gender", "female"},
};
await client.Users.UpdateAsync("123", userData)