Documentation Index
Fetch the complete documentation index at: https://zapo.to/llms.txt
Use this file to discover all available pages before exploring further.
WaClient takes a WaClientOptions object and an optional logger:
store and sessionId are required; everything else has a sensible default.
Required options
The store instance built by
createStore. Holds every per-session domain (auth, signal, app-state, …).Logical session identifier — it keys every domain inside
store. Use a stable string per device/account. Changing it between runs orphans the previous credentials and forces re-pairing.Sessions and multi-tenancy
Because every store domain is keyed bysessionId, a single store can hold many independent accounts. To run several accounts in one process, create one WaClient per sessionId over the same store:
Device fingerprint
These control how the device appears under Linked devices on the phone:Browser id advertised during pairing (
'chrome', 'firefox', 'safari', …; see WA_BROWSERS). Drives the Linked Devices label.Numeric companion platform id override (
WA_COMPANION_PLATFORM_IDS). Inferred from deviceBrowser when omitted; set explicitly for non-browser platforms.History sync
Controls the initial message-history download.
enabled?: boolean— download history on first sync.requireFullSync?: boolean— request the full archive instead of just recent chats.
history_sync_chunk events.
Timeouts
All in milliseconds; defaults are tuned for production.| Option | Purpose |
|---|---|
iqTimeoutMs | Default timeout for IQ queries (default 60s). |
nodeQueryTimeoutMs | Default timeout for raw node query() calls. |
keepAliveIntervalMs | Interval between keep-alive ping IQs. |
deadSocketTimeoutMs | How long without a reply before the socket is considered dead. |
mediaTimeoutMs | Media upload/download timeout. |
appStateSyncTimeoutMs | App-state sync round timeout. |
messageAckTimeoutMs | How long message.send waits for the server <ack> per attempt. |
messageMaxAttempts | Max attempts for a single message.send. |
messageRetryDelayMs | Delay between message-send retries. |
Presence on connect
true— announce the client as online (matches WhatsApp Web with the tab focused).false— announce as unavailable. Useful for bots that should not appear online. With this off, you also keep receiving notifications for messages while “offline”.
Addons (reactions, poll votes)
Set
autoDecrypt: true to automatically decrypt encrypted addons (poll votes, reactions, …) and emit them as typed message_addon events. Otherwise call client.message.tryDecryptAddon(event) yourself.Write-behind persistence
Batches incoming messages before flushing to the
messages / threads / contacts stores.maxPendingKeys?: numbermaxWriteConcurrency?: numberflushTimeoutMs?: number
Proxy
Route each leg through a proxy independently:
ws— the WebSocket connection.mediaUpload/mediaDownload— media transfers.linkPreview— the default link-preview fetcher.
WaProxyTransport, which is either:
- an undici dispatcher (
WaProxyDispatcher, e.g. an undiciProxyAgent) — used for thefetch-based legs (media, link preview), or - a Node
http/httpsAgent (WaProxyAgent) — used for the WebSocket (ws) leg.
The
ws leg requires the ws package, because the runtime’s native WebSocket cannot accept an HTTP Agent. Without a proxy, no extra package is needed.HTTP / HTTPS proxy
Use an undiciProxyAgent (a dispatcher) for the media/link-preview legs, and an https-proxy-agent (an http.Agent) for the ws leg:
SOCKS proxy
Usesocks-proxy-agent (works as an http.Agent for every leg, including ws):
IPv4 and IPv6 hosts
The proxy host can be a domain or an IP literal. IPv6 addresses must be wrapped in brackets:Logout store clearing
Per-domain control over what
logout() wipes. Defaults to clearing everything; set a domain to false to preserve it.Logging
Pass a logger as the second constructor argument. Two implementations ship with the package:ConsoleLogger is used. Log levels: trace, debug, info, warn, error.
