local@server. You will encounter them constantly in Baileys: as the target of sock.sendMessage, in the key.remoteJid of every incoming message, and as parameters to group and contact queries.
Modern WhatsApp identifies the same person in two different ways depending on context. Both are JIDs:
- PNJID — Phone Number Jabber Identifier. Lives on
@s.whatsapp.netand is derived from the user’s phone number. This is the legacy identifier and the one you use when looking someone up by their number. - LIDJID — Linked Identity Jabber Identifier. Lives on
@lidand is an opaque per-user identifier WhatsApp assigns to anonymize phone numbers in groups, communities, and other shared surfaces. This is the identifier WhatsApp uses by default in Baileys 7.x and later.
JID formats
User (PNJID)
[countrycode][number]@s.whatsapp.netExample: [email protected]User (LIDJID)
[lid]@lidExample: 123456789012345@lidGroup
[timestamp]-[random]@g.usExample: [email protected]Broadcast list
[timestamp]@broadcastExample: 1234567890@broadcastStories / Status
status@broadcastFixed constant — all status updates go to this JID.Newsletter
[id]@newsletterExample: 12345@newsletterPhone number rules
When constructing a PNJID from a phone number:- Include the country code (e.g.,
1for the US,44for the UK). - Do not include
+,-, spaces, or parentheses. [email protected]is correct;+1 (999) [email protected]is not.
PN ↔ LID: the dual-identity model
Since 2024, WhatsApp has been migrating from phone-number identifiers to LIDs (Linked Identity JIDs). A LID is an opaque, per-user identifier that hides the underlying phone number — it lets WhatsApp expose your account inside large groups, communities, and channels without leaking your number to other participants. In Baileys 7.x and later:- New Signal sessions are created in LID form by default.
- A single user has both a PNJID (
[email protected]) and a LIDJID (...@lid). They refer to the same person. - Group participant fields are typically LIDs;
participantAltcarries the matching PN, and vice versa. MessageKey.remoteJidAltandMessageKey.participantAltgive you the alternate identifier for direct messages and group/broadcast/channel messages respectively.- The
Contacttype now exposes a singleidplus pairedphoneNumber(whenidis a LID) andlid(whenidis a PN).
Don’t try to “restore” PN JIDs in your application. Migrate your storage, indexing, and routing logic to LIDs — WhatsApp treats LIDs as the canonical identifier going forward.
PNJID ↔ LIDJID resolution
WhatsApp lets you resolve a phone number to its LID. The reverse — going from a LID back to a phone number — is not generally supported. UseonWhatsApp for one-off PN existence checks, and the lidMapping store on sock.signalRepository for direct conversions:
lid-mapping.update event fires whenever Baileys learns a new PN ↔ LID pair from the wire. For more advanced directory queries (device lists, bulk metadata), see USync protocol.
Phone number sharing between accounts
Because LIDs hide phone numbers by default, WhatsApp provides explicit opt-in flags to exchange them when both sides agree:- Businesses can request the recipient’s number with
{ requestPhoneNumber: true }on a sent message. - Users can share their number with
{ sharePhoneNumber: true }.
Multi-device JIDs
In the WhatsApp multi-device protocol, a single account can have multiple connected devices. Each device gets a device suffix appended to the user portion:19999999999:[email protected] or 123456789012345:3@lid. The part before the : is the user, and the number after is the device ID.
This is why you must never compare or split JIDs with string operations — a message from device :0 and a message from device :2 belong to the same user.
JID helper functions
Baileys exports a set of helper functions from@whiskeysockets/baileys. Always use these instead of manual string manipulation.
Parsing and encoding
domainType field on the decoded result corresponds to the WAJIDDomains enum:
Type checks
isJidUser from earlier Baileys versions has been removed. Use isPnUser or isLidUser depending on which form you mean. Both PNs and LIDs are JIDs, so the old name was misleading.Common constants
META_AI_JID is the specific legacy @c.us user JID for the Meta AI account, but the broader isJidMetaAI(jid) helper only matches the @bot server domain — the domain Meta AI bot interactions actually use today. The two are intentionally different and isJidMetaAI(META_AI_JID) returns false. Compare against META_AI_JID directly when you need to match that specific account.