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.

WaClient is a strongly-typed event emitter. Every incoming activity — messages, receipts, group changes, presence — is surfaced as an event with a typed payload.

Listening

import type { WaIncomingMessageEvent } from 'zapo-js'

client.on('message', (event: WaIncomingMessageEvent) => {
  console.log(event.chatJid, event.message)
})

client.once('auth_paired', ({ credentials }) => {
  console.log('paired', credentials.meJid)
})

const handler = (e) => { /* ... */ }
client.on('receipt', handler)
client.off('receipt', handler) // stop listening
on, once, and off are all type-checked against the event map — the payload type is inferred from the event name, so listeners get full autocomplete.

Auth & connection

EventPayloadDescription
auth_qr{ qr, ttlMs }A QR code to render for pairing.
auth_pairing_code{ code }An 8-digit pairing code was issued.
auth_pairing_required{ forceManual }The session needs pairing input.
auth_paired{ credentials }Pairing succeeded.
connectionWaConnectionEventSocket opened or closed (see below).
The connection event is a discriminated union on status:
client.on('connection', (event) => {
  if (event.status === 'open') {
    console.log('online; new login?', event.isNewLogin)
  } else {
    console.log('closed:', event.reason, 'logout?', event.isLogout)
  }
})
See Reconnection for the handling pattern.

Messages

EventPayloadDescription
messageWaIncomingMessageEventAn incoming (or self-sent) message.
message_addonWaIncomingAddonEventReactions, poll votes, comments (decrypted addons).
message_protocolWaIncomingProtocolMessageEventProtocol messages (edits, revokes, …).
message_bot_chunkWaIncomingBotChunkEventStreamed bot response chunks.
receiptWaIncomingReceiptEventDelivery / read / played receipts.
See Receiving messages for payload details and text extraction.

Presence & chat-state

EventPayloadDescription
presenceWaIncomingPresenceEventA contact’s presence changed (available / last-seen).
chatstateWaIncomingChatstateEventTyping / recording / paused.
callWaIncomingCallEventIncoming call signaling.

Groups, newsletters & profiles

EventPayloadDescription
groupWaGroupEventGroup create/subject/participant/setting changes.
newsletterWaIncomingNewsletterEventNewsletter activity.
newsletter_message_updateWaIncomingNewsletterMessageUpdateEventEdits/reactions/poll updates on newsletter messages.
businessWaBusinessEventBusiness profile changes.
pictureWaPictureEventProfile/group picture changes.

State, history & MEX

EventPayloadDescription
mutationWaAppStateMutationEventApp-state mutation (mute, pin, archive, …) synced from another device.
history_sync_chunkWaHistorySyncChunkEventA chunk of synced message history.
offline_resumeWaOfflineResumeEventProgress of the post-connect offline-message drain.
mex_notificationWaMexNotificationEventMEX (GraphQL) notifications: username, status, LID changes, capping.

Failures

EventPayloadDescription
stream_failureWaIncomingFailureEventA stream-level failure (may precede a disconnect).
stanza_errorWaIncomingErrorStanzaEventAn error stanza from the server.

Debug events

A family of debug_* events expose low-level internals — raw frames, decoded nodes, decode errors, unhandled stanzas, and client errors. They are useful for protocol debugging but noisy; subscribe selectively.
client.on('debug_transport_node_in', ({ node }) => console.dir(node, { depth: null }))
client.on('debug_client_error', ({ error }) => console.error(error))
Mobile-registration events (mobile_registration_code, mobile_account_takeover_notice) exist for the mobile-registration path and are not part of the standard companion flow.
Last modified on May 27, 2026