Overview
Baileys provides comprehensive methods for working with WhatsApp group invite codes. You can generate invite links, revoke them, join groups using codes, and get information about groups before joining.Getting Invite Codes
Retrieve the current invite code for a group.Function Signature
jid- The group JID
Get Invite Code
Only group admins can retrieve the invite code.
Creating an Invite Link
To create a clickable WhatsApp invite link:Complete Example
Revoking Invite Codes
Revoke the current invite code and generate a new one.Function Signature
jid- The group JID
Revoke and Get New Code
Safe Revoke Pattern
Revoking V4 Invites
Revoke a specific user’s V4 invite.Function Signature
groupJid- The group JIDinvitedJid- JID of the person whose invite you want to revoke
true if successful
Revoke Specific User’s Invite
Joining Groups with Invite Codes
Join a group using an invite code.Function Signature
code- The invite code (without the URL prefix)
Join Using Code
The code parameter should be only the code, not the full URL. Extract it from
https://chat.whatsapp.com/CODEJoin with Error Handling
Joining with GroupInviteMessage (V4)
Accept a group invite using a GroupInviteMessage.Function Signature
key- The message key or sender JIDinviteMessage- The GroupInviteMessage object
Accept V4 Invite
Handle GroupInviteMessage from Events
When you accept a V4 invite, the library automatically expires the invite message in your chat.
Getting Group Info Before Joining
Fetch group metadata using just the invite code, without joining.Function Signature
code- The invite code (without URL prefix)
Get Group Information
Preview Group Before Joining
Complete Invite Management System
Comprehensive example combining all invite functionality:1
Generate and share invite
2
Manage invite security
3
Smart join with validation
Best Practices
Preview Before Joining: Always use
groupGetInviteInfo to check group details before joining with groupAcceptInvite.Code Format: When using invite codes, ensure you pass only the code portion, not the full URL.
Security Tips
- Regular Rotation: Periodically revoke and regenerate invite codes for sensitive groups
- Approval Mode: Enable join approval mode for additional security
- Validate Before Joining: Check group size and description before auto-joining
- Track Invites: Keep logs of when invite codes are generated and shared
Helper Functions
Common Use Cases
Automated Invite Distribution
Temporary Invite Links
Related Methods
- Creating Groups - Create new groups
- Managing Participants - Handle join requests
- Group Settings - Configure join approval mode
- Group Metadata - View group information