WhatsApp· 5 min read

@lid vs JID: why group contacts stopped resolving to numbers


An @lid is a WhatsApp user identifier that contains no phone number. Since 2025, libraries built on WhatsApp Web receive it in place of the phone-based JID for some senders, first in groups and then in direct chats. Any lookup that expects a phone number in the sender field then fails. The fix is to store both identifiers for each contact and look up by either one.

What a JID is

A JID is the address WhatsApp uses for a chat or a user. For a person it has been the phone number in international format without the plus sign, followed by a server suffix. WhatsApp Web clients such as WAHA document the form [email protected]; Baileys users write the same number as [email protected] (Baileys issue 2414, opened 2026-03-13, accessed 2026-10-28). Groups use @g.us. The two person suffixes name the same user and can be swapped by string replacement. That is why so much code strips the suffix and treats the rest as a phone number.

What an @lid is, and what WhatsApp has said

The @lid form is 123456789012345@lid. The number before the suffix is an identifier WhatsApp assigns to the account. It is not a phone number and no arithmetic or formatting turns it into one. Baileys issue 2414 calls it “an arbitrary number, NOT a phone”.

WhatsApp has not published a developer page that defines @lid, when it appears or how to map it. We searched the WhatsApp Help Center and the WhatsApp Business Platform documentation on 2026-10-28 and found no reference. The only official pages about hidden numbers concern user privacy in communities. WhatsApp’s community safety guide warns that mentioning a member in the announcement group “will expose that contact’s phone number”, which implies the number is otherwise hidden there. Anything more specific comes from the libraries.

When it started, according to the public record

The dates below are the earliest public traces we found in each project. They show when developers started seeing the identifier, not when WhatsApp switched it on.

Project First dated record What it shows
WAHA Issue 993, opened 2025-05-26 A request to add the phone JID to every webhook because senders were arriving as @lid in groups
whatsapp-web.js PR 3702, opened 2025-08-13, merged 2025-09-06 getCurrentLid and getPhoneNumber returned undefined for contacts you had never messaged; the fix forces the lookup
Evolution API Issue 1872, opened 2025-08-25, still open Umbrella thread: remoteJid arrives as @lid, Chatwoot creates duplicate contacts, Typebot sends fail with exists: false
Baileys Release 6.7.19, 2025-08-31 “add lid to message key” and phoneNumber on group participants “with lid addressing mode”

All links accessed 2026-10-28.

Groups came first. In Baileys issue 1737 the group-participants.update event carried participant IDs ending in @lid instead of @s.whatsapp.net. By August 2025 the same thing reached private chats. The author of Baileys issue 1718 (2025-08-26) wrote that in groups “the participant field sometimes still has a valid number”. In direct messages there was “no reliable way to map the LID to the real JID”. WAHA issue 1608 (2025-11-07) shows the payload shape: payload.from and _data.key.remoteJid both @lid, with the phone JID in _data.key.remoteJidAlt.

Why phone-number lookups break

Your code received [email protected] for years and did split('@')[0] to get a phone number. Now the same contact arrives as 98765432109876@lid in one event and as the phone JID in another. Three things fail at once.

The lookup misses. WHERE phone = '98765432109876' finds nothing, so the integration creates a new contact. Evolution API’s umbrella thread lists this as Chatwoot “duplicate contacts, splitting one customer’s history”.

The reply fails. Some libraries accept @lid as a send target and some do not. The WAHA reporter stored the @lid as the customer ID. On that version, “sending messages to that JID fails since it’s not a valid WhatsApp JID”. In Evolution API, replying to a @lid returned 400 "exists: false".

The alternate field is not always there. Each library now exposes a companion field with the phone JID when it knows it. Baileys-based stacks carry remoteJidAlt and key.senderPn (Baileys issue 1768, opened 2025-09-12). WAHA’s NOWEB and GOWS engines carry payload._data.key.senderPn and payload._data.Info.SenderAlt (issue 993, comment of 2025-09-29).

When the library does not know the mapping, the field is empty. A reporter in the Evolution thread notes that “remoteJidAlt frequently arrives empty”. WAHA’s docs say the phone number “may not be found if it isn’t in your contact list, or if you aren’t a group admin”. Its GET /api/{session}/lids/{lid} returns "pn": null in that case. whatsapp-web.js added getContactLidAndPhone, which returns {lid, pn} pairs for a list of user IDs. If the mapping is unknown at that moment, the @lid is all you have.

Store both identifiers

Treat the @lid as a first-class key rather than a broken phone number. One row per contact, two nullable identifier columns, a unique index on each, and a rule that at least one is present.

CREATE TABLE contacts (
  id           bigserial PRIMARY KEY,
  phone        text,          -- digits only, e.g. 5511999990000
  lid          text,          -- digits before @lid, e.g. 98765432109876
  display_name text,
  created_at   timestamptz NOT NULL DEFAULT now(),
  updated_at   timestamptz NOT NULL DEFAULT now(),
  CONSTRAINT contacts_has_identifier CHECK (phone IS NOT NULL OR lid IS NOT NULL)
);

CREATE UNIQUE INDEX contacts_phone_key ON contacts (phone) WHERE phone IS NOT NULL;
CREATE UNIQUE INDEX contacts_lid_key   ON contacts (lid)   WHERE lid IS NOT NULL;

On every inbound message, parse whatever identifiers the payload carries. If the sender is @lid, take the digits as lid; if any alternate field holds a phone JID, take its digits as phone. Then look up by either column.

SELECT id, phone, lid
FROM contacts
WHERE (phone = :phone AND :phone IS NOT NULL)
   OR (lid = :lid AND :lid IS NOT NULL)
LIMIT 1;

When the row exists with only one identifier and the message brings the other, fill the gap.

UPDATE contacts
SET phone = COALESCE(phone, :phone),
    lid   = COALESCE(lid, :lid),
    updated_at = now()
WHERE id = :id;

If that update violates contacts_phone_key, you already have a second row for the same person, created before you learned the mapping. Move that row’s messages to the surviving row and delete it. Keep the raw sender string on each message as well (sender_jid text). Then you can re-run the merge when a mapping arrives that you did not have at receive time.

Two habits save you from the next change. Never send to a value you built by string replacement; send to the identifier the library gave you for that chat. Never key an external system (CRM, Typebot, a Google Sheet) on the phone number alone. Key it on your contacts.id and let that row hold both WhatsApp identifiers.

If you receive messages through Z-API Omni, the webhook documentation lists which identifier fields each event carries; map them into the two columns above the same way.

If you are on Meta’s official API

The Cloud API webhook has no lid field (webhook component reference, accessed 2026-10-28), but it has the same problem under another name. Since April 2026 Meta sends a business-scoped user ID in user_id on every messages webhook, to support WhatsApp usernames. When a user adopts a username, the phone number can be left out of the payload (Business-scoped user IDs, accessed 2026-11-02). The two-column contact table above works there too, with the BSUID in place of the lid; WhatsApp phone number format has the schema. If you are choosing between the two connections and identifiers matter to you, see QR connection vs Meta’s official API.

Z-API Omni team