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).

list_participating

List every parent community the account participates in as slim GroupOverview records. Same slim wire projection as Groups::list_participating: id, subject, hierarchy, and participant count — no subgroup members, no settings, one round trip.
Returns:
  • Vec<GroupOverview> — one overview per parent community.
Example:

fetch_participating_metadata

Fetch full GroupMetadata for every parent community the account participates in.
Returns:
  • HashMap<Jid, GroupMetadata> — Map of community JID to metadata.
Always hits the network. Returns protocol data only; call Groups::resolve_participant_addresses per result when PN-keyed display data is needed. Prefer list_participating when the display fields are all you need. 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. All groups are linked with the default SubgroupVisibility::Visible; use link_subgroups_with_options to mix visible and hidden groups in a single request.
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:
Link existing groups to a community with a per-group visibility. A single request can mix visible and hidden groups.
Parameters:
  • community_jid — JID of the parent community
  • subgroup_options — Array of per-group link options (see LinkSubgroupOptions)
Returns: Example:
Visibility is set at link time. To change a group’s visibility later you must unlink and re-link it.

create_subgroup

Create a new group that is already linked as a subgroup of a community, in one call. The subgroup is created with the default SubgroupVisibility::Visible.
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.

create_subgroup_with_options

Create a new subgroup linked to a community with an explicit visibility. Use this when the subgroup should be hidden from non-members in the community’s subgroup list.
Parameters: Returns:
  • CreateCommunityResult — Contains the full metadata: GroupMetadata for the created subgroup
Example:
Visibility is fixed at creation time. WhatsApp does not support changing a subgroup’s visibility later.
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)
  • creation — Subgroup creation timestamp (Unix seconds), if available
  • owner — JID of the subgroup owner, if available
  • is_default_sub_group — Whether this is the default announcement subgroup
  • is_general_chat — Whether this is the general chat subgroup
  • is_hidden_group — Whether this subgroup is hidden from non-members in the community’s subgroup list. Reflects the hidden_group property parsed from the MEX response; defaults to false if the server omits it.

SubgroupVisibility

Visibility selected when a subgroup is created or linked. Implements Copy, PartialEq, Eq, and Default (Visible).
Variants:
  • Visible — The subgroup appears in the community’s subgroup list.
  • Hidden — The subgroup is omitted from the community’s subgroup list for users who are not members. Visibility cannot be changed after linking.

CreateSubgroupOptions

Options passed to create_subgroup_with_options when creating a subgroup already linked to a community.
Fields:
  • 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
  • visibility — Visibility applied at creation time (defaults to Visible)
Constructors:

LinkSubgroupOptions

Options for linking a single existing group to a community via link_subgroups_with_options.
Fields:
  • jid — JID of the existing group to link
  • visibility — Visibility applied to this group at link time
Constructor:

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>: