Send a Multi-Product Message Template
POST Method
The Send a Multi-Product Message Template API allows you to send Multi-Product messages using the approved templates.
To send a Multi-Product Message Template, perform the following steps:
- Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
- A prerequisite for using Kaleyra WhatsApp APIs is to have an active WhatsApp plan on kaleyra.io.
To set up a WhatsApp account on kaleyra.io, see: https://developers.kaleyra.io/docs/manual-signup
And https://developers.kaleyra.io/docs/embedded-signup - Send a Multi-Product Message Template API request.
The following is the prerequisite for sending a Multi-Product Message template:
- You must link the catalogue to the WhatsApp Business Account (WABA) ID that is being used to send the message.
Base URL
<https://api.kaleyra.io/v1/><SID>
API request to send a Multi-Product Message Template
To send a Multi-Product Message template, use the /messages
endpoint with the following request method:
Request Format
The following is the request format to send Multi-Product Message Template:
curl --location 'https://api.kaleyra.io/v1/<SID>/messages' \
--header 'api-key: <api_key>' \
--form 'name="<template_name>"' \
--form 'to="<receipent_phone_number>"' \
--form 'type="<message_type>"' \
--form 'language="<language>"' \
--form 'thumbnail_product_retailer_id="\"<product_retailer_id>\""' \
--form 'sections="[{
\"title\": \"<title>\",
\"product_items\": [
{
\"product_retailer_id\": \"<product_retailer_id>\"
},
{
\"product_retailer_id\": \"<product_retailer_id>\"
}
]
},
{
\"title\": \"<title>\",
\"product_items\": [
{
\"product_retailer_id\": \"<product_retailer_id>\"
}
]
}]"' \
--form 'from="<sender_phone_number>"' \
--form 'channel="<channel_name>"'
Sample Request Format
The following is the sample request format to send Multi-Product Message Template:
curl --location 'https://api.kaleyra.io/v1/HXAP16XXXXXX97IN/messages' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--form 'name="my_first_mpm"' \
--form 'to="+1202XXXXXXX"' \
--form 'type="mediatemplate"' \
--form 'language="en"' \
--form 'thumbnail_product_retailer_id="\"2lxxxx05pt\""' \
--form 'sections="[{
\"title\": \"shirt\",
\"product_items\": [
{
\"product_retailer_id\": \"2lxxxx05pb\"
},
{
\"product_retailer_id\": \"2lxxxx05pd\"
}
]
},
{
\"title\": \"pant\",
\"product_items\": [
{
\"product_retailer_id\": \"2lxxxx05pp\"
}
]
}]"' \
--form 'from="+1202XXXXXXX"' \
--form 'channel="whatsapp"'
Parameters and Data Types
Following is the list of parameters and data types supported for sending Multi-Product Message Template:
Parameter | Data Type | Description | Examples | Mandatory? |
---|---|---|---|---|
sid | String | Account SID (Security Identifier). | HXXXXXXX071US | Yes |
api-key | String | Your API Key generated by Kaleyra.io. | Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3 | Yes |
template_name | String or Integer | Specifies the Template name. Maximum 512 characters. | my_first_mpm | Yes |
receipent_phone_number | String | A valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format). Note: You can add multiple numbers, separate each number using the comma (,). | +1202XXXXXXX | Yes |
message_type | String | Specifies the type of the message. The only acceptable value is mediatemplate for the MPM. | mediatemplate | Yes |
language | String | The language in which, you want to create the template. | en | Yes |
thumbnail_product_retailer_id | String | The product retailer id that is used as the header image of the message being sent. | 2lxxxx05pt | Yes |
sections | Array | Helps to define the category of the product and the product to be displayed. A maximum 30 products can be displayed. Minimum limit is one and mandatory. | [{ "title": "Shirt", "product_items": [ { "product_retailer_id": "2lxxxx05pb" } ] }] | Yes |
sender_phone_number | String | The number registered with WhatsApp business account from which the message is to be sent. Ensure that the country code is prefixed to the number. (E164 format). | +1202XXXXXXX | Yes |
channel_name | String | Channel on which message must be sent. The acceptable value is "whatsapp". | Yes |
The following table describes the different attributes used for the sections array.
Parameter | Data Type | Description | Examples | Mandatory? |
---|---|---|---|---|
title | String | Specifies the category of the product. | pant | Yes |
Product_items | Array | Specifies the product that is listed under the specified title. | "product_items": [ { "product_retailer_id": "2lxxxx05pp" } ] | Yes |
product_retailer_id | String | Specifies the product to be shown from the catalogue. | 2lxxxx05pd | Yes |
Sample Success Response to send MPM template
The following success message appears with the status 200 Accepted:
{
"id": "afc8a003-39b6-412a-aedf-d207XXXXX372",
"type": "template",
"body": null,
"createdDateTime": "2024-02-08 12:41:31+00:00",
"totalCount": 1,
"data": [
{
"message_id": "afc8a003-39b6-412a-aedf-d207XXXXX872:0",
"recipient": "91XXXXXXX943"
}
],
"error": {}
}
Error Codes
For information related to the WhatsApp error code, see WhatsApp Error Codes.
Updated 6 months ago