Help Center WhatsApp via bat/messagelist

WhatsApp via bat/messagelist

WhatsApp Business messages are sent with the same request as SMS and Viber: POST /bat/messagelist with "type": "whatsapp". The message content goes into the whatsAppMessage object.

Ready-made requests for every example on this page are in the Postman collection, see the “Postman collection” section below.

Two kinds of messages

KindwhatsAppMessage.typeWhen it can be sent
Session messages: text, media, location, contact, interactivetext, media, location, contact, interactiveOnly within the 24-hour session window after the customer’s last incoming message.
TemplatetemplateAt any time. The template must be approved in your WhatsApp Business Account (WABA).

Without a session window, send an approved template. The rule also applies when WhatsApp is a step of a fallback chain.

Common fields

{
  "callbackUrl": "https://example.com/smsbat/status",
  "messages": [
    {
      "from": "WABA_PHONE",
      "to": "RECIPIENT_PHONE",
      "type": "whatsapp",
      "ttl": 60,
      "whatsAppMessage": { "type": "text", "text": "Your order is ready." }
    }
  ]
}
FieldDescription
callbackUrlAddress for delivery callbacks. Optional.
fromThe WhatsApp Business number the message is sent from.
toRecipient number.
typewhatsapp.
ttlMessage lifetime in seconds. The examples use 60; set it for your scenario.
whatsAppMessageMessage content, see the sections below.

Authentication: the X-Authorization-Key header with the organization key, as for all SMSBAT API requests.

Session messages

Every example in this section needs the 24-hour session window.

Text

"whatsAppMessage": {
  "type": "text",
  "text": "Your order is ready."
}

Image with caption

"whatsAppMessage": {
  "type": "media",
  "media": {
    "type": "image",
    "url": "https://example.com/image.png",
    "caption": "Your order is ready."
  }
}

media.url is a public HTTPS address of the image. caption is optional.

Video with caption

"whatsAppMessage": {
  "type": "media",
  "media": {
    "type": "video",
    "url": "https://example.com/video.mp4",
    "caption": "Your order is ready."
  }
}

Audio

"whatsAppMessage": {
  "type": "media",
  "media": {
    "type": "audio",
    "url": "https://example.com/audio.mp3"
  }
}

Document

"whatsAppMessage": {
  "type": "media",
  "media": {
    "type": "document",
    "url": "https://example.com/invoice.pdf",
    "filename": "invoice.pdf",
    "caption": "Your invoice"
  }
}

filename sets the file name the recipient sees. caption is optional.

media fields:

FieldDescription
typeimage, video, audio or document.
urlPublic HTTPS address of the file.
captionCaption. Optional; the examples use it for image, video and document.
filenameFile name for a document.

Location

"whatsAppMessage": {
  "type": "location",
  "location": {
    "latitude": 48.1486,
    "longitude": 17.1077,
    "name": "Pickup point",
    "address": "Bratislava"
  }
}

Add the place name and address when needed.

Contact

"whatsAppMessage": {
  "type": "contact",
  "contact": {
    "name": {
      "formatted_name": "Support Team",
      "first_name": "Support"
    },
    "phones": [
      { "phone": "+421900000000", "type": "WORK" }
    ]
  }
}

Besides the full display name (formatted_name), fill in at least one more name field, for example first_name.

Reply buttons

"whatsAppMessage": {
  "type": "interactive",
  "interactive": {
    "type": "button",
    "body": { "text": "Confirm your order" },
    "action": {
      "buttons": [
        { "type": "reply", "reply": { "id": "confirm", "title": "Confirm" } },
        { "type": "reply", "reply": { "id": "cancel", "title": "Cancel" } }
      ]
    }
  }
}

Use reply.id to recognise which button the recipient pressed. reply.title is the button label.

List

"whatsAppMessage": {
  "type": "interactive",
  "interactive": {
    "type": "list",
    "body": { "text": "Choose a pickup point" },
    "action": {
      "button": "View options",
      "sections": [
        {
          "title": "Pickup points",
          "rows": [
            { "id": "center", "title": "City centre" },
            { "id": "station", "title": "Main station" }
          ]
        }
      ]
    }
  }
}

action.button is the label of the button that opens the list. sections[].rows[] are the options, each with an id and a title.

Templates

Templates can be sent at any time, without a session window. The template must be approved in the WABA you send from.

How to fill in a template

FieldDescription
template.idExact name of the approved template.
template.languageLanguage code of that template, for example uk or en_US.
template.body.parametersValues of the text variables, in template order: [{ "text": "..." }]. Leave out body if there are no variables.
template.headerOnly for a template with a variable header. Not needed for a static header.
template.buttonsOnly for a dynamic URL button and quick-reply buttons.

A static button URL and the phone number of a call button are set in the template itself and are not passed when sending. The number of parameters and buttons must match your approved template.

Text template

"whatsAppMessage": {
  "type": "template",
  "template": {
    "id": "YOUR_TEMPLATE_NAME",
    "language": "uk",
    "body": {
      "parameters": [ { "text": "Alex" } ]
    }
  }
}

Dynamic URL button

"whatsAppMessage": {
  "type": "template",
  "template": {
    "id": "YOUR_TEMPLATE_NAME",
    "language": "uk",
    "body": {
      "parameters": [
        { "text": "Oleh" },
        { "text": "1 January 2024" },
        { "text": "+1 555-745-2867" }
      ]
    },
    "buttons": [
      { "type": "url", "index": 0, "url_parameter": "ORDER-123" }
    ]
  }
}

index is the button’s position in the template, starting at 0. Pass only the variable part of the address in url_parameter. For example, for the button URL https://example.com/orders/{{1}} the value ORDER-123 produces https://example.com/orders/ORDER-123. If the button URL is static, do not pass buttons.

Quick-reply buttons

"buttons": [
  { "type": "quick_reply", "index": 0, "quick_reply_payload": "CONFIRM" },
  { "type": "quick_reply", "index": 1, "quick_reply_payload": "CANCEL" }
]

quick_reply_payload helps you tell which button the recipient pressed. The button indexes must match the template.

Header: text

"header": { "type": "text", "text": "Order 123" }

Pass the value of the header variable in header.text.

Header: image, video, document

"header": { "type": "image", "image": { "url": "https://example.com/image.png" } }
"header": { "type": "video", "video": { "url": "https://example.com/video.mp4" } }
"header": {
  "type": "document",
  "document": { "url": "https://example.com/file.pdf", "filename": "sample.pdf" }
}

The URL must be a public HTTPS address. For a document, filename sets the attachment name.

Delivery statuses

WhatsApp message statuses arrive at callbackUrl in the delivery callback format: delivered, undeliverable or permanenterror.

Postman collection

Download the “OmniSMSBat · BAT /messagelist” collection: ready-made requests for WhatsApp (session messages and 7 kinds of templates), Viber Business, SMS and fallbacks.

  1. Import the file into Postman.
  2. Fill in the collection variables: orgKey (organization key), toPhone (recipient number), wabaPhone (WhatsApp sender number), alphaName (alpha name for Viber Business and SMS) and, if needed, callbackUrl.
  3. In the template requests replace PLACEHOLDER_... in template.id with the name of your approved template and check template.language.

Requests go to the production server https://restapi.smsbat.com and may be charged. There is no separate test environment.