Skip to main content
Send messages through a connected Number with messaging.messages. Messages you receive arrive as webhooks.

Send a text message

conversation picks the recipient with one of these fields:
  • phoneNumber: an E.164 phone number.
  • id: the Polymorfa conversation ID from an earlier message or webhook.
  • bsuid: a business-scoped user ID.
If you pass more than one, they must point to the same conversation. A username alone is not a destination. send creates an idempotency key for you, so its automatic retries never send twice. Pass your own idempotencyKey to stay safe across process restarts. See Retry a write safely.

Send an image or a file

Each media kind (image, video, file, voice) takes either url or base64, not both. Set voice.ptt to true to send a voice note.

Send a template

The template must be approved in that language, or the send fails with template_not_approved. On an Official API Number, a free-form message sent more than 24 hours after the customer last wrote fails with conversation_window_closed; send a template instead. See Templates.

Other message kinds

content holds exactly one message kind. Besides text, media, and templates, the SDK types cover poll, location, contact, buttons, list, product, productList, order, requestPhoneNumber, addressMessage, flow, and callPermissionRequest. Your editor lists the fields of each kind from the SendMessageRequest type.

Reply to a message

Set isForwarded: true to mark a message as forwarded.

React, mark as read, and show typing

Official API Numbers need the id of an inbound message for setTyping. They mark it read and show typing for up to 25 seconds or until you reply. They support only the typing state. Linked-device Numbers also accept recording and paused.

Edit or delete a sent message

Message IDs

Every message has a Polymorfa id. Use it for replies, reactions, edits, and deletes. Keep it as a string, even when it contains only digits. whatsapp_ids holds the WhatsApp references Polymorfa observed, under linked_devices, official_api, or both. They are not interchangeable with the Polymorfa id. The older whatsapp_id field is deprecated; read whatsapp_ids instead. See Message identifiers.

Receive messages

Incoming messages arrive as message.received webhooks. Verify the signature, then narrow the event:
See Webhooks to create the endpoint and verify requests. To read events without a public endpoint, see Events.

Download media

Stream a media file by its Polymorfa media ID:
In Node.js, write it straight to a file:
The helper writes to a temporary file and moves it into place only after the download finishes. Treat filename as a display name, not a path. When a project does not store media, inbound media webhooks carry an encrypted media descriptor instead. messaging.media.downloadFromWhatsApp(event.payload) downloads and decrypts the file from WhatsApp without calling the Polymorfa API. The descriptor contains a decryption key, so never log stored webhook bodies.

Read stored message history

Message history is a beta. It works only for Numbers with hosted message storage on, in teams enrolled in the beta. See Read message history.
chats.list lists stored conversations. chats.downloadMessageMediaStream downloads the stored copy of a message’s media and also needs media:read.