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",
});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.
# The Python API client exposes users methods on client.users
# when adding reactions, collections or reading feeds with enrichment
# you can provide `user_id` as an argument# The Ruby API client exposes user method on client.users
# when adding reactions, collections or reading feeds with enrichment
# you can provide `:user_id` as an argument// The PHP API client exposes users methods on $client->users()
// when adding reactions, collections or reading feeds with enrichment
// you can provide `$user_id` as argument// Java API client exposes users methods on client.user object
// when adding reactions, collections you can provide `userID` as argument# The Go API client exposes users methods on Client.Users.
# When adding reactions, collections or reading feeds with enrichment
# you can provide `user_id` as an argumentAdding 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);// 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",
});# create a new user, if the user already exist an error is returned
client.users.add(
  "john-doe",
  {"name": "John Doe", "occupation": "Software Engineer", "gender": "male"},
)
# get or create a new user, if the user already exist the user is returned
client.users.add(
  "john-doe",
  {"name": "John Doe", "occupation": "Software Engineer", "gender": "male"},
  get_or_create=True,
)# create a new user, if the user already exists, an error is returned
client.users.add(
  "john-doe",
  :data => {:name => "John Doe", :occupation => "Software Engineer", :gender => "male"},
)
# get or create a new user, if the user already exists, the user is returned
client.users.add(
  "john-doe",
  :data => {:name => "John Doe", :occupation => "Software Engineer", :gender => "male"},
  :get_or_create => true,
)// create a new user with the name in userdata
$user = $client->users()->add('42', array('name' => 'Arthur Dent'));
// get OR create the user
$user = $client->users()->add('42', array('name' => 'Arthur Dent'), true);// create a new user, if the user already exist an error is returned
client.user("john-doe").create(new Data()
    .set("name", "John Doe")
    .set("occupation", "Software Engineer")
    .set("gender", "male")).join();
// get or create a new user, if the user already exist the user is returned
client.user("john-doe").getOrCreate(new Data()
    .set("name", "John Doe")
    .set("occupation", "Software Engineer")
    .set("gender", "male")).join();// create a new user, if the user already exist an error is returned
	userData := stream.User{
		ID: "123",
		Data: map[string]any{
			"name":    "John Doe",
			"occupation": "Software Engineer",
			"gender":   "male",
		},
	}
	resp, err := client.Users().Add(context.TODO(), userData, false)
	if err != nil {
		panic(err)
	}
	// get or create a new user, if the user already exist the user is returned
	resp, err := client.Users().Add(context.TODO(), userData, true)
	if err != nil {
		panic(err)
	}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");client.user("123").get();client.users.get("123")client.users.get("123")$client->users()->get('42');client.user("123").get().join();resp, err := client.Users().Get(context.TODO(), "123")
	if err != nil {
		panic(err)
	}Removing Users
The delete endpoint removes a user by their ID.
await client.Users.DeleteAsync("123")client.user("123").delete();client.users.delete("123")client.users.delete("123")$client->users()->delete('42');client.user("123").delete().join();resp, err := client.Users().Delete(context.TODO(), "123")
	if err != nil {
		panic(err)
	}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)client.user("123").update({
  name: "Jane Doe",
  occupation: "Software Engineer",
  gender: "female",
});client.users.update("123",
  {"name": "Jane Doe", "occupation": "Software Engineer", "gender": "female"}
)client.users.update("123",
  :data => {:name => "Jane Doe", :occupation => "Software Engineer", :gender => "female"}
)$user = $client->users()->update('42', array('name' => 'Arthur Dent');client.user("123").update(new Data()
    .set("name", "Jane Doe")
    .set("occupation", "Software Engineer")
    .set("gender", "female")).join();data := map[string]any{
		"name":    "John Doe",
		"occupation": "Software Engineer",
		"gender":   "female",
	}
	resp, err := client.Users().Update(context.TODO(), "123", data)
	if err != nil {
		panic(err)
	}