MessagesResource
Defined in: src/resources/messages.ts:86
Outbound Messages API exposed as client.messages.
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new MessagesResource(
request,getDefaultPhoneNumberId):MessagesResource
Defined in: src/resources/messages.ts:90
Parameters
Section titled “Parameters”request
Section titled “request”RequestFn
getDefaultPhoneNumberId
Section titled “getDefaultPhoneNumberId”PhoneNumberIdAccessor
Returns
Section titled “Returns”MessagesResource
Methods
Section titled “Methods”markAsRead()
Section titled “markAsRead()”markAsRead(
messageId,phoneNumberId?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:508
Marks a received message as read.
Parameters
Section titled “Parameters”messageId
Section titled “messageId”string
phoneNumberId?
Section titled “phoneNumberId?”string
Returns
Section titled “Returns”Promise<SendMessageResponse>
sendAddressMessage()
Section titled “sendAddressMessage()”sendAddressMessage(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:437
Sends an interactive address message (supported in India and Singapore), prompting the user to supply or confirm a delivery address.
The parameters object (country, pre-filled values, saved addresses, and
validation errors) is serialized into the JSON-encoded action.parameters
string the API requires. The submitted address arrives via webhook as an
interactive nfm_reply.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendAudio()
Section titled “sendAudio()”sendAudio(
to,audio,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:136
Sends an audio message from an uploaded media id or a public link.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendContacts()
Section titled “sendContacts()”sendContacts(
to,contacts,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:186
Sends one or more contact cards.
Parameters
Section titled “Parameters”contacts
Section titled “contacts”Contact[]
options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendDocument()
Section titled “sendDocument()”sendDocument(
to,document,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:146
Sends a document message, with optional caption and display filename.
Parameters
Section titled “Parameters”document
Section titled “document”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendImage()
Section titled “sendImage()”sendImage(
to,image,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:116
Sends an image message from an uploaded media id or a public link.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendInteractiveButtons()
Section titled “sendInteractiveButtons()”sendInteractiveButtons(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:218
Sends an interactive message with up to three reply buttons.
Throws WhatsAppValidationError when more than three buttons are given.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendInteractiveCtaUrl()
Section titled “sendInteractiveCtaUrl()”sendInteractiveCtaUrl(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:283
Sends an interactive call-to-action URL message, rendering a tappable button that opens the given URL.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendInteractiveFlow()
Section titled “sendInteractiveFlow()”sendInteractiveFlow(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:309
Sends an interactive flow message that opens a WhatsApp Flow.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendInteractiveList()
Section titled “sendInteractiveList()”sendInteractiveList(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:246
Sends an interactive list message with grouped selectable rows.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendLocation()
Section titled “sendLocation()”sendLocation(
to,location,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:166
Sends a location message.
Parameters
Section titled “Parameters”location
Section titled “location”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendLocationRequest()
Section titled “sendLocationRequest()”sendLocationRequest(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:347
Sends an interactive location-request message prompting the user to share.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendProduct()
Section titled “sendProduct()”sendProduct(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:367
Sends a single-product interactive message from a catalog.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendProductList()
Section titled “sendProductList()”sendProductList(
to,payload,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:398
Sends a multi-product interactive message from a catalog.
Parameters
Section titled “Parameters”payload
Section titled “payload”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendRaw()
Section titled “sendRaw()”sendRaw<
TResponse>(body,options?):Promise<TResponse>
Defined in: src/resources/messages.ts:558
Escape hatch: POSTs an arbitrary message body to {phoneNumberId}/messages.
Use it for message shapes or fields Meta has released that the typed
senders do not cover yet. messaging_product: 'whatsapp' is added when the
body does not set it. The body is sent as given: there is no client-side
validation. Retries, timeouts and error mapping are the same as for the
other senders. The result type is whatever you declare in TResponse.
Type Parameters
Section titled “Type Parameters”TResponse
Section titled “TResponse”TResponse = SendMessageResponse
Parameters
Section titled “Parameters”Record<string, unknown>
options?
Section titled “options?”Returns
Section titled “Returns”Promise<TResponse>
Example
Section titled “Example”await client.messages.sendRaw({ recipient: 'US.13491208655302741918', type: 'text', text: { body: 'Hello' },});sendReaction()
Section titled “sendReaction()”sendReaction(
to,reaction,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:489
Reacts to a previously received message with an emoji.
Passing an empty emoji removes a previously applied reaction.
Parameters
Section titled “Parameters”reaction
Section titled “reaction”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendSticker()
Section titled “sendSticker()”sendSticker(
to,sticker,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:156
Sends a sticker message from an uploaded media id or a public link.
Parameters
Section titled “Parameters”sticker
Section titled “sticker”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendTemplate()
Section titled “sendTemplate()”sendTemplate(
to,template,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:195
Sends a pre-approved message template.
Parameters
Section titled “Parameters”template
Section titled “template”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendText()
Section titled “sendText()”sendText(
to,text,opts?,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:96
Sends a text message, optionally enabling link previews.
Parameters
Section titled “Parameters”string
options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
sendTypingIndicator()
Section titled “sendTypingIndicator()”sendTypingIndicator(
messageId,phoneNumberId?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:528
Marks a received message as read and shows a typing indicator to the user.
The indicator is dismissed when you send a message or after about 25
seconds. messageId is the WAMID of the inbound message being replied to.
Only the text indicator type is currently supported.
Parameters
Section titled “Parameters”messageId
Section titled “messageId”string
phoneNumberId?
Section titled “phoneNumberId?”string
Returns
Section titled “Returns”Promise<SendMessageResponse>
sendVideo()
Section titled “sendVideo()”sendVideo(
to,video,options?):Promise<SendMessageResponse>
Defined in: src/resources/messages.ts:126
Sends a video message from an uploaded media id or a public link.
Parameters
Section titled “Parameters”options?
Section titled “options?”Returns
Section titled “Returns”Promise<SendMessageResponse>
Independent open-source project. Not affiliated with, endorsed by or sponsored by Meta or WhatsApp. Released under the MIT licence. Source on GitHub.