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.
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
image, video, file, voice) takes either url or
base64, not both. Set voice.ptt to true to send a voice note.
Send a template
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
isForwarded: true to mark a message as forwarded.
React, mark as read, and show typing
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 Polymorfaid. 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 asmessage.received webhooks. Verify the signature,
then narrow the event:
Download media
Stream a media file by its Polymorfa media ID: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.