Skip to main content
Quick Reference for AI Agents & Developers
// Delete a group (admin only)
CometChat.deleteGroup("GUID", object : CometChat.CallbackListener<String>() {
    override fun onSuccess(message: String) { }
    override fun onError(e: CometChatException) { }
})
Note: Only group admins can delete groups. This action is permanent and cannot be undone.
Available via: SDK | REST API | UI Kits

Delete Group

To delete a group, use the deleteGroup() method. The user must be an Admin of the group they are trying to delete.
private String GUID = "GUID";

CometChat.deleteGroup(GUID, new CometChat.CallbackListener<String>() {
  @Override
  public void onSuccess(String successMessage) {
    Log.d(TAG, "Group deleted successfully: ");
  }

  @Override
  public void onError(CometChatException e) {
    Log.d(TAG, "Group delete failed with exception: " + e.getMessage());
  }
});
The deleteGroup() method takes the following parameters:
ParameterDescription
GUIDThe GUID of the group you want to delete

Best Practices

Always prompt users to confirm deletion with a clear warning that this action is permanent and will remove all group messages and data.
Check the user’s scope before showing delete options. Only admins can delete groups.
Consider sending a notification or message to group members before deleting the group to give them time to save important information.

Troubleshooting

Symptom: deleteGroup() fails with “Insufficient permissions” error.Cause: User is not an admin of the group.Solution: Only group admins can delete groups. Check the user’s scope using group.getScope() before attempting deletion.
Symptom: deleteGroup() fails with “Group not found” error.Cause: The group GUID is incorrect or the group has already been deleted.Solution: Verify the GUID is correct and the group still exists by fetching it first using retrieve-groups.

Next Steps