Skip to main content
The 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.
Parameters: Returns:
  • CreateCommunityResult — Contains the full metadata: GroupMetadata for the created community parent group
Example:
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).

get_participating

Fetch all parent/community groups the logged-in account currently participates in.
Returns:
  • HashMap<Jid, GroupMetadata> — Map of community JID to metadata
Example:

deactivate

Deactivate (delete) a community. Subgroups are unlinked but not deleted.
Parameters:
  • community_jid — JID of the community to deactivate
Example:
Link existing groups as subgroups of a community.
Parameters:
  • community_jid — JID of the parent community
  • subgroup_jids — Array of group JIDs to link
Returns:
  • LinkSubgroupsResult — Contains linked_jids (successfully linked) and failed_groups (JID + error code pairs)
Example:

create_subgroup

Create a new group that is already linked as a subgroup of a community, in one call.
Parameters:
  • name — Name of the new subgroup
  • participants — Initial participant JIDs to add to the subgroup
  • parent_jid — JID of the parent community to link the new subgroup under
Returns:
  • CreateCommunityResult — Contains the full metadata: GroupMetadata for the created subgroup
Example:
Equivalent to creating a group and then calling link_subgroups, but done in a single round-trip.
Unlink subgroups from a community.
Parameters:
  • community_jid — JID of the parent community
  • subgroup_jids — Array of subgroup JIDs to unlink
  • remove_orphan_members — Whether to remove members who are only in the community through the unlinked subgroups
Returns:
  • UnlinkSubgroupsResult — Contains unlinked_jids (successfully unlinked) and failed_groups (JID + error code pairs)
Example:

get_subgroups

Fetch all subgroups of a community via MEX (GraphQL).
Parameters:
  • community_jid — JID of the community
Returns:
  • Vec<CommunitySubgroup> — List of subgroups with metadata
Example:

get_subgroup_participant_counts

Fetch participant counts per subgroup via MEX (GraphQL).
Parameters:
  • community_jid — JID of the community
Returns:
  • Vec<(Jid, u32)> — Pairs of subgroup JID and participant count
Example:

query_linked_group

Query a linked subgroup’s metadata from the parent community.
Parameters:
  • community_jid — JID of the parent community
  • subgroup_jid — JID of the subgroup to query
Returns:
  • GroupMetadata — Full group metadata (see Groups API)
Example:

join_subgroup

Join a linked subgroup via the parent community.
Parameters:
  • community_jid — JID of the parent community
  • subgroup_jid — JID of the subgroup to join
Returns:
  • GroupMetadata — Metadata of the joined subgroup
Example:

get_linked_groups_participants

Get all participants across all linked groups of a community.
Parameters:
  • community_jid — JID of the community
Returns:
  • Vec<GroupParticipant> — List of participants across all subgroups
Example:

remove_participants

Remove participants from a community.
Parameters:
  • community_jid — JID of the community
  • participants — Array of participant JIDs to remove
Returns: Example:

Types

CreateCommunityOptions

Options for creating a new community. Implements PartialEq and Eq.
Fields:
  • name — Community name
  • description — 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-up set_description IQ 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)
Constructor:

CreateCommunityResult

Result of creating a community.
The 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. Implements PartialEq 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 JID
  • subject — Subgroup name
  • participant_count — Number of participants (if available)
  • is_default_sub_group — Whether this is the default announcement subgroup
  • is_general_chat — Whether this is the general chat subgroup
  • creation — Subgroup creation timestamp (Unix seconds), if available
  • owner — JID of the subgroup owner, if available

LinkSubgroupsResult

Result of linking subgroups to a community. Implements PartialEq 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. Implements PartialEq 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. Implements PartialEq and Eq.
GroupType is #[non_exhaustive], so match statements should include a wildcard arm to handle future variants. Variants:
  • Default — Regular standalone group
  • Community — Community parent group
  • LinkedSubgroup — A subgroup linked to a community
  • LinkedAnnouncementGroup — The default announcement subgroup of a community
  • LinkedGeneralGroup — The general chat subgroup of a community
Use the group_type() function to classify a group:

Error handling

All community methods return Result<T, CommunityError>: