Send templated Whatsapp Messages
Template messages allow you to send marketing, utility, and authentication templates to WhatsApp users. Unlike all other message types, template messages do not require a 24-hour customer service window to be open between you and the message recipient before the message can be sent.
Note: Before going further, please read about whatsapp message templates
Endpoint
POST
/whatsapp/v2/send
Header
Authentication
AUTHORIZATION: Bearer Token
Body
Object
{
"messages": [
{
"originator": "{registered phone_number}",
"content": {
"message_type": "TEMPLATE",
"template": <template>
},
"recipients": [<recipient>],
"report_url": "{report url}"
},
{
"originator": "{registered phone_number}",
"content": {
"message_type": "TEMPLATE",
"template": <template>
},
"recipients": [<recipient>],
"report_url": "{report url}"
}
]
}
{
"messages": [
{
"originator": "{registered phone_number}",
"content": {
"message_type": "TEMPLATE",
"template": <template>
},
"recipients": [<recipient>],
"report_url": "{report url}"
}
],
"message_globals": { // Global message parameters for all message objects
"schedule_time": "2021-08-05T12:52+05:30",
}
}
Body parameters
Parameter | Type | Description | Example |
---|---|---|---|
* originator | String | The Phone number of Sender/Header of a message. We can use your mobile number that is registered and approved in meta. | +97156xxxxxxx |
* recipients | Array(Object) | Array of recipient object | See examples |
*message_type | String | For templated messages. type is "TEMPLATE" | See examples |
*template | Template Object | A template object | |
report_url | HttpUrl | To receive delivery status (DLR) for your message, specify the callback server URL where you want to receive the message status updates using the report_url parameter. When the delivery status changes, the status updates will be sent to the specified URL. See more |
https://url_for_report.com |
schedule_time | String | Schedule request to send at specific time .format: YYYY-MM-DDTHH:MM+HH:MM , must be specified inside message_globals object |
Message Objects
"recipients": [
{
"recipient": "{{recipient1}}",
"recipient_type": "individual",
"reference": {
"cust_ref": "[email protected]",
"message_tag1": "d7id00001_m1",
"conversation_id": "d7id00001"
}
},
{
"recipient": "{{recipient2}}",
"recipient_type": "individual",
"reference": {
"cust_ref": "[email protected]",
"message_tag1": "d7id00001_m1",
"conversation_id": "d7id00001"
}
}
],
Parameter | Type | Description | Value / Pattern |
---|---|---|---|
*recipient | Array(string) | Mobile Numbers to send Whatsapp seperated by comma in an array. The recipient's phone number should have a country code prefix. | +97156xxxxxxx |
*recipient_type | String | Default: individual. Now Support Only individual recipients | individual |
cust_ref | string | Any text to store reference of recipient | [email protected] |
message_tag1 | string | Any text tag for message reference | tag1 |
message_tag2 | string | Any text tag for message reference | tag2 |
message_tag3 | string | Any text tag for message reference | tag3 |
message_tag4 | string | Any text tag for message reference | tag4 |
message_tag5 | string | Any text tag for message reference | tag5 |
conversation_id | string | Any text for conversation reference | conversation_marketing |
Parameter | Type | Description |
---|---|---|
*template_id | String | Template ID configured for WhatsApp template (HSM). This should be registered and approved by D7. You can create a new Whatsapp Template here |
*language | String | Specifies the code of language the template may be rendered in. Supported languages |
body_parameter_values | Dict | The Object of the body parameter values. Only required if your body text have variables. |
media | Object | Includes the parameters of template header |
buttons | Object | Details of the button object. |
carousel | Object | Carousel template object |
limited_time_offer | Object | LTO Template Object |
Parameter | Type | Description |
---|---|---|
*media_type | String | Type of the attachment you want to send through your template. Valid: image, audio, document, video |
*media_url | String | URL for the attachment. Required except the media type is location/text. |
media_caption | String | Caption for the attachment. |
document_file_name | String | Describes the filename for the specific document. Only required if the media type is document |
*text_header_title | String | Required only if approved template having text header and a parameter included in header text. |
*location | Object | Details of the location object, if media type is location |
Parameter | Type | Description |
---|---|---|
*quick_replies | Array(Object) | List of quick_replies button object. This is required if you wants to add quick reply buttons in your message. |
*actions | Array(object) | List of actions button object. This is required if you wants to add call to action buttons in your message. |
*coupon_code | Array(Object) | List of coupon code button object. This is required if you wants to add coupon code buttons in your message. |
"buttons": {
"quick_replies": [
{
"button_index": "0",
"button_payload": "SMS"
},
{
"button_index": "1",
"button_payload": "VIBER",
}
]
}
Parameter | Type | Description |
---|---|---|
*button_index | String | Position index of the button. Required if you have quick reply in your template. |
*button_payload | String | Developer-defined payload that will be returned when the button is clicked. |
"buttons": {
"actions": [
{
"action_index": "0",
"action_type": "URL",
"action_payload": "invoice/2345345345"
}
]
}
Parameter | Type | Description |
---|---|---|
*action_type | String | Type of action that whats to do while clicking the button. Supported Values: Dial and URL. |
*action_index | String | Position index of the button. Required if you have either url or dial button in your template. |
*action_payload | String | Developer-defined payload that will be returned when the button is clicked. For Dial Its a phone number and For URL it is a url. |
Parameter | Type | Description |
---|---|---|
*index | String | Position index of the button. Required if you have copy code button in your template. |
*type | String | Type of the coupen code |
*coupon_code | String | The coupon code to be copied when the customer taps the button. |
Parameter | Type | Description |
---|---|---|
*expiration_time_ms | number | Offer code expiration time as a UNIX timestamp in milliseconds. |
"carousel": {
"cards": [
{
"card_index": "0",
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"id": "1585106238959535"
}
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "15OFF"
},
{
"type": "text",
"text": "15%"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "59NqSd"
}
]
}
]
},
{
"card_index": "1",
"components": [
{
"type": "header",
"parameters": [
{
"type": "image",
"image": {
"id": "1585106238959535"
}
}
]
},
{
"type": "body",
"parameters": [
{
"type": "text",
"text": "20OFFEXOTIC"
},
{
"type": "text",
"text": "20%"
}
]
},
{
"type": "button",
"sub_type": "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
"payload": "59NqSdd"
}
]
}
]
}
]
}
Parameter | Type | Description |
---|---|---|
*card_index | number | Zero-indexed order in which card appears within the card carousel. 0 indicates first card, 1 indicates second card, etc. |
*components | Array(Object) | Includes the header object, body object and button object. See example |
Response
When the request is validated, request_id, status and created time will be returned. Users can use this request_id to query status using the Get status endpoint.
200 - Success
401 - Unauthorized
404 - Not Found
Response Parameters
Parameter | Value / Pattern |
---|---|
request_id | Unique id for each Whatsapp message request. This request_id is required to check delivery status of your Whatsapp message. |
status | The status of Whatsapp message request. Possible request status are accepted and rejected |
created_at | Date and time of the Whatsapp message request. |
Programing Examples:
One to One Message
1. Template without media and buttons
One to Many Message
1. Message type Template without media and buttons
|
|
|
|
|
|
|
|
|
|
Many to Many Message
1. Message type Template without media and buttons
|
|
|
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
|
|
|
|
|