Skip to main content

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

From src/WABinary/jid-utils.ts:8:

User JIDs

Standard User Format

Examples:
  • 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

This format is deprecated but still encountered in some contexts.

Group JIDs

Format

Example: 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

Example: 1234567890@broadcast

Stories/Status

From src/WABinary/jid-utils.ts:5:
Stories use the special JID status@broadcast.

Newsletter JIDs

Format

Newsletters (WhatsApp Channels) use the @newsletter server.

JID Utilities

Baileys provides utility functions for working with JIDs.

jidDecode

Parse a JID into its components: From src/WABinary/jid-utils.ts:55:
Example:

jidEncode

Construct a JID from components: From src/WABinary/jid-utils.ts:51:
Example:

jidNormalizedUser

Normalize a user JID (convert c.us to s.whatsapp.net): From src/WABinary/jid-utils.ts:113:
Example:

JID Type Checking

Baileys provides functions to check JID types: From src/WABinary/jid-utils.ts:87-108:
Examples:

Special JIDs

From src/WABinary/jid-utils.ts:1-6:

Meta AI Bot

Multi-Device Protocol

Device IDs

In multi-device protocol, JIDs can include a device ID:
  • :0 is the primary device (phone)
  • :1, :2, etc. are companion devices

Transferring Device ID

From src/WABinary/jid-utils.ts:123:
Example:

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

From src/WABinary/jid-utils.ts:20:
Domain types are used internally to route messages to the correct server infrastructure.

Best Practices

JID Handling Tips:
  1. Always validate - Use type checking functions before operations
  2. Normalize user JIDs - Use jidNormalizedUser for consistency
  3. Handle device IDs - Use areJidsSameUser to compare users across devices
  4. Never hardcode formats - Use jidEncode to construct JIDs
  5. Check types - Use isJidGroup, isJidBroadcast, etc. before group operations
  6. Store normalized JIDs - Always normalize before storing in database

Common Mistakes

Avoid These Mistakes:❌ Including + in JIDs: +19999999999@s.whatsapp.net✅ Use digits only: 19999999999@s.whatsapp.net❌ Mixing server types: Using c.us for new messages✅ Use s.whatsapp.net for users: jidNormalizedUser(jid)❌ String concatenation: phoneNumber + '@s.whatsapp.net'✅ Use jidEncode: jidEncode(phoneNumber, 's.whatsapp.net')

See Also