Skip to main content
Quick Reference - Update a group:
const group = new CometChat.Group("GUID", "Updated Name", CometChat.GROUP_TYPE.PUBLIC);
await CometChat.updateGroup(group);
Available via: SDK | REST API

Update Group

In other words, as a group owner, how can I update the group details? You can update the existing details of the group using the updateGroup() method.
var GUID = "GUID";
var groupName = "Hello Group";
var groupType = CometChat.GROUP_TYPE.PUBLIC;
var group = new CometChat.Group(GUID, groupName, groupType);

CometChat.updateGroup(group).then(
group => {
  console.log("Groups details updated successfully:", group);
}, error => {
  console.log("Group details update failed with exception:", error);
}
);
This method takes an instance of the Group class as a parameter which should contain the data that you wish to update.
ParameterDescription
groupan instance of class Group
After a successful update of the group, you will receive an instance of Group class containing update information of the group.
On SuccessupdateGroup() returns the updated Group object:
ParameterTypeDescriptionSample Value
hasJoinedbooleanWhether the logged-in user has joined the grouptrue
membersCountnumberTotal number of members in the group2
isBannedbooleanWhether the logged-in user is banned from the groupfalse
guidstringUnique identifier of the group"group_1772427551785"
namestringUpdated name of the group"Comet Group Updated"
typestringType of the group (public, private, password)"public"
scopestringScope of the logged-in user in the group"admin"
joinedAtnumberUnix timestamp when the user joined1772427556
conversationIdstringConversation ID for the group"group_group_1772427551785"
createdAtnumberUnix timestamp when the group was created1772427556
ownerstringUID of the group owner"cometchat-uid-6"
updatedAtnumberUnix timestamp when the group was last updated1772427918
updatedBystringUID of the user who updated the group"cometchat-uid-6"
onlineMembersCountnumberNumber of online members in the group2
For more information on the Group class, please check here

Best Practices

The Group object passed to updateGroup() must have the correct GUID set. Only the fields you set on the object will be updated — unset fields remain unchanged.
The updateGroup() method requires the logged-in user to be the owner or an admin of the group. Participants and moderators cannot update group details.

Troubleshooting

Verify the logged-in user is the owner or an admin of the group. Use getGroup() to check the user’s scope in the group.
The type field of a group is not editable after creation. To change a group’s type, you would need to create a new group with the desired type.

Next Steps