Skip to content

WhatsApp API

createWhatsAppMessage

Used to send WhatsApp messages to users

POST https://api.pushwoosh.com/json/1.3/createWhatsAppMessage

Request Body

NameRequiredTypeDescription
auth*YesstringAPI access token from Pushwoosh Control Panel.
application*YesstringPushwoosh application code.
notifications*YesarrayContent settings. JSON array of message parameters. See details below.

Notification parameters

NameRequiredTypeDescription
send_date*YesstringDate and time to send the notification. Use format YYYY-MM-DD HH:mm or 'now' to send immediately.
contentRequired if content_id is not provided.stringText content of the WhatsApp message.
content_idRequired if content is not provided.stringIdentifier for a pre-approved WhatsApp template from your Meta account.
devices*YesarrayCustomer phone number (must be associated with a UserId using /registerDevice and specified in the hwid parameter, or use use_auto_registration). Only one number can be specified here.
use_auto_registrationNobooleanIf set to true, the phone number specified in the devices parameter will be automatically registered.
content_variablesNoobjectContent variables to customize the message content. Each placeholder will be replaced with corresponding dynamic values.
button_url_variablesNoobjectDynamic URL variables for buttons. Each key represents a button index, and its value is the dynamic variable to replace in the button’s URL. Note: Button indexing starts at 0, with the first button as 0, the second as 1, and so on.
header_variablesNoobjectVariables for the header in a WhatsApp template message. Specify the type (e.g., text, image, video, document) and the corresponding value. Example: "header_variables": {"image": "https://image-url.png"}
presetNostringWhatsApp Preset Code from your Control Panel.
languageNostringLanguage locale of the WhatsApp template (must match the locale in Meta WhatsApp template editor). Default: "en_US". Example: "en_GB".

Request example

{
"request": {
"application": "12XXX-67XXX", // required. Pushwoosh application code.
"auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel.
"notifications": [{
"send_date": "now", // required. YYYY-MM-DD HH:mm OR "now".
"content": "Hello! {{1}}", // required if content_id is not provided. Message text.
"content_id": "hello_world", // required if content is not provided. WhatsApp template identifier.
"devices": ["whatsapp:+1234567890"], // required. Customer WhatsApp phone number (must be associated
// with a UserId using /registerDevice and specified in
// the "hwid" parameter or use "use_auto_registration").
// Only one WhatsApp number can be specified here.
"preset": "XXXXX-XXXXX", // optional. WhatsApp Preset Code from your Control Panel.
"content_variables": { // optional. Content variables to customize the message content.
"1": "John"
},
"header_variables": { // optional. Variables for the WhatsApp message header.
"image": "https://image-url.png"
},
"language": "en_GB", // optional. Language locale for the WhatsApp template (must match the locale in Meta WhatsApp template editor). Default: "en_US".
"use_auto_registration": true // optional. Automatically register WhatsApp number specified
// in "devices" parameter.
}]
}
}

Example: Sending a Two-Factor Authentication Code via WhatsApp

{
"request": {
"application":"APP_CODE", "auth":"AUTH_TOKEN",
"notifications":[{
"send_date":"now",
"content_id":"replace_with_your_meta_two_factor_template_name",
"content_variables":{"1":"AUTH_CODE"},
"button_url_variables":{"0":"AUTH_CODE"},
"devices":["whatsapp:REPLACE_WITH_YOUR_PHONE_NO"]
}]
}
}

Response example

{
"status_code": 200,
"status_message": "OK",
"response": {
"Messages": [
"9648-0B10EXXX-0D9F2XXX"
]
}
}

Error response

{
"status_code": 210,
"status_message": "Invalid devices list. \"devices\" must be an array.",
"response": {
"Messages": []
}
}