Users

You should create a User in CometChat to be able to initiate communication in the platform. Users can chat in either 1-1 or groups.

πŸ“˜

UIDs would be automatically converted to lowercase while creating a user.

The following table lists the properties that the User API supports.

ParametersTypeDescription
uidstring(mandatory) Specifies user's unique ID. Maximum length is 100 characters.

Allowed characters: alpha-dash (a-z, 0-9 with -and _ ) without spaces
name string(mandatory) Specifies the user's name.
Maximum length is 100 characters.
avatar string(optional) Specifies the display picture of the user.
If left empty, no display image is set for the user.

Maximum length is 3000 characters.
link string(optional) Specifies the URL to the profile page.

Maximum length is 3000 characters.
role string(optional) Indicates the role that is assigned to the user.

The role must be created before-hand using the create role API.

If role is not passed, then default role is assigned to the user.
metadata nested object(optional) Specifies a JSON object to store up to 1.6K characters (JSON stringified metadata) for additional user information.
tags array of strings(optional) Specifies a list of tags to be associated with certain users.

Maximum of 25 tags can be associated with a single user.
withAuthToken boolean(optional) Includes authToken of the created user in the response.

If set to true, you do not have to make a separate API call to create authToken.
createdAtIntegerUNIX Timestamp indicates the time when the user was created.

The following table lists the most common error codes that the User API may return in case of an error.

CodeDescription
ERR_UID_NOT_FOUNDIndicates any one of the following:

1. UID does not exist.
2. User is soft deleted.
ERR_UID_ALREADY_EXISTSIndicates the entered UID is already present.
ERR_INVALID_UIDIndicates that the entered UID is not in a valid format. Allowed characters: alpha-dash (a-z, 0-9 with -and _ ) without spaces
ERR_BAD_REQUESTIndicates a validation error
ERR_UID_DELETE_FAILEDIndicates that the API failed to delete the user.