Skip to main content
Groups in WhatsApp are multi-participant conversations that support features like admin roles, group settings, and ephemeral messages. Baileys provides comprehensive group management capabilities through its API.

Group JIDs

Groups use a special JID (Jabber ID) format to identify them in the WhatsApp network:
  • Group JIDs end with @g.us (e.g., [email protected])
  • Individual user JIDs end with @s.whatsapp.net
  • When creating groups or performing operations, Baileys automatically handles JID encoding
// Group JID example
const groupJid = '[email protected]'

// The library handles encoding automatically
const metadata = await sock.groupMetadata(groupJid)

Group metadata

Group metadata contains comprehensive information about a group, including participants, settings, and descriptions.

Fetching metadata

const metadata = await sock.groupMetadata(jid)
console.log(metadata.id + ', title: ' + metadata.subject + ', description: ' + metadata.desc)

Metadata structure

The GroupMetadata object includes:
id
string
Group JID identifier
subject
string
Group name/title
subjectOwner
string
JID of the user who last changed the group name
subjectTime
number
Timestamp when the group name was last changed
desc
string
Group description text
descOwner
string
JID of the user who set the description
descId
string
Description ID used for updates
descTime
number
Timestamp when the description was last changed
creation
number
Group creation timestamp
owner
string
JID of the group creator
size
number
Number of participants in the group
participants
GroupParticipant[]
Array of participant objects with id, admin role, and optional phoneNumber/lid
announce
boolean
Whether the group is announcement-only (only admins can send messages)
restrict
boolean
Whether group settings are restricted to admins only
ephemeralDuration
number
Ephemeral message duration in seconds (if enabled)
memberAddMode
boolean
Whether all members can add participants (true) or only admins (false)
joinApprovalMode
boolean
Whether join requests require admin approval
isCommunity
boolean
Whether the group is part of a community
linkedParent
string
JID of the parent community (if applicable)

Fetching all participating groups

You can retrieve metadata for all groups you’re participating in with a single call:
const response = await sock.groupFetchAllParticipating()
console.log(response)
// Returns: { [groupJid: string]: GroupMetadata }
This returns an object mapping group JIDs to their metadata. This is useful for:
  • Building a group list UI
  • Syncing group information on startup
  • Caching group data locally
The groupFetchAllParticipating function automatically emits a groups.update event, which you can listen to for keeping your local cache in sync.

Caching and dirty bits

Bailey’s uses a “dirty bits” system to track when group data needs refreshing:
  • When groups are modified, WhatsApp sends a dirty bit notification
  • Baileys automatically listens for these notifications on the CB:ib,,dirty event
  • When groups are marked dirty, groupFetchAllParticipating is called automatically
  • After syncing, dirty bits are cleaned with cleanDirtyBits('groups')
This ensures your group metadata stays synchronized without constant polling.
Dirty bits are WhatsApp’s way of signaling that cached data is stale. When you receive a dirty bit notification for groups, it means one or more groups you’re in have been modified (name changed, participant added/removed, settings updated, etc.). Baileys handles this automatically, but you can also manually trigger a refresh by calling groupFetchAllParticipating().

Participant roles

Group participants can have different admin roles:
  • null - Regular member
  • 'admin' - Group admin
  • 'superadmin' - Group creator/owner (has all admin privileges)
const metadata = await sock.groupMetadata(jid)
metadata.participants.forEach(participant => {
  if (participant.admin) {
    console.log(`${participant.id} is a ${participant.admin}`)
  }
})
Most group management operations (changing settings, adding/removing participants, etc.) require admin privileges. Attempts to perform these actions as a regular member will fail.

Build docs developers (and LLMs) love