Creating Groups
Basic Group Creation
Create a new group with default settings:When you create a group, you are automatically:
- Added as the only member
- Designated as a super admin
- Required to update installations before other operations
Create Group with Members
Add members at creation time using wallet addresses:Group Metadata
Set group name, description, and image:Managing Members
use xmtp_id::associations::Identifier;
let new_members = vec![
Identifier::Address("0xabcd...".to_string()),
];
let result = group.add_members_by_identity(&new_members).await?;
println!("Added {} installations", result.added_members.len());
let members_to_remove = vec![
Identifier::Address("0x1234...".to_string()),
];
group.remove_members_by_identity(&members_to_remove).await?;
Direct Messages (DMs)
DMs are a special type of group limited to two participants.Find or Create DM
The recommended approach automatically handles duplicate DMs:find_or_create_dm prevents duplicate DMs by:- Checking for existing active DMs with the target inbox
- Returning the existing DM if found
- Creating a new DM only if none exists
DM Metadata
Customize DM settings:Syncing Groups
Sync Welcomes
Fetch groups you’ve been added to:Sync Group Messages
Update a specific group:Combined Sync
Sync welcomes and all groups in one call:Querying Groups
Find Groups
Query with filters:Get Specific Group
Look up by group ID:List Conversations
Get conversations with last message:Updating Group Metadata
Group admins can update metadata:Metadata updates are governed by the group’s permission policies. See Permissions and Policies for details.
Group Properties
Error Handling
Common group management errors:Best Practices
// Before important operations
group.sync().await?;
// Or use periodic background sync
let summary = client.sync_all_welcomes_and_groups(None).await?;
// Good - prevents duplicates
let dm = client.find_or_create_dm(inbox_id, None).await?;
// Avoid - can create duplicates
// let dm = client.create_dm_by_inbox_id(inbox_id, None).await?;
Next Steps
Sending Messages
Send and receive messages in groups
Permissions and Policies
Configure who can perform actions in groups
