Skip to main content
Note: User creation/deletion should ideally happen on your backend via the REST API.
Users must exist in CometChat before they can log in. This page covers creating, updating, and deleting users. All methods that return user data return a User object. The typical flow:
  1. User registers in your app → Create user in CometChat
  2. User logs into your app → Log user into CometChat
User deletion is only available via the REST API — there is no client-side SDK method for it.

Creating a User

User creation should ideally happen on your backend via the REST API.
Security: Never expose your Auth Key in client-side production code. User creation and updates using Auth Key should ideally happen on your backend server. Use client-side creation only for prototyping or development.
For client-side creation (development only), use createUser():
Returns a User object. See User Class for all available fields.
UID can be alphanumeric with underscore and hyphen. Spaces, punctuation and other special characters are not allowed.

Updating a User

Like creation, user updates should ideally happen on your backend via the REST API. For client-side updates (development only), use updateUser():
Ensure the User object has the correct UID set. Returns a User object. See User Class for all available fields.

Updating Logged-in User

Use updateCurrentUserDetails() to update the current user without an Auth Key. Note: You cannot update the user’s role with this method.
The method returns a User object.

Deleting a user

User deletion is only available via the REST API.

User Class


Next Steps

Retrieve Users

Fetch and filter user lists with pagination.

User Presence

Monitor real-time online/offline status.

Block Users

Block and unblock users.

Authentication

Log users into CometChat.