Overview
WhatsApp uses a special ID format called JID (Jabber ID) to identify users, groups, broadcast lists, and other entities. Understanding JID structure is essential for working with Baileys.JID Format
A JID consists of three parts:user@server[:device]
- user - The unique identifier (phone number for users, timestamp for groups)
- server - The server domain
- device - Optional device ID for multi-device protocol
Server Types
Fromsrc/WABinary/jid-utils.ts:8:
User JIDs
Standard User Format
- US number:
19999999999@s.whatsapp.net - UK number:
447777777777@s.whatsapp.net - India:
919876543210@s.whatsapp.net
User JIDs do not include
+, (), or -. Only digits followed by @s.whatsapp.net.Legacy User Format
Group JIDs
Format
123456789-1234567890@g.us
- The first number is typically a Unix timestamp of group creation
- The second number identifies the group creator
Broadcast List JIDs
Format
1234567890@broadcast
Stories/Status
Fromsrc/WABinary/jid-utils.ts:5:
status@broadcast.
Newsletter JIDs
Format
@newsletter server.
JID Utilities
Baileys provides utility functions for working with JIDs.jidDecode
Parse a JID into its components: Fromsrc/WABinary/jid-utils.ts:55:
jidEncode
Construct a JID from components: Fromsrc/WABinary/jid-utils.ts:51:
jidNormalizedUser
Normalize a user JID (convertc.us to s.whatsapp.net):
From src/WABinary/jid-utils.ts:113:
JID Type Checking
Baileys provides functions to check JID types: Fromsrc/WABinary/jid-utils.ts:87-108:
Special JIDs
Fromsrc/WABinary/jid-utils.ts:1-6:
Meta AI Bot
Multi-Device Protocol
Device IDs
In multi-device protocol, JIDs can include a device ID::0is the primary device (phone):1,:2, etc. are companion devices
Transferring Device ID
Fromsrc/WABinary/jid-utils.ts:123:
LID (Logged In Device)
LID is a privacy-focused identifier used in some contexts:LID Utilities
Practical Examples
Sending to a User
Extracting Phone Number
Validating Group JID
Filtering Message Types
JID Domain Types
Fromsrc/WABinary/jid-utils.ts:20:
Best Practices
Common Mistakes
See Also
- Events - Working with message keys
- Message Store - Indexing messages by JID
- Connection - User identification