Skip to main content

Documentation Index

Fetch the complete documentation index at: https://zapo.to/llms.txt

Use this file to discover all available pages before exploring further.

A JID (Jabber ID) is how WhatsApp addresses every entity. zapo exports a set of helpers to build and classify them, all from the package root:
import { parsePhoneJid, isGroupJid, splitJid } from 'zapo-js'

JID shapes

EntityExample
User (phone)5511999999999@s.whatsapp.net
Group123456789-987654@g.us
Newsletter / channel120363000000000000@newsletter
Status broadcaststatus@broadcast
LID (privacy id)123456789@lid

Building JIDs

// Phone number → user JID
parsePhoneJid('5511999999999')        // '5511999999999@s.whatsapp.net'

// Normalize anything into a recipient JID (accepts a number or string)
normalizeRecipientJid('5511999999999')

// Strip a device suffix down to the base user JID
toUserJid('5511999999999:12@s.whatsapp.net') // '5511999999999@s.whatsapp.net'

// Build a device-scoped JID
buildDeviceJid('5511999999999@s.whatsapp.net', 12)

Parsing & splitting

splitJid('5511999999999@s.whatsapp.net')  // { user, server }
parseJidFull(jid)                         // ParsedJid with full breakdown
parseSignalAddressFromJid(jid)            // { user, device }

Classifying JIDs

Boolean predicates for routing logic:
HelperTrue for
isGroupJid(jid)Group (@g.us)
isGroupOrBroadcastJid(jid)Group or broadcast
isBroadcastJid(jid)Broadcast list
isStatusBroadcastJid(jid)status@broadcast
isNewsletterJid(jid)Newsletter (@newsletter)
isLidJid(jid)LID (@lid)
isBotJid(jid)A bot (@bot)
isHostedDeviceJid(jid)Hosted device
client.on('message', (event) => {
  if (isGroupJid(event.chatJid!)) {
    console.log('a group message')
  }
})

Constants

The full set of protocol constants is exported as frozen WA_* objects (the library uses these instead of TypeScript enums). The most commonly used:
ConstantContains
WA_DEFAULTSDefault timeouts, the status-broadcast JID, the default device browser, …
WA_BROWSERSBrowser identifiers for the device fingerprint.
WA_PRIVACY_CATEGORIES / WA_PRIVACY_VALUESPrivacy setting names and allowed values.
WA_DISCONNECT_REASONS / WA_LOGOUT_REASONSReason strings on connection events.
WA_MESSAGE_TYPES / WA_MESSAGE_TAGSMessage classification.
WA_NODE_TAGS / WA_XMLNSProtocol node tags and XML namespaces.
WA_APP_STATE_COLLECTIONSApp-state collection names.
import { WA_DEFAULTS, WA_LOGOUT_REASONS } from 'zapo-js'

await client.logout(WA_LOGOUT_REASONS.USER_INITIATED)
Associated string-literal types are also exported for annotation: WaPrivacyCategory, WaPrivacySettingName, WaPrivacyValue, WaDisconnectReason, WaLogoutReason, WaConnectionCode, WaStreamErrorCode, WaFailureReasonCode, and ParsedJid.

Other utilities

ExportPurpose
protoThe full protobuf namespace — build raw Proto.IMessage payloads.
delay(ms)Promise-based sleep.
parseUsyncResultEnvelopeParse a USync IQ result envelope.
Last modified on May 27, 2026