Skip to main content
A User is the core identity in CometChat. Every person (or bot) that sends messages, joins groups, or makes calls must exist as a User. Users are identified by a unique uid that you assign during creation and cannot change afterward.

How Users connect to other resources

  • Auth Tokens — A User needs an auth token to log in via the SDK. You can generate one during creation (withAuthToken: true) or separately via the Auth Tokens API.
  • Groups — Users can join up to 2,000 Groups and participate in group messaging and calling.
  • Messages — Users send and receive Messages in 1-on-1 or group conversations.
  • Friends — Users can add up to 1,000 Friends. Friendships are bidirectional.
  • Roles — Users can be assigned a Role that controls permissions. If no role is set, the default role applies.
  • Blocked Users — Users can block other users to prevent all direct communication in both directions.

Common workflow

  1. Create a User with withAuthToken: true to get an auth token in the same call.
  2. Use the auth token to initialize the CometChat SDK on the client.
  3. The user can now send messages, join groups, and make calls.
UIDs are automatically converted to lowercase during creation. For example, CometChat-UID-1 becomes cometchat-uid-1.

Available operations

OperationMethodEndpointDescription
ListGET/usersRetrieve a paginated list of users with filtering options
CreatePOST/usersCreate a new user in your app
GetGET/users/{uid}Retrieve a specific user’s details
UpdatePUT/users/{uid}Modify a user’s profile (name, avatar, role, metadata)
DeleteDELETE/users/{uid}Deactivate or permanently delete a user
DeactivateDELETE/usersTemporarily disable users while preserving their data
ReactivatePUT/usersRestore previously deactivated users

User properties

The following table lists the properties that the User object supports.
PropertyTypeDescription
uidstringRequired. User’s unique identifier. Max 100 characters. Alphanumeric with dashes and underscores only, no spaces. Case-insensitive and immutable after creation.
namestringRequired. Display name shown in chat interfaces and notifications. Max 100 characters. Supports all languages and emojis (UTF8mb4).
avatarstringURL to the user’s profile picture. Max 3,000 characters. CometChat stores the URL, not the image itself. Recommended size: 200×200 pixels.
linkstringURL to the user’s profile page in your application. Max 3,000 characters.
rolestringRole assigned to the user. Must be created beforehand using the Create Role API. Defaults to the default role if not set.
metadataobjectJSON object for storing additional user information (e.g., email, phone, preferences). Max 5 KB. Use the @private key for sensitive data that should only be visible to the user themselves and via admin APIs.
tagsarray of stringsTags for categorizing and filtering users. Max 25 tags per user, 100 characters each (UTF8mb4). Useful for segmenting by department, location, or custom criteria.
withAuthTokenbooleanWhen true on creation, includes the auth token in the response — saving a separate API call. Only applicable during Create.
createdAtintegerUNIX timestamp indicating when the user was created. System-generated, read-only.

Error handling

When API calls fail, CometChat returns structured error responses. The most common errors for User operations:
Error CodeDescription
AUTH_ERR_EMPTY_APIKEYAPI key is missing from the request headers
AUTH_ERR_APIKEY_NOT_FOUNDThe provided API key is invalid
AUTH_ERR_NO_ACCESSThe API key doesn’t have the required scope (e.g., using an authOnly key for a fullAccess operation)
ERR_UID_NOT_FOUNDThe specified UID does not exist, or the user has been deactivated
For the complete list of error codes, see Error Guide. For all system limits (metadata size, tag counts, ID length, etc.), see Properties and Constraints.