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.

Create User

This API call creates a new user 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
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
roleid The role id of 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 remove a user from cometchat by using ID of 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 ID of user Yes

Response

Success

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

Failure

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

Update User

This API Update your profile information. You can update your password, display name, 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 ID of user Yes
newpassword New passoword
username New name
displayname New displayname
avatar New avatar link
link New profile link
roleid New role id

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

This API add users as your friends. You can pass single or multiple IDs of user

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

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

This API unfriend a user from your friend list. You can pass single or multiple IDs of friends or json array contaning IDs of users.

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 ID of user Yes
friends ID’s of unfriend users for eg: friends:2 or friends:1,2,3 Yes

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

This API block a user from your friend list.

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

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

This API unblock user which is previously blocked by you.

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

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.”}}
  • Was this helpful?
  • Yes   No