Users

Product:
User management needs to be done on your server end. Please refer to the Web SDK guide to understand how to manage/sync your users.

Restful APIs cannot be used to manage users. If you don’t have a User Management System for User Registration, Login, Logout etc. only then we recommended you to use our APIs so that you can create new users in CometChat.

Create User

If your website doesn’t have a User Management System for User Registration, Login, Logout etc. only then we recommend you to use our APIs so that you can create new users in CometChat.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/createuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
username The user’s name Yes
password The user’s password. If you are not allowing your users to login directly, then you can create an internal password for this. Yes
link The link to the user’s profile page. If you do not have a profile link, you can leave this blank.
avatar The link to the avatar image.
displayname The display name for the user. If this is blank, then CometChat will show username
role role of this user

Response

Success

{“success”: {“status”:”1000″, “message”:”User created successfully!”}}

Failure

{“failed”: {“status”:”1001″, “message”:”username already exists”}}

{“failed”: {“status”:”1007″, “message”:”Invalid Username.”}}

{“failed”: {“status”:”1009″, “message”:”Invalid Password.”}}

Remove User

This API deletes the user.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/removeuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid ID of user Yes

Response

Success

{“success”: {“status”:”1000″, “message”:”User removed successfully!”}}

Failure

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Update User

Updates the user’s information including his password, display name, profile avatar and profile link.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/updateuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid CometChat user ID Yes
username Username for this user Yes
password Existing password of this user Yes
newpassword New password
displayname New displayname
avatar New avatar link
link New profile link
role New role for this user

Response

Success

{“success”: {“status”:”1000″, “message”:”Details updated successfully!”}}

Failure

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

{“failed”: {“status”:”1014″, “message”:”Failed to update username. Invalid username or username already exists.”}}

{“failed”: {“status”:”1016″, “message”:”Failed to update details.”}}

Add Friend

Add friends’ to user’s friend list. You can add single or multiple friends at a time.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/addfriend Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid ID of user Yes
friends ID’s of friend users for eg: friends:2 or friends:1,2,3 Yes
clearFriends If ‘clearFriends = 1’ then API will clear Users all friends which previously added to the database and add new Friends Ids for User. If ‘clearFriends = 0 ‘ then API will only add new friend ids. Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”Friends added successfully!”, “data”:{“userid”:”2,3”}}}

Failure

{“failed”: {“status”:”1005″, “message”:”Invalid input”}}

{“failed”: {“status”:”1006″, “message”:”Failed to add friend.”}}

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Remove Friend

Remove friends’ from user’s friend list. You can remove single or multiple friends at a time.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/removefriend Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid User’s ID Yes
friends ID’s of unfriend users for eg: friends:2 or friends:1,2,3 Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”Friends removed successfully!”, “data”:{“id”:”2″}}}

Failure

{“failed”: {“status”:”1005″, “message”:”Invalid input”}}

{“failed”: {“status”:”1002″, “message”:”Failed to remove friends!”}}

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Block User

Allows the user to block another user. A user can’t receive any messages from someone they have blocked. Also, blocking someone doesn’t alert them that they have been blocked.

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/blockuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
fromuserid ID of user Yes
touserid ID of users to whom we want to block Yes

Response

Success

{“success”: {“status”:”1000″, “message”:”User blocked successfully.”}}

Failure

{“failed”: {“status”:”1014″, “message”:”Failed to blocked user.”}}

{“failed”: {“status”:”1001″, “message”:”Invalid fromuserid or touserid.”}}

Unblock User

Unblocks the user who was previously blocked.

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/unblockuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
fromuserid ID of user Yes
touserid ID of users to whom we want to block Yes

Response

Success

{“success”: {“status”:”1000″, “message”:”User unblocked successfully.”}}

Failure

{“failed”: {“status”:”1014″, “message”:”Failed to unblocked user.”}}

{“failed”: {“status”:”1001″, “message”:”Invalid fromuserid or touserid.”}}

List Users

Lists all user profile details on CometChat.

Request body

Name Description Mandatory
sample url http://PATH_TO_COMETCHAT_DIRECTORY/cometchat/api/userlist Yes
api-key The API Key present in your CometChat Admin Panel Yes
page_number Page Number. It is in integer format. No
limit Limit is a number of record display per page or per call. It is in integer format. Limit for displaying user list is Maximum 100. No

Response

Success

{“success”: {“status”:”1000″, “message”:”User list fetched successfully!!”},“data“:user_list_records}

Detail

“user_list_records” is an all user list in a JSON Formatted Array.

Create User

If your website doesn’t have a User Management System for User Registration, Login, Logout etc. only then we recommend you to use our APIs so that you can create new users in CometChat.

Request body

Name Description Mandatory
sample url http://api.cometondemand.net/api/createuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
username The user’s name Yes
password The user’s password. If you are not allowing your users to login directly, then you can create an internal password for this. Yes
uid This is your Site User ID. Add this to maintain consistency between CometChat User ID and your Site User ID.
link The link to the user’s profile page. If you do not have a profile link, you can leave this blank.
avatar The link to the avatar image.
displayname The display name for the user. If this is blank, then CometChat will show username
role role of this user

Response

Success

{“success”: {“status”:”1000″, “message”:”User created successfully!”}}

Failure

{“failed”: {“status”:”1001″, “message”:”username already exists”}}

{“failed”: {“status”:”1007″, “message”:”Invalid Username.”}}

{“failed”: {“status”:”1009″, “message”:”Invalid Password.”}}

Remove User

This API deletes the user.

Request body

Name Description Mandatory
sample url http://api.cometondemand.net/api/removeuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid OR uid CometChat user ID / Your Site User ID. Yes

Response

Success

{“success”: {“status”:”1000″, “message”:”User removed successfully!”}}

Failure

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Update User

Updates the user’s information including his password, display name, profile avatar and profile link.

Request body

Name Description Mandatory
sample url http://api.cometondemand.net/api/updateuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid CometChat user ID Yes
username Username for this user Yes
password Existing password of this user Yes
newpassword New password
displayname New displayname
avatar New avatar link
link New profile link
role New role for this user

Response

Success

{“success”: {“status”:”1000″, “message”:”Details updated successfully!”}}

Failure

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

{“failed”: {“status”:”1014″, “message”:”Failed to update username. Invalid username or username already exists.”}}

{“failed”: {“status”:”1016″, “message”:”Failed to update details.”}}

Add Friend

Add friends’ to user’s friend list. You can add single or multiple friends at a time.

Request body

Name Description Mandatory
sample URL http://api.cometondemand.net/api/addfriend Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid ID of user Yes
friends ID’s of friend users for eg: friends:2 or friends:1,2,3 Yes
clearFriends If ‘clearFriends = 1’ then API will clear Users all friends which previously added to the database and add new Friends Ids for User. If ‘clearFriends = 0 ‘ then API will only add new friend ids. Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”Friends added successfully!”, “data”:{“userid”:”2,3”}}}

Failure

{“failed”: {“status”:”1005″, “message”:”Invalid input”}}

{“failed”: {“status”:”1006″, “message”:”Failed to add friend.”}}

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Remove Friend

Remove friends’ from user’s friend list. You can remove single or multiple friends at a time.

Request body

Name Description Mandatory
sample url http://api.cometondemand.net/api/removefriend Yes
api-key The API Key present in your CometChat Admin Panel Yes
userid User’s ID Yes
friends ID’s of unfriend users for eg: friends:2 or friends:1,2,3 Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”Friends removed successfully!”, “data”:{“id”:”2″}}}

Failure

{“failed”: {“status”:”1005″, “message”:”Invalid input”}}

{“failed”: {“status”:”1002″, “message”:”Failed to remove friends!”}}

{“failed”: {“status”:”1007″, “message”:”Invalid user ID”}}

Block User

Allows the user to block another user. A user can’t receive any messages from someone they have blocked. Also, blocking someone doesn’t alert them that they have been blocked.

Name Description Mandatory
sample url http://api.cometondemand.net/api/blockuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
fromuserid ID of user Yes
touserid ID of users to whom we want to block Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”User blocked successfully.”}}

Failure

{“failed”: {“status”:”1014″, “message”:”Failed to blocked user.”}}

{“failed”: {“status”:”1001″, “message”:”Invalid fromuserid or touserid.”}}

Unblock User

Unblocks the user who was previously blocked.

Name Description Mandatory
sample url http://api.cometondemand.net/api/unblockuser Yes
api-key The API Key present in your CometChat Admin Panel Yes
fromuserid ID of user Yes
touserid ID of users to whom we want to block Yes
isusersiteid If ‘isusersiteid= 1’ then API will use site userid (Site’s User Table Primary Key) & if ‘isusersiteid = 0’ then API will use CometChat user table’s userid (CometChat Primary Key). Default Value is 0. No

Response

Success

{“success”: {“status”:”1000″, “message”:”User unblocked successfully.”}}

Failure

{“failed”: {“status”:”1014″, “message”:”Failed to unblocked user.”}}

{“failed”: {“status”:”1001″, “message”:”Invalid fromuserid or touserid.”}}

List Users

Lists all user profile details on CometChat.

Request body

Name Description Mandatory
sample url http://api.cometondemand.net/api/userlist Yes
api-key The API Key present in your CometChat Admin Panel Yes
page_number Page Number. It is in integer format. No
limit Limit is a number of record display per page or per call. It is in integer format. Limit for displaying user list is Maximum 100. No

Response

Success

{“success”: {“status”:”1000″, “message”:”User list fetched successfully!!”},“data“:user_list_records}

Detail

“user_list_records” is an all user list in a JSON Formatted Array.

  • Was this helpful?
  • Yes   No