Skip to content

Send WhatsApp messages

Send text, documents, images, video, audio, reply buttons, lists, contact cards and reactions on WhatsApp with the WizMessage API, and follow their status.

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.
  • reference is 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.sent webhook with your reference before you send it again.
FieldWhat it is
data.message_idstringOur uuid. Use it with GET /messages/{uuid}.
data.whatsapp_message_idstringWhatsApp’s id. Webhooks carry this one as data.message_id.
data.statusstringqueued, processing, sent, delivered, read, failed

Text

FieldWhat it is
tostring, requiredThe recipient in international format, with the plus sign.10 to 20 characters
messagestring, requiredThe text.At most 4096 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/text
{
  "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.

FieldWhat it is
tostring, requiredThe recipient in international format, with the plus sign.10 to 20 characters
typestring, requiredWhat the file is.document, image, video, audio
media_idstringMedia id from POST /media/upload.
linkstringPublic address that WhatsApp can fetch.
captionstringText under the file. Not for audio.At most 1024 characters
filenamestringName shown to the customer. Documents only.At most 240 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/media
{
  "to": "+447700900123",
  "type": "document",
  "link": "https://example.com/invoice-1042.pdf",
  "filename": "Invoice 1042.pdf",
  "caption": "Your invoice",
  "reference": "invoice-1042"
}
TypeFilesAt most
documentpdf, doc, docx, xls, xlsx, ppt, pptx, txt100 MB
imagejpg, jpeg, png, webp5 MB
videomp4, 3gp16 MB
audioaac, amr, mp3, ogg, m4a16 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.

FieldWhat it is
filestring, requiredThe file.
media_typestringFound from the file when left out.document, image, video, audio
filenamestringAccepted, not used.At most 255 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
media.mjs
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)

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.

FieldWhat it is
tostring, requiredThe recipient in international format, with the plus sign.10 to 20 characters
headerobject
header.typestring, requiredtext, image, video, document
header.textstringHeader text, for type text.At most 60 characters
header.imageobjectAn image: either id from an upload or a public link.
header.image.idstringMedia id from POST /media/upload.
header.image.linkstringPublic https address of the file.
header.videoobjectA video: either id from an upload or a public link.
header.video.idstringMedia id from POST /media/upload.
header.video.linkstringPublic https address of the file.
header.documentobjectA document: either id from an upload or a public link.
header.document.idstringMedia id from POST /media/upload.
header.document.linkstringPublic https address of the file.
header.document.filenamestringName shown to the recipient.At most 240 characters
bodystring, requiredThe text.At most 1024 characters
footerstringSmall line below the text.At most 60 characters
buttonsarray, requiredAt most 3 entries
buttons[].idstring, requiredYour own id of the button.At most 256 characters
buttons[].titlestring, requiredLabel.At most 20 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/interactive/button
{
  "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.

FieldWhat it is
tostring, requiredThe recipient in international format, with the plus sign.10 to 20 characters
headerstringShort line above the text.At most 60 characters
bodystring, requiredThe text.At most 1024 characters
footerstringSmall line below the text.At most 60 characters
buttonstring, requiredLabel of the button that opens the list.At most 20 characters
sectionsarray, requiredAt most 10 entries
sections[].titlestringHeading of the section.At most 24 characters
sections[].rowsarray, requiredAt most 10 entries
sections[].rows[].idstring, requiredYour own id of the row.At most 200 characters
sections[].rows[].titlestring, requiredWhat the customer sees.At most 24 characters
sections[].rows[].descriptionstringSecond line.At most 72 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/interactive/list
{
  "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

FieldWhat it is
tostring, requiredThe recipient in international format. Here the plus sign may be left out.10 to 20 characters
contactsarray, requiredAt most 10 entries
contacts[].nameobject, required
contacts[].name.formatted_namestring, requiredName on the card.At most 255 characters
contacts[].name.first_namestringFirst name.At most 255 characters
contacts[].name.last_namestringLast name.At most 255 characters
contacts[].name.middle_namestringMiddle name.At most 255 characters
contacts[].name.prefixstringFor example Dr.At most 255 characters
contacts[].name.suffixstringFor example Jr.At most 255 characters
contacts[].phonesarrayAt most 10 entries
contacts[].phones[].phonestringNumber on the card.At most 50 characters
contacts[].phones[].typestringA label of your choice.At most 50 characters
contacts[].phones[].wa_idstringThe number in digits. With it, the card has a button to write to that person.At most 50 characters
contacts[].emailsarrayAt most 10 entries
contacts[].emails[].emailstringE-mail address.At most 255 characters
contacts[].emails[].typestringA label of your choice.At most 50 characters
contacts[].addressesarrayAt most 10 entries
contacts[].addresses[].streetstringStreet.At most 500 characters
contacts[].addresses[].citystringTown.At most 255 characters
contacts[].addresses[].statestringState.At most 255 characters
contacts[].addresses[].zipstringPostcode.At most 50 characters
contacts[].addresses[].countrystringCountry.At most 255 characters
contacts[].addresses[].country_codestringTwo letters.At most 10 characters
contacts[].addresses[].typestringA label of your choice.At most 50 characters
contacts[].urlsarrayAt most 10 entries
contacts[].urls[].urlstringAddress.At most 2048 characters
contacts[].urls[].typestringA label of your choice.At most 50 characters
contacts[].orgobject
contacts[].org.companystringCompany.At most 255 characters
contacts[].org.departmentstringDepartment.At most 255 characters
contacts[].org.titlestringJob title.At most 255 characters
contacts[].birthdaystringYear, month and day, for example 1990-01-31.At most 10 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/contacts
{
  "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.

FieldWhat it is
tostring, requiredThe recipient in international format, with the plus sign.10 to 20 characters
message_idstring, requiredThe WhatsApp id (whatsapp_message_id) of the message, not our uuid.At most 255 characters
emojistring, requiredOne emoji.At most 16 characters
referencestringYour own id for this send. It comes back in webhooks and in the status.At most 100 characters
POST /messages/reaction
{
  "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.

FieldWhat it is
data.message_idstringOur uuid.
data.statusstringqueued, processing, sent, delivered, read, failed
data.recipientstringThe number.
data.typestringWhat was sent.
data.referencestring or nullYour own id.
data.template_namestring or nullThe template, if one was sent.
data.whatsapp_message_idstring or nullWhatsApp’s id.
data.sent_atstring or null
data.delivered_atstring or null
data.read_atstring or null
data.errorobject or null
data.error.codestringError code.
data.error.messagestringWhat happened.
data.created_atstringWhen the call arrived.