Community feature provides methods for managing WhatsApp communities, including creation, subgroup linking/unlinking, and metadata queries. Community mutations use IQ stanzas (w:g2 namespace) while metadata queries use MEX (GraphQL).
Access
Access community operations through the client:Methods
create
Create a new community.options— Community creation options (see CreateCommunityOptions)
CreateCommunityResult— Contains the fullmetadata: GroupMetadatafor the created community parent group
Since v0.6,
community().create() returns the full GroupMetadata instead of just the JID. The library inlines the community description directly into the create stanza (matching WA Web), so the returned metadata already contains it — no separate set_description round-trip is needed. If you previously read result.gid, switch to result.metadata.id (GroupMetadata uses id: Jid).deactivate
Deactivate (delete) a community. Subgroups are unlinked but not deleted.community_jid— JID of the community to deactivate
link_subgroups
Link existing groups as subgroups of a community.community_jid— JID of the parent communitysubgroup_jids— Array of group JIDs to link
LinkSubgroupsResult— Containslinked_jids(successfully linked) andfailed_groups(JID + error code pairs)
unlink_subgroups
Unlink subgroups from a community.community_jid— JID of the parent communitysubgroup_jids— Array of subgroup JIDs to unlinkremove_orphan_members— Whether to remove members who are only in the community through the unlinked subgroups
UnlinkSubgroupsResult— Containsunlinked_jids(successfully unlinked) andfailed_groups(JID + error code pairs)
get_subgroups
Fetch all subgroups of a community via MEX (GraphQL).community_jid— JID of the community
Vec<CommunitySubgroup>— List of subgroups with metadata
get_subgroup_participant_counts
Fetch participant counts per subgroup via MEX (GraphQL).community_jid— JID of the community
Vec<(Jid, u32)>— Pairs of subgroup JID and participant count
query_linked_group
Query a linked subgroup’s metadata from the parent community.community_jid— JID of the parent communitysubgroup_jid— JID of the subgroup to query
GroupMetadata— Full group metadata (see Groups API)
join_subgroup
Join a linked subgroup via the parent community.community_jid— JID of the parent communitysubgroup_jid— JID of the subgroup to join
GroupMetadata— Metadata of the joined subgroup
get_linked_groups_participants
Get all participants across all linked groups of a community.community_jid— JID of the community
Vec<GroupParticipant>— List of participants across all subgroups
Types
CreateCommunityOptions
Options for creating a new community. ImplementsPartialEq and Eq.
name— Community namedescription— Optional description. Since v0.6 it’s inlined as a<description>child of the create stanza, so the community is created with the description in a single round-trip (no follow-upset_descriptionIQ needed).closed— Whether the community requires approval to join (default:false)allow_non_admin_sub_group_creation— Whether non-admin members can create subgroups (default:false)create_general_chat— Whether to create a general chat subgroup (default:true)
CreateCommunityResult
Result of creating a community.metadata field carries the full community parent metadata from the server, with the inline description: Option<String> already populated. See GroupMetadata for the full field list.
CreateCommunityResult is #[non_exhaustive]: struct-literal construction and exhaustive struct destructuring from outside the crate are both disallowed. Field reads are unaffected; add .. to any exhaustive destructuring patterns.
Prior to v0.6 this struct exposed only
gid: Jid and derived PartialEq, Eq. The Eq derives were dropped because GroupMetadata does not implement them.CommunitySubgroup
A subgroup within a community. ImplementsPartialEq and Eq.
CommunitySubgroup is #[non_exhaustive]: struct-literal construction and exhaustive struct destructuring from outside the crate are both disallowed. Field reads are unaffected; add .. to any exhaustive destructuring patterns.
Fields:
id— Subgroup JIDsubject— Subgroup nameparticipant_count— Number of participants (if available)is_default_sub_group— Whether this is the default announcement subgroupis_general_chat— Whether this is the general chat subgroup
LinkSubgroupsResult
Result of linking subgroups to a community. ImplementsPartialEq and Eq.
LinkSubgroupsResult is #[non_exhaustive]: struct-literal construction and exhaustive struct destructuring from outside the crate are both disallowed. Field reads are unaffected; add .. to any exhaustive destructuring patterns.
UnlinkSubgroupsResult
Result of unlinking subgroups from a community. ImplementsPartialEq and Eq.
UnlinkSubgroupsResult is #[non_exhaustive]: struct-literal construction and exhaustive struct destructuring from outside the crate are both disallowed. Field reads are unaffected; add .. to any exhaustive destructuring patterns.
GroupType
Classification of a group within the community hierarchy. ImplementsPartialEq and Eq.
GroupType is #[non_exhaustive], so match statements should include a wildcard arm to handle future variants.
Variants:
Default— Regular standalone groupCommunity— Community parent groupLinkedSubgroup— A subgroup linked to a communityLinkedAnnouncementGroup— The default announcement subgroup of a communityLinkedGeneralGroup— The general chat subgroup of a community
group_type() function to classify a group:
Error handling
All community methods returnResult<T, CommunityError>: