Class: Client

Client(options)

Starting point for interacting with the WhatsApp Web API

Constructor

new Client(options)

Parameters:
Name Type Description
options object

Client options

Properties
Name Type Description
authStrategy AuthStrategy

Determines how to save and restore sessions. If not set, NoAuth will be used.

webVersion string

The version of WhatsApp Web to use. Use options.webVersionCache to configure how the version is retrieved.

webVersionCache object

Determines how to retrieve the WhatsApp Web version. Defaults to a strict local cache and fails if the requested version is missing.

authTimeoutMs number

Timeout for authentication selector in puppeteer

evalOnNewDoc function

function to eval on new doc

puppeteer object

Puppeteer launch options. View docs here: https://github.com/puppeteer/puppeteer/

qrMaxRetries number

How many times should the qrcode be refreshed before giving up

takeoverOnConflict number

If another whatsapp web session is detected (another browser), take over the session in the current browser

takeoverTimeoutMs number

How much time to wait before taking over the session

userAgent string

User agent to use in puppeteer

ffmpegPath string

Ffmpeg path to use when formatting videos to webp while sending stickers

bypassCSP boolean

Sets bypassing of page's Content-Security-Policy.

emitHistoricalEvents boolean

Emit events from synchronization/history. When false, synchronized historical events are ignored.

resolveCiphertextMessages boolean

When true, attempts to resolve ciphertext messages by polling the Store.

ciphertextResolutionDelaysMs Array.<number>

Retry delays in milliseconds used to resolve ciphertext messages.

deviceName string

Sets the device name of a current linked device., i.e.: 'TEST'.

browserName string

Sets the browser name of a current linked device, i.e.: 'Firefox'.

proxyAuthentication object

Proxy Authentication object.

Source:
Fires:

Extends

  • EventEmitter

Members

pupBrowser :puppeteer.Browser

Type:
  • puppeteer.Browser
Source:

pupPage :puppeteer.Page

Type:
  • puppeteer.Page
Source:

Methods

(async) _muteUnmuteChat(chatId, action, unmuteDateTs) → {Promise.<{isMuted: boolean, muteExpiration: number}>}

Internal method to mute or unmute the chat

Parameters:
Name Type Description
chatId string

ID of the chat that will be muted/unmuted

action string

The action: 'MUTE' or 'UNMUTE'

unmuteDateTs number

Timestamp at which the chat will be unmuted

Source:
Returns:
Type
Promise.<{isMuted: boolean, muteExpiration: number}>

(async) acceptChannelAdminInvite(channelId) → {Promise.<boolean>}

Accepts a channel admin invitation and promotes the current user to a channel admin

Parameters:
Name Type Description
channelId string

The channel ID to accept the admin invitation from

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) acceptGroupV4Invite(inviteInfo) → {Promise.<Object>}

Accepts a private invitation to join a group

Parameters:
Name Type Description
inviteInfo object

Invite V4 Info

Source:
Returns:
Type
Promise.<Object>

(async) acceptInvite(inviteCode) → {Promise.<string>}

Accepts an invitation to join a group

Parameters:
Name Type Description
inviteCode string

Invitation code

Source:
Returns:

Id of the joined Chat

Type
Promise.<string>

(async) addOrEditCustomerNote(userId, note) → {Promise.<void>}

Add or edit a customer note

Parameters:
Name Type Description
userId string

The ID of a customer to add a note to

note string

The note to add Customer notes are available only to eligible WhatsApp Business accounts.

Source:
See:
Returns:
Type
Promise.<void>

(async) addOrRemoveLabels(labelIds, chatIds) → {Promise.<void>}

Change labels in chats

Parameters:
Name Type Description
labelIds Array.<(number|string)>
chatIds Array.<string>
Source:
Returns:
Type
Promise.<void>

(async) approveGroupMembershipRequests(groupId, options) → {Promise.<Array.<MembershipRequestActionResult>>}

Approves membership requests if any

Parameters:
Name Type Description
groupId string

The group ID to get the membership request for

options MembershipRequestActionOptions

Options for performing a membership request action

Source:
Returns:

Returns an array of requester IDs whose membership requests were approved and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned

Type
Promise.<Array.<MembershipRequestActionResult>>

(async) archiveChat() → {boolean}

Enables and returns the archive state of the Chat

Source:
Returns:
Type
boolean

assertPublicEventGateHealthy()

Confirms that a native handoff still owns the unpublished event gate. RemoteAuth invokes this inside its final fenced promotion gate.

Source:

(async) attachEventListeners(expectedDocumentEpochopt)

Attach event listeners to WA Web Private function

Parameters:
Name Type Attributes Description
expectedDocumentEpoch number <optional>

document identity fence

Source:

(async) cancelPairingCode()

Cancels an active pairing code session and returns to QR code mode

Source:

(async) createChannel(title, options) → {Promise.<(CreateChannelResult|string)>}

Creates a new channel

Parameters:
Name Type Description
title string

The channel name

options CreateChannelOptions
Source:
Returns:

Returns an object that handles the result for the channel creation or an error message as a string

Type
Promise.<(CreateChannelResult|string)>

(async) createGroup(title, participants, options) → {Promise.<(CreateGroupResult|string)>}

Creates a new group

Parameters:
Name Type Description
title string

Group title

participants string | Contact | Array.<(Contact|string)> | undefined

A single Contact object or an ID as a string or an array of Contact objects or contact IDs to add to the group

options CreateGroupOptions

An object that handles options for group creation

Source:
Returns:

Object with resulting data or an error message as a string

Type
Promise.<(CreateGroupResult|string)>

(async) deleteAddressbookContact(phoneNumber) → {Promise.<void>}

Deletes the contact from user's addressbook

Parameters:
Name Type Description
phoneNumber string

The contact's phone number in a format "17182222222", where "1" is a country code

Source:
Returns:
Type
Promise.<void>

(async) deleteChannel(channelId) → {Promise.<boolean>}

Deletes the channel you created

Parameters:
Name Type Description
channelId string

The ID of a channel to delete

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) deleteProfilePicture() → {Promise.<boolean>}

Deletes the current user's profile picture.

Source:
Returns:

Returns true if the picture was properly deleted.

Type
Promise.<boolean>

(async) demoteChannelAdmin(channelId, userId) → {Promise.<boolean>}

Demotes a channel admin to a regular subscriber (can be used also for self-demotion)

Parameters:
Name Type Description
channelId string

The channel ID to demote an admin in

userId string

The user ID to demote

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) destroy()

Closes the client

Source:

emit()

EventEmitter boundary used to hold every public WWebJS event emitted by a staging handoff. Internal browser/authentication callbacks continue to run, while consumers see nothing until durable promotion succeeds.

Source:

(async) getBlockedContacts() → {Promise.<Array.<Contact>>}

Gets all blocked contacts by host account

Source:
Returns:
Type
Promise.<Array.<Contact>>

(async) getBroadcastById(contactId) → {Promise.<Broadcast>}

Get broadcast instance by current user ID

Parameters:
Name Type Description
contactId string
Source:
Returns:
Type
Promise.<Broadcast>

(async) getBroadcasts() → {Promise.<Array.<Broadcast>>}

Get all current Broadcast

Source:
Returns:
Type
Promise.<Array.<Broadcast>>

(async) getChannelByInviteCode(inviteCode) → {Promise.<Channel>}

Gets a Channel instance by invite code

Parameters:
Name Type Description
inviteCode string

The code that comes after the 'https://whatsapp.com/channel/'

Source:
Returns:
Type
Promise.<Channel>

(async) getChannels() → {Promise.<Array.<Channel>>}

Gets all cached Channel instance

Source:
Returns:
Type
Promise.<Array.<Channel>>

(async) getChatById(chatId) → {Promise.<(Chat|Channel)>}

Gets chat or channel instance by ID

Parameters:
Name Type Description
chatId string
Source:
Returns:
Type
Promise.<(Chat|Channel)>

(async) getChatLabels(chatId) → {Promise.<Array.<Label>>}

Get all Labels assigned to a chat

Parameters:
Name Type Description
chatId string
Source:
Returns:
Type
Promise.<Array.<Label>>

(async) getChats() → {Promise.<Array.<Chat>>}

Get all current chat instances

Source:
Returns:
Type
Promise.<Array.<Chat>>

(async) getChatsByLabelId(labelId) → {Promise.<Array.<Chat>>}

Get all Chats for a specific Label

Parameters:
Name Type Description
labelId string
Source:
Returns:
Type
Promise.<Array.<Chat>>

(async) getCommonGroups(contactId) → {Promise.<Array.<WAWebJS.ChatId>>}

Gets the Contact's common groups with you. Returns empty array if you don't have any common group.

Parameters:
Name Type Description
contactId string

the whatsapp user's ID (_serialized format)

Source:
Returns:
Type
Promise.<Array.<WAWebJS.ChatId>>

(async) getCompanionIdentity() → {Promise.<{jid: string, companionFingerprint: string, fingerprintVersion: string, moduleAbi: string, webVersion: string}>}

Resolves the canonical companion identity without returning key material from the page realm.

Source:
Returns:
Type
Promise.<{jid: string, companionFingerprint: string, fingerprintVersion: string, moduleAbi: string, webVersion: string}>

getConnectionStatus() → {Readonly.<object>}

Returns an immutable provider-neutral connection snapshot without a browser or database round trip.

Source:
Returns:
Type
Readonly.<object>

(async) getContactById(contactId) → {Promise.<Contact>}

Get contact instance by ID

Parameters:
Name Type Description
contactId string
Source:
Returns:
Type
Promise.<Contact>

(async) getContactDeviceCount(userId) → {Promise.<number>}

Get user device count by ID Each WaWeb Connection counts as one device, and the phone (if exists) counts as one So for a non-enterprise user with one WaWeb connection it should return "2"

Parameters:
Name Type Description
userId string
Source:
Returns:
Type
Promise.<number>

(async) getContactLidAndPhone(userIds) → {Promise.<Array.<{lid: string, pn: string}>>}

Get lid and phone number for multiple users

Parameters:
Name Type Description
userIds Array.<string>

Array of user IDs

Source:
Returns:
Type
Promise.<Array.<{lid: string, pn: string}>>

(async) getContacts() → {Promise.<Array.<Contact>>}

Get all current contact instances

Source:
Returns:
Type
Promise.<Array.<Contact>>

(async) getCountryCode(number) → {Promise.<string>}

Get the country code of a WhatsApp ID.

Parameters:
Name Type Description
number string

Number or ID

Source:
Returns:
Type
Promise.<string>

(async) getCustomerNote(userId) → {Promise.<({chatId: string, content: string, createdAt: number, id: string, modifiedAt: number, type: string}|null)>}

Get a customer note

Parameters:
Name Type Description
userId string

The ID of a customer to get a note from

Source:
See:
Returns:

Null when customer notes are unavailable for the account.

Type
Promise.<({chatId: string, content: string, createdAt: number, id: string, modifiedAt: number, type: string}|null)>

(async) getFormattedNumber(number) → {Promise.<string>}

Get the formatted number of a WhatsApp ID.

Parameters:
Name Type Description
number string

Number or ID

Source:
Returns:
Type
Promise.<string>

(async) getGroupMembershipRequests(groupId) → {Promise.<Array.<GroupMembershipRequest>>}

Gets an array of membership requests

Parameters:
Name Type Description
groupId string

The ID of a group to get membership requests for

Source:
Returns:

An array of membership requests

Type
Promise.<Array.<GroupMembershipRequest>>

(async) getInteractiveCapabilities()

Source:

(async) getInteractiveMessageCapabilities() → {Promise.<object>}

Reports the interactive-message features exposed by the active WhatsApp Web runtime. This is a local capability probe; server-side eligibility is still established only by a real send/receive canary.

Source:
Returns:
Type
Promise.<object>

(async) getInviteInfo(inviteCode) → {Promise.<object>}

Returns an object with information about the invite code's group

Parameters:
Name Type Description
inviteCode string
Source:
Returns:

Invite information

Type
Promise.<object>

(async) getLabelById(labelId) → {Promise.<Label>}

Get Label instance by ID

Parameters:
Name Type Description
labelId string
Source:
Returns:
Type
Promise.<Label>

(async) getLabels() → {Promise.<Array.<Label>>}

Get all current Labels

Source:
Returns:
Type
Promise.<Array.<Label>>

(async) getMessageById(messageId) → {Promise.<Message>}

Get message by ID

Parameters:
Name Type Description
messageId string
Source:
Returns:
Type
Promise.<Message>

(async) getNumberId(number) → {Promise.<(Object|null)>}

Get the registered WhatsApp ID for a number. Will return null if the number is not registered on WhatsApp.

Parameters:
Name Type Description
number string

Number or ID ("@c.us" will be automatically appended if not specified)

Source:
Returns:
Type
Promise.<(Object|null)>

(async) getPinnedMessages(chatId) → {Promise.<Array.<Message>>}

Gets instances of all pinned messages in a chat

Parameters:
Name Type Description
chatId string

The chat ID

Source:
Returns:
Type
Promise.<Array.<Message>>

(async) getPollVotes(messageId) → {Promise.<Array.<PollVote>>}

Get Poll Votes

Parameters:
Name Type Description
messageId string
Source:
Returns:
Type
Promise.<Array.<PollVote>>

(async) getProfilePicUrl(contactId) → {Promise.<string>}

Returns the contact ID's profile picture URL, if privacy settings allow it

Parameters:
Name Type Description
contactId string

the whatsapp user's ID

Source:
Returns:
Type
Promise.<string>

(async) getState() → {WAState}

Gets the current connection state for the client

Source:
Returns:
Type
WAState

(async) getWWebVersion() → {Promise.<string>}

Returns the version of WhatsApp Web currently being run

Source:
Returns:
Type
Promise.<string>

(async) initialize()

Sets up events and requirements, kicks off authentication request

Source:

(async) inject()

Injection logic Private function

Source:

(async) isRegisteredUser(id) → {Promise.<Boolean>}

Check if a given ID is registered in whatsapp

Parameters:
Name Type Description
id string

the whatsapp user's ID

Source:
Returns:
Type
Promise.<Boolean>

(async) logout()

Logs out the client, closing the current session

Source:

(async) markChatUnread(chatId)

Mark the Chat as unread

Parameters:
Name Type Description
chatId string

ID of the chat that will be marked as unread

Source:

(async) muteChat(chatId, unmuteDatenullable) → {Promise.<{isMuted: boolean, muteExpiration: number}>}

Mutes this chat forever, unless a date is specified

Parameters:
Name Type Attributes Description
chatId string

ID of the chat that will be muted

unmuteDate Date <nullable>

Date when the chat will be unmuted, don't provide a value to mute forever

Source:
Returns:
Type
Promise.<{isMuted: boolean, muteExpiration: number}>

(async) onWhatsApp(…phoneNumber) → {Promise.<Array.<{jid: (string|null), exists: boolean}>>}

Check whether numbers or IDs are registered on WhatsApp.

Accepted input formats (per item):

  • Plain number as string: 5511999999999
  • Plain number as number: 5511999999999
  • Legacy user ID: 5511999999999@c.us
  • Canonical user JID: 5511999999999@s.whatsapp.net
  • LID: 227959751348297@lid

Call styles:

  • Variadic: client.onWhatsApp('5511999999999', '227959751348297@lid')
  • Array: client.onWhatsApp(['5511999999999', '227959751348297@lid'])
  • Numeric value: client.onWhatsApp(5511999999999)

Output order matches input order.

Parameters:
Name Type Attributes Description
phoneNumber string | number | Array.<(string|number)> <repeatable>

Numbers or IDs to check

Source:
Returns:

One item per input:

  • exists: true if the account exists on WhatsApp.
  • jid: preferred @s.whatsapp.net when available; otherwise resolved _serialized (@c.us or @lid); null when not found or invalid input.
Type
Promise.<Array.<{jid: (string|null), exists: boolean}>>

(async) pinChat() → {Promise.<boolean>}

Pins the Chat

Source:
Returns:

New pin state. Could be false if the max number of pinned chats was reached.

Type
Promise.<boolean>

(async) refreshQR() → {Promise.<boolean>}

Refreshes the current QR code while the socket is still waiting for a scan. A refresh is deliberately deferred once pairing has started so the active companion handshake is never invalidated by an expiring QR timer.

Source:
Returns:

Whether a refresh was requested

Type
Promise.<boolean>

(async) rejectGroupMembershipRequests(groupId, options) → {Promise.<Array.<MembershipRequestActionResult>>}

Rejects membership requests if any

Parameters:
Name Type Description
groupId string

The group ID to get the membership request for

options MembershipRequestActionOptions

Options for performing a membership request action

Source:
Returns:

Returns an array of requester IDs whose membership requests were rejected and an error for each requester, if any occurred during the operation. If there are no requests, an empty array will be returned

Type
Promise.<Array.<MembershipRequestActionResult>>

(async) requestPairingCode(phoneNumber, showNotificationopt, intervalMsopt) → {Promise.<string>}

Request authentication via pairing code instead of QR code

Parameters:
Name Type Attributes Default Description
phoneNumber string

Phone number in international, symbol-free format (e.g. 12025550108 for US, 551155501234 for Brazil)

showNotification boolean <optional>
true

Show notification to pair on phone number

intervalMs number <optional>
180000

The interval in milliseconds on how frequent to generate pairing code (WhatsApp default to 3 minutes)

Source:
Returns:
  • Returns a pairing code in format "ABCDEFGH"
Type
Promise.<string>

(async) resetState()

Force reset of connection state for the client

Source:

(async) revokeChannelAdminInvite(channelId, userId) → {Promise.<boolean>}

Revokes a channel admin invitation sent to a user by a channel owner

Parameters:
Name Type Description
channelId string

The channel ID an invitation belongs to

userId string

The user ID the invitation was sent to

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) revokeStatusMessage(messageId) → {Promise.<void>}

Revoke current own status messages

Parameters:
Name Type Description
messageId string
Source:
Returns:
Type
Promise.<void>

(async) saveOrEditAddressbookContact(phoneNumber, firstName, lastName, syncToAddressbookopt) → {Promise.<void>}

Save new contact to user's addressbook or edit the existing one

Parameters:
Name Type Attributes Default Description
phoneNumber string

The contact's phone number in a format "17182222222", where "1" is a country code

firstName string
lastName string
syncToAddressbook boolean <optional>
false

If set to true, the contact will also be saved to the user's address book on their phone. False by default

Source:
Returns:
Type
Promise.<void>

(async) searchChannels(searchOptions) → {Promise.<Array.<Channel>>}

Searches for channels based on search criteria, there are some notes:

  1. The method finds only channels you are not subscribed to currently
  2. If you have never been subscribed to a found channel or you have unsubscribed from it with UnsubscribeOptions.deleteLocalModels set to 'true', the lastMessage property of a found channel will be 'null'
Parameters:
Name Type Description
searchOptions Object

Search options

Properties
Name Type Attributes Default Description
searchText string <optional>
''

Text to search

countryCodes Array.<string> <optional>
[your local region]

Array of country codes in 'ISO 3166-1 alpha-2' standart (@see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) to search for channels created in these countries

skipSubscribedNewsletters boolean <optional>
false

If true, channels that user is subscribed to won't appear in found channels

view number <optional>
0

View type, makes sense only when the searchText is empty. Valid values to provide are: 0 for RECOMMENDED channels 1 for TRENDING channels 2 for POPULAR channels 3 for NEW channels

limit number <optional>
50

The limit of found channels to be appear in the returnig result

Source:
Returns:

Returns an array of Channel objects or an empty array if no channels were found

Type
Promise.<Array.<Channel>>

(async) searchMessages(query, optionsopt) → {Promise.<Array.<Message>>}

Searches for messages

Parameters:
Name Type Attributes Description
query string
options Object <optional>
Properties
Name Type Attributes Description
page number <optional>
limit number <optional>
chatId string <optional>
Source:
Returns:
Type
Promise.<Array.<Message>>

(async) sendChannelAdminInvite(chatId, channelId, options) → {Promise.<boolean>}

Sends a channel admin invitation to a user, allowing them to become an admin of the channel

Parameters:
Name Type Description
chatId string

The ID of a user to send the channel admin invitation to

channelId string

The ID of a channel for which the invitation is being sent

options SendChannelAdminInviteOptions
Source:
Returns:

Returns true if an invitation was sent successfully, false otherwise

Type
Promise.<boolean>

(async) sendMessage(chatId, content, optionsopt) → {Promise.<(Message|null|undefined)>}

Send a message to a specific chatId

Parameters:
Name Type Attributes Description
chatId string
content string | MessageMedia | Location | Poll | Contact | Array.<Contact> | Buttons | List | InteractiveMessage
options MessageSendOptions <optional>

Options used when sending the message

Source:
Returns:

Message that was just sent

Type
Promise.<(Message|null|undefined)>

(async) sendPresenceAvailable()

Marks the client as online

Source:

(async) sendPresenceUnavailable()

Marks the client as unavailable

Source:

(async) sendReaction(messageId, reaction) → {Promise}

Send an emoji reaction to a specific message

Parameters:
Name Type Description
messageId string

Id of the message to add the reaction.

reaction string

Emoji to react with. Send an empty string to remove the reaction.

Source:
Returns:
Type
Promise

(async) sendResponseToScheduledEvent(response, eventMessageId) → {Promise.<boolean>}

Sends a response to the scheduled event message, indicating whether a user is going to attend the event or not

Parameters:
Name Type Description
response number

The response code to the scheduled event message. Valid values are: 0 for NONE response (removes a previous response) | 1 for GOING | 2 for NOT GOING | 3 for MAYBE going

eventMessageId string

The scheduled event message ID

Source:
Returns:
Type
Promise.<boolean>

(async) sendSeen(chatId) → {Promise.<boolean>}

Mark as seen for the Chat

Parameters:
Name Type Description
chatId string
Source:
Returns:

result

Type
Promise.<boolean>

(async) setAutoDownloadAudio(flag)

Setting autoload download audio

Parameters:
Name Type Description
flag boolean

true/false

Source:

(async) setAutoDownloadDocuments(flag)

Setting autoload download documents

Parameters:
Name Type Description
flag boolean

true/false

Source:

(async) setAutoDownloadPhotos(flag)

Setting autoload download photos

Parameters:
Name Type Description
flag boolean

true/false

Source:

(async) setAutoDownloadVideos(flag)

Setting autoload download videos

Parameters:
Name Type Description
flag boolean

true/false

Source:

(async) setBackgroundSync(flag) → {Promise.<boolean>}

Setting background synchronization. NOTE: this action will take effect after you restart the client.

Parameters:
Name Type Description
flag boolean

true/false

Source:
Returns:
Type
Promise.<boolean>

(async) setDisplayName(displayName) → {Promise.<Boolean>}

Sets the current user's display name. This is the name shown to WhatsApp users that have not added you as a contact beside your number in groups and in your profile.

Parameters:
Name Type Description
displayName string

New display name

Source:
Returns:
Type
Promise.<Boolean>

(async) setProfilePicture(media) → {Promise.<boolean>}

Sets the current user's profile picture.

Parameters:
Name Type Description
media MessageMedia
Source:
Returns:

Returns true if the picture was properly updated.

Type
Promise.<boolean>

(async) setStatus(status)

Sets the current user's status message

Parameters:
Name Type Description
status string

New status message

Source:

(async) subscribeToChannel(channelId) → {Promise.<boolean>}

Subscribe to channel

Parameters:
Name Type Description
channelId string

The channel ID

Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) syncHistory(chatId) → {Promise.<boolean>}

Sync chat history conversation

Parameters:
Name Type Description
chatId string
Source:
Returns:

True if operation completed successfully, false otherwise.

Type
Promise.<boolean>

(async) transferChannelOwnership(channelId, newOwnerId, options) → {Promise.<boolean>}

Transfers a channel ownership to another user. Note: the user you are transferring the channel ownership to must be a channel admin.

Parameters:
Name Type Description
channelId string
newOwnerId string
options TransferChannelOwnershipOptions
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

(async) unarchiveChat() → {boolean}

Changes and returns the archive state of the Chat

Source:
Returns:
Type
boolean

(async) unmuteChat(chatId) → {Promise.<{isMuted: boolean, muteExpiration: number}>}

Unmutes the Chat

Parameters:
Name Type Description
chatId string

ID of the chat that will be unmuted

Source:
Returns:
Type
Promise.<{isMuted: boolean, muteExpiration: number}>

(async) unpinChat() → {Promise.<boolean>}

Unpins the Chat

Source:
Returns:

New pin state

Type
Promise.<boolean>

(async) unsubscribeFromChannel(channelId, options) → {Promise.<boolean>}

Unsubscribe from channel

Parameters:
Name Type Description
channelId string

The channel ID

options UnsubscribeOptions
Source:
Returns:

Returns true if the operation completed successfully, false otherwise

Type
Promise.<boolean>

Events

auth_failure

Emitted when there has been an error while trying to restore an existing session

Parameters:
Name Type Description
message string
Source:

change_battery

Emitted when the battery percentage for the attached device changes. Will not be sent if using multi-device.

Parameters:
Name Type Description
batteryInfo object
Properties
Name Type Description
battery number

The current battery percentage

plugged boolean

Indicates if the phone is plugged in (true) or not (false)

Deprecated:
  • Yes
Source:

change_state

Emitted when the connection state changes

Parameters:
Name Type Description
state WAState

the new connection state

Source:

chat_archived

Emitted when a chat is archived/unarchived

Parameters:
Name Type Description
chat Chat
currState boolean
prevState boolean
Source:

chat_removed

Emitted when a chat is removed

Parameters:
Name Type Description
chat Chat
Source:

chat_state

Emitted when a chat state changes

Parameters:
Name Type Description
chatState object
Properties
Name Type Attributes Description
chatId string
userId string <nullable>
state string
isOnline boolean
isGroup boolean
typingUserIds Array.<string>
recordingUserIds Array.<string>
timestamp number <nullable>
deny boolean <nullable>
Source:

contact_changed

Emitted when a contact or a group participant changes their phone number.

Parameters:
Name Type Description
message Message

Message with more information about the event.

oldId String

The user's id (an old one) who changed their phone number and who triggered the notification.

newId String

The user's new id after the change.

isContact Boolean

Indicates if a contact or a group participant changed their phone number.

Source:

disconnected

Emitted when the client has been disconnected

Parameters:
Name Type Description
reason WAState | "LOGOUT"

reason that caused the disconnect

Source:

group_admin_changed

Emitted when a current user is promoted to an admin or demoted to a regular user.

Parameters:
Name Type Description
notification GroupNotification

GroupNotification with more information about the action

Source:

group_join

Emitted when a user joins the chat via invite link or is added by an admin.

Parameters:
Name Type Description
notification GroupNotification

GroupNotification with more information about the action

Source:

group_leave

Emitted when a user leaves the chat or is removed by an admin.

Parameters:
Name Type Description
notification GroupNotification

GroupNotification with more information about the action

Source:

group_membership_request

Emitted when some user requested to join the group that has the membership approval mode turned on

Parameters:
Name Type Description
notification GroupNotification

GroupNotification with more information about the action

Properties
Name Type Description
chatId string

The group ID the request was made for

author string

The user ID that made a request

timestamp number

The timestamp the request was made at

Source:

group_update

Emitted when group settings are updated, such as subject, description or picture.

Parameters:
Name Type Description
notification GroupNotification

GroupNotification with more information about the action

Source:

media_uploaded

Emitted when media has been uploaded for a message sent by the client. Modern WhatsApp Web builds no longer consistently transition isUnsentMedia; the first server ACK is an authoritative fallback because it is impossible before the encrypted upload is accepted.

Parameters:
Name Type Description
message Message

The message with media that was uploaded

Source:

message

Emitted when a new message is received.

Parameters:
Name Type Description
message Message

The message that was received

Source:

message_ack

Emitted when an ack event occurrs on message type.

Parameters:
Name Type Description
message Message

The message that was affected

ack MessageAck

The new ACK value

Source:

message_ciphertext

Emitted when a message is received as ciphertext (not yet decrypted)

Parameters:
Name Type Description
message Message
Source:

message_ciphertext_failed

Emitted when a ciphertext message failed to decrypt after recovery attempt

Parameters:
Name Type Description
message Message
Source:

message_create

Emitted when a new message is created, which may include the current user's own messages.

Parameters:
Name Type Description
message Message

The message that was created

Source:

message_edit

Emitted when messages are edited

Parameters:
Name Type Description
message Message
newBody string
prevBody string
Source:

message_interaction

Emitted for a bounded button, list, template-button or native-flow response. Display text and IDs are untrusted; correlated is true only when they match a recent message sent by this Client instance.

Parameters:
Name Type Description
message Message

The response message

interaction Object

Normalized response metadata

Source:

message_pinned

Emitted when a message pin/unpin action is created.

Parameters:
Name Type Description
message Message

The message that contains the pin action

pinData Object
Properties
Name Type Attributes Description
pinType string <nullable>

Raw pin type from WhatsApp model

isPinned boolean <nullable>

Indicates if it is a pin (true) or unpin (false) when available

parentMessageId string <nullable>

Parent message id that was pinned/unpinned

senderId string <nullable>

Sender/contact responsible for the action

chatId string <nullable>

Chat id where the action happened

messageType string <nullable>

Underlying WhatsApp message type

source string

Internal source that triggered the event

Source:

message_reaction

Emitted when a reaction is sent, received, updated or removed

Parameters:
Name Type Description
reaction object
Properties
Name Type Attributes Description
id object

Reaction id

orphan number

Orphan

orphanReason string <nullable>

Orphan reason

timestamp number

Timestamp

reaction string

Reaction

read boolean

Read

msgId object

Parent message id

senderId string

Sender id

ack number <nullable>

Ack

Source:

message_revoke_everyone

Emitted when a message is deleted for everyone in the chat.

Parameters:
Name Type Attributes Description
message Message

The message that was revoked, in its current state. It will not contain the original message's data.

revoked_msg Message <nullable>

The message that was revoked, before it was revoked. It will contain the message's original data. Note that due to the way this data is captured, it may be possible that this param will be undefined.

Source:

message_revoke_me

Emitted when a message is deleted by the current user.

Parameters:
Name Type Description
message Message

The message that was revoked

Source:

qr

Emitted when a QR code is received

Parameters:
Name Type Description
qr string

QR Code

Source:

vote_update

Emitted when some poll option is selected or deselected, shows a user's current selected option(s) on the poll

Source: