Six calls send a message inside an open conversation. They share a few rules; after those, each call has its fields and an example. To start or reopen a conversation, send a template.
Rules for every send
- The number is written in international format with the plus sign,
+447700900123. - 24 hours. Free-form messages arrive only within 24 hours of the last message from that person. The API does not check this for you: WhatsApp refuses the message, at once or later by webhook.
referenceis your own id for the send, for example an order number. Webhooks and the status carry it back.- The answer comes when WhatsApp has accepted or refused the message. A number sends about 15 messages a second, shared with campaigns and the inbox, so a call can wait up to 30 seconds for its turn. Let your client wait at least 65 seconds.
- After a timeout the message may be out. Wait for the
message.sentwebhook with yourreferencebefore you send it again.
| Field | What it is |
|---|---|
data.message_idstring | Our uuid. Use it with GET /messages/{uuid}. |
data.whatsapp_message_idstring | WhatsApp’s id. Webhooks carry this one as data.message_id. |
data.statusstring | queued, processing, sent, delivered, read, failed |
Text
| Field | What it is |
|---|---|
tostring, required | The recipient in international format, with the plus sign.10 to 20 characters |
messagestring, required | The text.At most 4096 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"message": "Your parcel is ready to collect.",
"reference": "order-1042"
}Media
A document, an image, a video or an audio file. Give a public link that WhatsApp can fetch, or the media_id of an upload. A caption is not possible on audio, and a file name only on documents.
| Field | What it is |
|---|---|
tostring, required | The recipient in international format, with the plus sign.10 to 20 characters |
typestring, required | What the file is.document, image, video, audio |
media_idstring | Media id from POST /media/upload. |
linkstring | Public address that WhatsApp can fetch. |
captionstring | Text under the file. Not for audio.At most 1024 characters |
filenamestring | Name shown to the customer. Documents only.At most 240 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"type": "document",
"link": "https://example.com/invoice-1042.pdf",
"filename": "Invoice 1042.pdf",
"caption": "Your invoice",
"reference": "invoice-1042"
}| Type | Files | At most |
|---|---|---|
document | pdf, doc, docx, xls, xlsx, ppt, pptx, txt | 100 MB |
image | jpg, jpeg, png, webp | 5 MB |
video | mp4, 3gp | 16 MB |
audio | aac, amr, mp3, ogg, m4a | 16 MB |
Upload a file
POST /media/upload takes the file as multipart/form-data and answers with a media_id that you can send for 30 days. Use it for files that are not public, or that you send often.
| Field | What it is |
|---|---|
filestring, required | The file. |
media_typestring | Found from the file when left out.document, image, video, audio |
filenamestring | Accepted, not used.At most 255 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
import { openAsBlob } from 'node:fs'
import { WizMessage } from './wizmessage.mjs'
const api = new WizMessage({
apiKey: process.env.WIZMESSAGE_API_KEY,
apiSecret: process.env.WIZMESSAGE_API_SECRET,
})
const file = await openAsBlob('price-list.pdf', { type: 'application/pdf' })
const { media_id } = await api.uploadMedia(file, 'price-list.pdf')
const sent = await api.sendMedia({
to: '+447700900123',
type: 'document',
media_id,
filename: 'Price list.pdf',
caption: 'Our prices for December',
})
console.log(sent.whatsapp_message_id, sent.status)import os
from wizmessage import WizMessage
api = WizMessage(os.environ["WIZMESSAGE_API_KEY"], os.environ["WIZMESSAGE_API_SECRET"])
upload = api.upload_media("price-list.pdf")
sent = api.send_media(
to="+447700900123",
type="document",
media_id=upload["media_id"],
filename="Price list.pdf",
caption="Our prices for December",
)
print(sent["whatsapp_message_id"], sent["status"])<?php
require __DIR__ . '/WizMessage.php';
$api = new WizMessage(getenv('WIZMESSAGE_API_KEY'), getenv('WIZMESSAGE_API_SECRET'));
$upload = $api->uploadMedia('price-list.pdf', 'application/pdf');
$sent = $api->sendMedia([
'to' => '+447700900123',
'type' => 'document',
'media_id' => $upload['media_id'],
'filename' => 'Price list.pdf',
'caption' => 'Our prices for December',
]);
echo $sent['whatsapp_message_id'], ' ', $sent['status'], "\n";The client is on the authentication page.
Reply buttons
Up to three buttons under a text. What the customer taps arrives as a message by webhook; today it carries the label of the button, not its id.
| Field | What it is |
|---|---|
tostring, required | The recipient in international format, with the plus sign.10 to 20 characters |
headerobject | |
header.typestring, required | text, image, video, document |
header.textstring | Header text, for type text.At most 60 characters |
header.imageobject | An image: either id from an upload or a public link. |
header.image.idstring | Media id from POST /media/upload. |
header.image.linkstring | Public https address of the file. |
header.videoobject | A video: either id from an upload or a public link. |
header.video.idstring | Media id from POST /media/upload. |
header.video.linkstring | Public https address of the file. |
header.documentobject | A document: either id from an upload or a public link. |
header.document.idstring | Media id from POST /media/upload. |
header.document.linkstring | Public https address of the file. |
header.document.filenamestring | Name shown to the recipient.At most 240 characters |
bodystring, required | The text.At most 1024 characters |
footerstring | Small line below the text.At most 60 characters |
buttonsarray, required | At most 3 entries |
buttons[].idstring, required | Your own id of the button.At most 256 characters |
buttons[].titlestring, required | Label.At most 20 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"body": "Shall we confirm your visit?",
"buttons": [
{
"id": "yes",
"title": "Yes"
},
{
"id": "no",
"title": "No"
}
],
"reference": "visit-31"
}List
A button that opens a list, for more than three choices. The choice arrives the same way.
| Field | What it is |
|---|---|
tostring, required | The recipient in international format, with the plus sign.10 to 20 characters |
headerstring | Short line above the text.At most 60 characters |
bodystring, required | The text.At most 1024 characters |
footerstring | Small line below the text.At most 60 characters |
buttonstring, required | Label of the button that opens the list.At most 20 characters |
sectionsarray, required | At most 10 entries |
sections[].titlestring | Heading of the section.At most 24 characters |
sections[].rowsarray, required | At most 10 entries |
sections[].rows[].idstring, required | Your own id of the row.At most 200 characters |
sections[].rows[].titlestring, required | What the customer sees.At most 24 characters |
sections[].rows[].descriptionstring | Second line.At most 72 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"body": "When shall we deliver?",
"button": "Choose a time",
"sections": [
{
"title": "Tomorrow",
"rows": [
{
"id": "slot-am",
"title": "9:00 to 12:00"
},
{
"id": "slot-pm",
"title": "13:00 to 17:00",
"description": "Ring the bell"
}
]
}
],
"reference": "delivery-77"
}Contact cards
| Field | What it is |
|---|---|
tostring, required | The recipient in international format. Here the plus sign may be left out.10 to 20 characters |
contactsarray, required | At most 10 entries |
contacts[].nameobject, required | |
contacts[].name.formatted_namestring, required | Name on the card.At most 255 characters |
contacts[].name.first_namestring | First name.At most 255 characters |
contacts[].name.last_namestring | Last name.At most 255 characters |
contacts[].name.middle_namestring | Middle name.At most 255 characters |
contacts[].name.prefixstring | For example Dr.At most 255 characters |
contacts[].name.suffixstring | For example Jr.At most 255 characters |
contacts[].phonesarray | At most 10 entries |
contacts[].phones[].phonestring | Number on the card.At most 50 characters |
contacts[].phones[].typestring | A label of your choice.At most 50 characters |
contacts[].phones[].wa_idstring | The number in digits. With it, the card has a button to write to that person.At most 50 characters |
contacts[].emailsarray | At most 10 entries |
contacts[].emails[].emailstring | E-mail address.At most 255 characters |
contacts[].emails[].typestring | A label of your choice.At most 50 characters |
contacts[].addressesarray | At most 10 entries |
contacts[].addresses[].streetstring | Street.At most 500 characters |
contacts[].addresses[].citystring | Town.At most 255 characters |
contacts[].addresses[].statestring | State.At most 255 characters |
contacts[].addresses[].zipstring | Postcode.At most 50 characters |
contacts[].addresses[].countrystring | Country.At most 255 characters |
contacts[].addresses[].country_codestring | Two letters.At most 10 characters |
contacts[].addresses[].typestring | A label of your choice.At most 50 characters |
contacts[].urlsarray | At most 10 entries |
contacts[].urls[].urlstring | Address.At most 2048 characters |
contacts[].urls[].typestring | A label of your choice.At most 50 characters |
contacts[].orgobject | |
contacts[].org.companystring | Company.At most 255 characters |
contacts[].org.departmentstring | Department.At most 255 characters |
contacts[].org.titlestring | Job title.At most 255 characters |
contacts[].birthdaystring | Year, month and day, for example 1990-01-31.At most 10 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"contacts": [
{
"name": {
"formatted_name": "Riya Example",
"first_name": "Riya"
},
"phones": [
{
"phone": "+447700900456",
"type": "WORK",
"wa_id": "447700900456"
}
],
"emails": [
{
"email": "[email protected]",
"type": "WORK"
}
],
"org": {
"company": "Example Shop",
"title": "Support"
}
}
],
"reference": "ticket-88214"
}Reaction
message_id is the WhatsApp id of the message, the one that starts with wamid., not our uuid. Another emoji replaces the first one. Taking a reaction back is not possible at the moment.
| Field | What it is |
|---|---|
tostring, required | The recipient in international format, with the plus sign.10 to 20 characters |
message_idstring, required | The WhatsApp id (whatsapp_message_id) of the message, not our uuid.At most 255 characters |
emojistring, required | One emoji.At most 16 characters |
referencestring | Your own id for this send. It comes back in webhooks and in the status.At most 100 characters |
{
"to": "+447700900123",
"message_id": "wamid.EXAMPLE-INBOUND-1",
"emoji": "👍",
"reference": "order-1042"
}Look up a message
GET /messages/{uuid} with the message_id of the answer tells you how far a message got. It finds only messages that the same key sent. Webhooks tell you the same without asking, and do not use up your limit.
| Field | What it is |
|---|---|
data.message_idstring | Our uuid. |
data.statusstring | queued, processing, sent, delivered, read, failed |
data.recipientstring | The number. |
data.typestring | What was sent. |
data.referencestring or null | Your own id. |
data.template_namestring or null | The template, if one was sent. |
data.whatsapp_message_idstring or null | WhatsApp’s id. |
data.sent_atstring or null | |
data.delivered_atstring or null | |
data.read_atstring or null | |
data.errorobject or null | |
data.error.codestring | Error code. |
data.error.messagestring | What happened. |
data.created_atstring | When the call arrived. |