Send WhatsApp messages: text, media, location, contacts, reactions, templates, and interactive messages (reply buttons, lists, CTA URL, location request, Flows), plus read receipts with a typing indicator.
Every send request takes an optional reply_to — the wamid of a
message to quote — sent as Meta's context: {message_id}. Each
send-* function has a pure build-*-body counterpart that returns
the exact JSON payload (unset optionals omitted), exposed for testing.
Sends return {messaging_product, contacts, messages: [{id}]} on
success, or an Err carrying ::whatsapp::api/HttpError.
Functions
build-audio-body
fn (request: SendAudioRequest): Map
The JSON payload send-audio posts. Fails when neither audio_id nor
audio_url is set.
Example
::messages ::whatsapp::messages
req ::messages/SendAudioRequest({to: "15551234567", audio_id: "123"})
::messages/build-audio-body(req).audio // {id: "123"}
build-buttons-body
fn (request: SendButtonsRequest): Map
The JSON payload send-buttons posts.
Example
::messages ::whatsapp::messages
button {type: "reply", reply: {id: "yes", title: "Yes"}}
req ::messages/SendButtonsRequest({to: "15551234567", body_text: "Ready?", buttons: [button]})
::messages/build-buttons-body(req).interactive.type // "button"
build-contacts-body
fn (request: SendContactsRequest): Map
The JSON payload send-contacts posts. contacts is a top-level array,
so it does not use the build-message envelope.
Example
::messages ::whatsapp::messages
contact {name: {formatted_name: "Jane Doe"}}
req ::messages/SendContactsRequest({to: "15551234567", contacts: [contact]})
::messages/build-contacts-body(req).contacts // [{name: {formatted_name: "Jane Doe"}}]
build-cta-url-body
fn (request: SendCtaUrlRequest): Map
The JSON payload send-cta-url posts.
Example
::messages ::whatsapp::messages
req ::messages/SendCtaUrlRequest({to: "15551234567", body_text: "Your invoice.", display_text: "Open", url: "https://example.com/i/1"})
::messages/build-cta-url-body(req).interactive.action.name // "cta_url"
build-document-body
fn (request: SendDocumentRequest): Map
The JSON payload send-document posts. Fails when neither document_id
nor document_url is set.
Example
::messages ::whatsapp::messages
req ::messages/SendDocumentRequest({to: "15551234567", document_id: "123", filename: "a.pdf"})
::messages/build-document-body(req).document // {id: "123", filename: "a.pdf"}
build-flow-body
fn (request: SendFlowRequest): Map
The JSON payload send-flow posts. Fails when neither flow_id nor
flow_name is set. screen and data go in flow_action_payload.
Example
::messages ::whatsapp::messages
req ::messages/SendFlowRequest({to: "15551234567", body_text: "Book now.", flow_cta: "Book", flow_id: "123", screen: "START"})
::messages/build-flow-body(req).interactive.action.parameters.flow_action_payload // {screen: "START"}
build-image-body
fn (request: SendImageRequest): Map
The JSON payload send-image posts. Fails when neither image_id nor
image_url is set.
Example
::messages ::whatsapp::messages
req ::messages/SendImageRequest({to: "15551234567", image_id: "123", caption: "Look"})
::messages/build-image-body(req).image // {id: "123", caption: "Look"}
build-interactive
fn (to: Str, kind: Str, body-text: Str, action: Map, header: Map?, footer-text: Str?, reply-to: Str?): Map
An interactive message: interactive: {type, body: {text}, action, header?, footer?}. Exposed for testing.
Example
::messages ::whatsapp::messages
body ::messages/build-interactive("15551234567", "button", "Pick one", {buttons: []}, null, "Thanks", null)
body.interactive.footer // {text: "Thanks"}
build-list-body
fn (request: SendListRequest): Map
The JSON payload send-list posts. header_text becomes a text header.
Example
::messages ::whatsapp::messages
section {title: "Plans", rows: [{id: "1", title: "Basic"}]}
req ::messages/SendListRequest({to: "15551234567", body_text: "Choose", button_text: "View", sections: [section], header_text: "Menu"})
::messages/build-list-body(req).interactive.header // {type: "text", text: "Menu"}
build-location-body
fn (request: SendLocationRequest): Map
The JSON payload send-location posts.
Example
::messages ::whatsapp::messages
req ::messages/SendLocationRequest({to: "15551234567", latitude: 37.78, longitude: -122.41, name: "Office"})
::messages/build-location-body(req).location // {latitude: 37.78, longitude: -122.41, name: "Office"}
build-location-request-body
fn (request: SendLocationRequestRequest): Map
The JSON payload send-location-request posts.
Example
::messages ::whatsapp::messages
req ::messages/SendLocationRequestRequest({to: "15551234567", body_text: "Where to?"})
::messages/build-location-request-body(req).interactive.action // {name: "send_location"}
build-mark-read-body
fn (request: MarkReadRequest): Map
The JSON payload mark-read posts. typing_indicator: true adds the
typing indicator.
Example
::messages ::whatsapp::messages
req ::messages/MarkReadRequest({message_id: "wamid.1", typing_indicator: true})
::messages/build-mark-read-body(req).typing_indicator // {type: "text"}
build-message
fn (to: Str, message-type: Str, content: Map, reply-to: Str?): Map
The common message envelope: messaging_product, recipient_type,
to, type, the type-specific object under the key named by type,
and context.message_id when reply-to is set. Exposed for testing.
Example
::messages ::whatsapp::messages
body ::messages/build-message("15551234567", "text", {body: "Hi"}, "wamid.1")
body.text // {body: "Hi"}
body.context // {message_id: "wamid.1"}
build-reaction-body
fn (request: SendReactionRequest): Map
The JSON payload send-reaction posts.
Example
::messages ::whatsapp::messages
req ::messages/SendReactionRequest({to: "15551234567", message_id: "wamid.1", emoji: "ok"})
::messages/build-reaction-body(req).reaction // {message_id: "wamid.1", emoji: "ok"}
build-sticker-body
fn (request: SendStickerRequest): Map
The JSON payload send-sticker posts. Fails when neither sticker_id
nor sticker_url is set.
Example
::messages ::whatsapp::messages
req ::messages/SendStickerRequest({to: "15551234567", sticker_id: "123"})
::messages/build-sticker-body(req).sticker // {id: "123"}
build-template-body
fn (request: SendTemplateRequest): Map
The JSON payload send-template posts.
Example
::messages ::whatsapp::messages
req ::messages/SendTemplateRequest({to: "15551234567", template_name: "hello_world", language_code: "en_US"})
::messages/build-template-body(req).template // {name: "hello_world", language: {code: "en_US"}}
build-text-body
fn (request: SendTextRequest): Map
The JSON payload send-text posts.
Example
::messages ::whatsapp::messages
req ::messages/SendTextRequest({to: "15551234567", text: "Hi", preview_url: true})
::messages/build-text-body(req).text // {body: "Hi", preview_url: true}
build-video-body
fn (request: SendVideoRequest): Map
The JSON payload send-video posts. Fails when neither video_id nor
video_url is set.
Example
::messages ::whatsapp::messages
req ::messages/SendVideoRequest({to: "15551234567", video_url: "https://example.com/v.mp4"})
::messages/build-video-body(req).video // {link: "https://example.com/v.mp4"}
mark-read
fn (request: MarkReadRequest): Map
fn (request: MarkReadRequest, opts: Map): Map
Mark a received message as read (blue checkmarks for the sender; earlier messages in the thread are marked too). Set typing_indicator: true to also show the "typing..." indicator, which stays until you reply or 25 seconds pass — only use it when you are about to respond. Returns {success: true}.
Example
::messages ::whatsapp::messages
::messages/mark-read(::messages/MarkReadRequest({
phone_number_id: "109876543210",
message_id: "wamid.HBg...",
typing_indicator: true
}))
media-object
fn (kind: Str, id: Str?, link: Str?): Map
A media reference: {id} for uploaded media (preferred when both are
given) or {link} for a public HTTPS URL. Fails when neither is set.
Exposed for testing.
Example
::messages ::whatsapp::messages
::messages/media-object("image", "123", "https://example.com/a.png") // {id: "123"}
::messages/media-object("image", null, "https://example.com/a.png") // {link: "https://example.com/a.png"}
send-audio
fn (request: SendAudioRequest): Map
fn (request: SendAudioRequest, opts: Map): Map
Send an audio file. Provide either audio_id or audio_url. Supports
AAC, AMR, MP3, MP4 audio, OGG (OPUS codec only, which plays as a voice
note); max 16 MB.
Example
::messages ::whatsapp::messages
sent ::messages/send-audio(::messages/SendAudioRequest({
phone_number_id: "109876543210", to: "15551234567",
audio_id: "1234567890"
}))
first(sent.messages).id
send-buttons
fn (request: SendButtonsRequest): Map
fn (request: SendButtonsRequest, opts: Map): Map
Send an interactive message with up to 3 reply buttons. Each button is {type: "reply", reply: {id: "btn_1", title: "Click Me"}} (title max 20 characters). header is a header object, e.g. {type: "text", text: "..."} or {type: "image", image: {link: "..."}}.
Example
::messages ::whatsapp::messages
::messages/send-buttons(::messages/SendButtonsRequest({
phone_number_id: "109876543210",
to: "15551234567",
body_text: "How can we help?",
buttons: [
{type: "reply", reply: {id: "sales", title: "Sales"}},
{type: "reply", reply: {id: "support", title: "Support"}},
{type: "reply", reply: {id: "info", title: "More Info"}}
]
}))
send-contacts
fn (request: SendContactsRequest): Map
fn (request: SendContactsRequest, opts: Map): Map
Send one or more contact cards. Each contact is a Map with name (required: {formatted_name: "..."}) and optional phones, emails, urls, addresses, org, birthday.
Example
::messages ::whatsapp::messages
::messages/send-contacts(::messages/SendContactsRequest({
phone_number_id: "109876543210",
to: "15551234567",
contacts: [{
name: {formatted_name: "Jane Doe", first_name: "Jane", last_name: "Doe"},
phones: [{phone: "+15559876543", type: "WORK"}]
}]
}))
send-cta-url
fn (request: SendCtaUrlRequest): Map
fn (request: SendCtaUrlRequest, opts: Map): Map
Send an interactive call-to-action URL button: body text plus one button that opens url, so you can link out without showing a raw URL. display_text is the button label (max 20 characters); body_text max 1024, footer_text max 60. header is optional: {type: "text", text} or an image/video/document header such as {type: "image", image: {link: "https://..."}}.
Example
::messages ::whatsapp::messages
::messages/send-cta-url(::messages/SendCtaUrlRequest({
phone_number_id: "109876543210",
to: "15551234567",
body_text: "Your invoice is ready.",
display_text: "View invoice",
url: "https://example.com/invoices/123"
}))
send-document
fn (request: SendDocumentRequest): Map
fn (request: SendDocumentRequest, opts: Map): Map
Send a document. Provide either document_id or document_url.
filename sets the name shown to the recipient. Supports PDF, Office
formats, plain text; max 100 MB.
Example
::messages ::whatsapp::messages
sent ::messages/send-document(::messages/SendDocumentRequest({
phone_number_id: "109876543210", to: "15551234567",
document_url: "https://example.com/invoice.pdf",
filename: "invoice.pdf"
}))
first(sent.messages).id
send-flow
fn (request: SendFlowRequest): Map
fn (request: SendFlowRequest, opts: Map): Map
Send a WhatsApp Flow as an interactive message. Identify the Flow by flow_id or flow_name (one of them). flow_cta is the button label (keep it under 30 characters, no emoji). Optional: flow_token (your correlation id, echoed back on completion), mode ("published" default, or "draft" for testing), flow_action ("navigate" default, or "data_exchange"), and for navigate, the entry screen and initial data Map.
Example
::messages ::whatsapp::messages
::messages/send-flow(::messages/SendFlowRequest({
phone_number_id: "109876543210",
to: "15551234567",
body_text: "Book your appointment in a few taps.",
flow_cta: "Book now",
flow_id: "1234567890",
flow_token: "booking-42",
screen: "APPOINTMENT",
data: {service: "haircut"}
}))
send-image
fn (request: SendImageRequest): Map
fn (request: SendImageRequest, opts: Map): Map
Send an image. Provide either image_id (from ::whatsapp::media/upload-media) or image_url (public HTTPS URL). Supported: JPEG, PNG; max 5 MB.
Example
::messages ::whatsapp::messages
response ::messages/send-image(::messages/SendImageRequest({
phone_number_id: "109876543210",
to: "15551234567",
image_url: "https://example.com/photo.jpg",
caption: "Check this out!"
}))
send-list
fn (request: SendListRequest): Map
fn (request: SendListRequest, opts: Map): Map
Send an interactive list message. Users tap a button to reveal a menu of options organized in sections. Max 10 sections and 10 rows in total.
Each section: {title: "Category", rows: [{id: "1", title: "Option", description: "Details"}, ...]}.
Example
::messages ::whatsapp::messages
::messages/send-list(::messages/SendListRequest({
phone_number_id: "109876543210",
to: "15551234567",
body_text: "Choose a product:",
button_text: "View Options",
sections: [
{title: "Electronics", rows: [
{id: "phone", title: "Phone", description: "$999"},
{id: "laptop", title: "Laptop", description: "$1499"}
]},
{title: "Accessories", rows: [
{id: "case", title: "Phone Case", description: "$29"}
]}
]
}))
send-location
fn (request: SendLocationRequest): Map
fn (request: SendLocationRequest, opts: Map): Map
Send a location pin. Optionally include a name and address for the
pin label.
Example
::messages ::whatsapp::messages
sent ::messages/send-location(::messages/SendLocationRequest({
phone_number_id: "109876543210", to: "15551234567",
latitude: 37.7749,
longitude: -122.4194,
name: "Office",
address: "1 Market St, San Francisco"
}))
first(sent.messages).id
send-location-request
fn (request: SendLocationRequestRequest): Map
fn (request: SendLocationRequestRequest, opts: Map): Map
Ask the user to share their location: shows body_text with a "Send location" button. The shared location arrives as a location message on the messages webhook.
Example
::messages ::whatsapp::messages
::messages/send-location-request(::messages/SendLocationRequestRequest({
phone_number_id: "109876543210",
to: "15551234567",
body_text: "Where should we deliver your order?"
}))
send-message
fn (phone-number-id: Str?, body: Map): Map
fn (phone-number-id: Str?, body: Map, opts: Map): Map
POST /{phone-number-id}/messages with a prebuilt payload — the escape hatch for message types without a dedicated function.
Example
::messages ::whatsapp::messages
sent ::messages/send-message("109876543210", {
messaging_product: "whatsapp",
to: "15551234567",
type: "text",
text: {body: "Hello"}
})
first(sent.messages).id
send-reaction
fn (request: SendReactionRequest): Map
fn (request: SendReactionRequest, opts: Map): Map
React to a message with an emoji. Set emoji to "" (empty string) to remove a reaction. Reactions can only target messages less than 30 days old.
Example
::messages ::whatsapp::messages
::messages/send-reaction(::messages/SendReactionRequest({
phone_number_id: "109876543210",
to: "15551234567",
message_id: "wamid.HBg...",
emoji: "👍"
}))
send-sticker
fn (request: SendStickerRequest): Map
fn (request: SendStickerRequest, opts: Map): Map
Send a sticker. Provide either sticker_id or sticker_url. WebP only;
static max 100 KB, animated max 500 KB.
Example
::messages ::whatsapp::messages
sent ::messages/send-sticker(::messages/SendStickerRequest({
phone_number_id: "109876543210", to: "15551234567",
sticker_url: "https://example.com/wave.webp"
}))
first(sent.messages).id
send-template
fn (request: SendTemplateRequest): Map
fn (request: SendTemplateRequest, opts: Map): Map
Send a pre-approved message template — the only message type allowed outside the 24-hour customer service window. components supplies header, body, and button parameters.
Example
::messages ::whatsapp::messages
// Simple template with no variables
::messages/send-template(::messages/SendTemplateRequest({
phone_number_id: "109876543210",
to: "15551234567",
template_name: "hello_world",
language_code: "en_US"
}))
// Template with body variables
::messages/send-template(::messages/SendTemplateRequest({
phone_number_id: "109876543210",
to: "15551234567",
template_name: "order_confirmation",
language_code: "en_US",
components: [
{type: "body", parameters: [
{type: "text", text: "ORDER-123"},
{type: "text", text: "$49.99"}
]}
]
}))
send-text
fn (request: SendTextRequest): Map
fn (request: SendTextRequest, opts: Map): Map
Send a text message (max 4096 characters). to is the recipient's phone number in international format (e.g. "15551234567"). Set preview_url: true to render a link preview; reply_to quotes an earlier message.
Example
::messages ::whatsapp::messages
response ::messages/send-text(::messages/SendTextRequest({
phone_number_id: "109876543210",
to: "15551234567",
text: "Hello from Hot!"
}))
first(response.messages).id // => "wamid.HBg..."
send-video
fn (request: SendVideoRequest): Map
fn (request: SendVideoRequest, opts: Map): Map
Send a video. Provide either video_id or video_url. Supports MP4 and
3GPP (H.264 video, AAC audio); max 16 MB.
Example
::messages ::whatsapp::messages
sent ::messages/send-video(::messages/SendVideoRequest({
phone_number_id: "109876543210", to: "15551234567",
video_url: "https://example.com/clip.mp4",
caption: "New clip"
}))
first(sent.messages).id
Types
MarkReadRequest
MarkReadRequest type {
phone_number_id: Str?,
message_id: Str,
typing_indicator: Bool?
}
SendAudioRequest
SendAudioRequest type {
phone_number_id: Str?,
to: Str,
audio_url: Str?,
audio_id: Str?,
reply_to: Str?
}
SendButtonsRequest
SendButtonsRequest type {
phone_number_id: Str?,
to: Str,
body_text: Str,
buttons: Vec<Map>,
header: Map?,
footer_text: Str?,
reply_to: Str?
}
SendContactsRequest
SendContactsRequest type {
phone_number_id: Str?,
to: Str,
contacts: Vec<Map>,
reply_to: Str?
}
SendCtaUrlRequest
SendCtaUrlRequest type {
phone_number_id: Str?,
to: Str,
body_text: Str,
display_text: Str,
url: Str,
header: Map?,
footer_text: Str?,
reply_to: Str?
}
SendDocumentRequest
SendDocumentRequest type {
phone_number_id: Str?,
to: Str,
document_url: Str?,
document_id: Str?,
caption: Str?,
filename: Str?,
reply_to: Str?
}
SendFlowRequest
SendFlowRequest type {
phone_number_id: Str?,
to: Str,
body_text: Str,
flow_cta: Str,
flow_id: Str?,
flow_name: Str?,
flow_token: Str?,
mode: Str?,
flow_action: Str?,
screen: Str?,
data: Map?,
header: Map?,
footer_text: Str?,
reply_to: Str?
}
SendImageRequest
SendImageRequest type {
phone_number_id: Str?,
to: Str,
image_url: Str?,
image_id: Str?,
caption: Str?,
reply_to: Str?
}
SendListRequest
SendListRequest type {
phone_number_id: Str?,
to: Str,
body_text: Str,
button_text: Str,
sections: Vec<Map>,
header_text: Str?,
footer_text: Str?,
reply_to: Str?
}
SendLocationRequest
SendLocationRequest type {
phone_number_id: Str?,
to: Str,
latitude: Dec,
longitude: Dec,
name: Str?,
address: Str?,
reply_to: Str?
}
SendLocationRequestRequest
SendLocationRequestRequest type {
phone_number_id: Str?,
to: Str,
body_text: Str,
reply_to: Str?
}
SendReactionRequest
SendReactionRequest type {
phone_number_id: Str?,
to: Str,
message_id: Str,
emoji: Str
}
SendStickerRequest
SendStickerRequest type {
phone_number_id: Str?,
to: Str,
sticker_url: Str?,
sticker_id: Str?,
reply_to: Str?
}
SendTemplateRequest
SendTemplateRequest type {
phone_number_id: Str?,
to: Str,
template_name: Str,
language_code: Str,
components: Vec<Map>?,
reply_to: Str?
}
SendTextRequest
SendTextRequest type {
phone_number_id: Str?,
to: Str,
text: Str,
preview_url: Bool?,
reply_to: Str?
}
SendVideoRequest
SendVideoRequest type {
phone_number_id: Str?,
to: Str,
video_url: Str?,
video_id: Str?,
caption: Str?,
reply_to: Str?
}