Adding Users

This endpoint allows you to insert a new user.

NameTypeDescription
idstringThe unique identifier for the new user (eg. username, user id, etc.). The value is restricted to alphanumeric characters, dashes and underscore symbols.
dataobjectThe data related to the user.
// 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)
	}
© Getstream.io, Inc. All Rights Reserved.