Querying Group Metadata
Retrieve complete information about a group, including participants, description, settings, and more.Method Signature
jid- The group JID
GroupMetadata object containing:
id- Group JIDsubject- Group namesubjectOwner- JID of who last changed the subjectsubjectTime- Timestamp of last subject changedesc- Group descriptiondescId- Description version IDdescOwner- JID of who set the descriptiondescTime- Timestamp of last description changeparticipants- Array of participant objects withid,adminstatus, and moresize- Number of participantsowner- Group creator’s JIDcreation- Group creation timestamprestrict- Whether group settings are locked to admins onlyannounce- Whether only admins can send messagesephemeralDuration- Disappearing messages duration (if enabled)memberAddMode- Whether all members can add participants
Caching Group Metadata
For better performance, implement group metadata caching:Caching group metadata is highly recommended if your application works with groups. This reduces API calls and improves performance.
Updating Group Settings
Configure who can send messages and modify group settings.Message Permissions
Settings Permissions
Method Signature
jid- The group JIDsetting- One of:'announcement'- Only admins can send messages'not_announcement'- Everyone can send messages'locked'- Only admins can modify group settings'unlocked'- Everyone can modify group settings
Toggle Disappearing Messages
Enable or disable disappearing messages for a group.Method Signature
jid- The group JIDephemeralExpiration- Duration in seconds:0- Disable disappearing messages86400- 24 hours604800- 7 days7776000- 90 days
When disappearing messages are enabled, all new messages in the group will automatically be deleted after the specified duration.
Member Add Mode
Control who can add new participants to the group.Method Signature
jid- The group JIDmode- Either:'admin_add'- Only admins can add participants'all_member_add'- All members can add participants
Fetching All Groups
Retrieve metadata for all groups you’re participating in.Method Signature
GroupMetadata
This method emits a
groups.update event with all the fetched group metadata.Best Practices
Implement metadata caching
Use the
cachedGroupMetadata socket config option to cache group data and reduce API calls.Listen to update events
Subscribe to
groups.update and group-participants.update events to keep your cache in sync.Check admin status
Before changing settings, verify you have admin privileges by checking your status in the group metadata.