Quick Reference for AI Agents & DevelopersNote: Only admins and moderators can kick, ban, or unban members.
- Kick a member from the group
- Ban a member from the group
- Unban a member from the group
- Update the scope of the member of the group
Kick a Group Member
The Admin or Moderator of a group can kick a member out of the group using thekickGroupMember() method.
- Java
- Kotlin
kickGroupMember() takes following parameters:
| Parameter | Description |
|---|---|
UID | The UID of the user to be kicked |
GUID | The GUID of the group from which user is to be kicked |
Ban a Group Member
The Admin or Moderator of the group can ban a member from the group using thebanGroupMember() method.
- Java
- Kotlin
banGroupMember() method takes the following parameters:
| Parameter | Description |
|---|---|
UID | The UID of the user to be banned |
GUID | The GUID of the group from which user is to be banned |
Unban a Banned Group Member from a Group
Only Admin or Moderators of the group can unban a previously banned member from the group using theunbanGroupMember() method.
- Java
- Kotlin
unbanGroupMember() method takes the following parameters
| Parameter | Description |
|---|---|
UID | The UID of the user to be unbanned |
GUID | The UID of the group from which user is to be banned |
Get List of Banned Members for a Group
To fetch the list of banned group members for a group, use theBannedGroupMembersRequest class. To create an object of the BannedGroupMembersRequest class, you need to use the BannedGroupMembersRequestBuilder class. The BannedGroupMembersRequestBuilder class allows you to set the parameters based on which the banned group members are fetched.
The BannedGroupMembersRequestBuilder class allows you to set the following parameters:
The GUID of the group for which the banned members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.
Set Limit
This method sets the limit i.e. the number of banned members that should be fetched in a single iteration.- Java
- Kotlin
Set Search Keyword
This method allows you to set the search string based on which the banned group members are to be fetched.- Java
- Kotlin
build() method to get the object of the BannedGroupMembersRequest class.
Once you have the object of the BannedGroupMembersRequest class, call the fetchNext() method. This method returns a list of GroupMember objects containing n number of banned members where n is the limit set in the builder class.
- Java
- Kotlin
Real-Time Group Member Kicked/Banned Events
How do I know when someone is banned or kicked while my app is running? To receive real-time events for kick/ban/unban group member actions, override the following methods of theGroupListener class.
onGroupMemberKicked()- Triggered when any group member has been kicked.onGroupMemberBanned()- Triggered when any group member has been banned.onGroupMemberUnbanned()- Triggered when any group member has been unbanned.
- Java
- Kotlin
Missed Group Member Kicked/Banned Events
How do I know when someone is banned or kicked while my app is not running? When you retrieve the list of previous messages, if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain anAction message. An Action message is a sub-class of the BaseMessage class.
For group member kicked event, the details can be obtained using the below fields of the Action class-
action-kickedactionBy- User object containing the details of the user who has kicked the memberactionOn- User object containing the details of the member that has been kickedactionFor- Group object containing the details of the Group from which the member was kicked
Action class-
action-bannedactionBy- User object containing the details of the user who has banned the memberactionOn- User object containing the details of the member that has been bannedactionFor- Group object containing the details of the Group from which the member was banned
Action class-
action-unbannedactionBy- User object containing the details of the user who has unbanned the memberactionOn- User object containing the details of the member that has been unbannedactionFor- Group object containing the details of the Group from which the member was unbanned
Best Practices
Understand Kick vs Ban
Understand Kick vs Ban
Use kick for temporary removal (user can rejoin). Use ban for permanent removal (requires unban to rejoin). Choose based on severity of violation.
Confirm Before Kicking/Banning
Confirm Before Kicking/Banning
Always prompt admins/moderators to confirm before kicking or banning members, as these actions immediately remove users from the group.
Document Ban Reasons
Document Ban Reasons
Store ban reasons in your database or use metadata to track why members were banned for future reference and appeals.
Review Banned Members Periodically
Review Banned Members Periodically
Use
BannedGroupMembersRequest to review banned members list and consider unbanning users after appropriate time periods.Troubleshooting
Kick/Ban Failed - Insufficient Permissions
Kick/Ban Failed - Insufficient Permissions
Symptom: Operation fails with “Insufficient permissions” error.Cause: User is not an admin or moderator of the group.Solution: Only admins and moderators can kick or ban members. Check the user’s scope before showing these options.
Cannot Kick/Ban Admin
Cannot Kick/Ban Admin
Symptom: Operation fails when trying to kick or ban an admin.Cause: Admins have elevated permissions and cannot be kicked or banned by moderators.Solution: Only group owners or other admins can remove admin members. Consider changing their scope first using group-change-member-scope.
Unban Failed - User Not Banned
Unban Failed - User Not Banned
Symptom:
unbanGroupMember() fails with “User not banned” error.Cause: The user is not currently banned from the group.Solution: Fetch the banned members list first using BannedGroupMembersRequest to verify the user is banned.