Overview
Communities are parent groups that contain linked subgroups. They use thew:g2 IQ namespace for mutations and MEX (GraphQL) for metadata queries.
This guide covers creating communities, linking and unlinking subgroups, querying subgroup metadata, and identifying group types within a community hierarchy.
Accessing the Community API
All community operations are accessed through thecommunity() method:
Creating a community
create_general_chat is true, so a general chat subgroup is created alongside the community.
See Community API reference for details.
Community creation options
Customize the community withCreateCommunityOptions:
If a description is provided, it is set via a follow-up IQ after creation — the group create stanza does not support inline descriptions for communities.
Deactivating a community
Deactivate (delete) a community. Subgroups are unlinked but not deleted:Managing subgroups
Link existing groups
Link existing groups as subgroups of a community:Unlink subgroups
Unlink subgroups from a community:remove_orphan_members is true, members who are only in the community through the unlinked subgroups are removed from the community.
See Community API reference for details.
Join a subgroup
Join a linked subgroup via the parent community:Querying community information
List subgroups
Fetch all subgroups of a community via MEX (GraphQL):Get subgroup participant counts
Fetch participant counts per subgroup without fetching full subgroup details:Query linked group metadata
Query a specific linked subgroup’s metadata from the parent community:Get all participants across subgroups
Fetch all participants across all linked groups of a community:Identifying group types
Use thegroup_type function to classify a group within the community hierarchy:
GroupMetadata fields:
See Groups API reference for all
GroupMetadata fields.
Error handling
Community mutations returnanyhow::Error, while MEX-based queries (get_subgroups, get_subgroup_participant_counts) return MexError:
Next steps
- Community API reference — Full API details and types
- Group management — Manage individual groups
- Events — Handle group update events
- MEX API — Understand the GraphQL layer used by community queries