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:

  1. Before you get started, Create an API Key. To view the API Key and the SID, see View API Key and SID.
  2. 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
  3. 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:

ParameterData TypeDescriptionExamplesMandatory?
sidStringAccount SID (Security Identifier).HXXXXXXX071USYes
api-keyStringYour API Key generated by Kaleyra.io.Axxxxxxxxxxxxxxxxxxxxxxxxxxxx3Yes
template_nameString or IntegerSpecifies the Template name. Maximum 512 characters.my_first_mpmYes
receipent_phone_numberStringA 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 (,).
+1202XXXXXXXYes
message_typeStringSpecifies the type of the message. The only acceptable value is mediatemplate for the MPM.mediatemplateYes
languageStringThe language in which, you want to create the template.enYes
thumbnail_product_retailer_idStringThe product retailer id that is used as the header image of the message being sent.2lxxxx05ptYes
sectionsArrayHelps 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_numberStringThe 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).+1202XXXXXXXYes
channel_nameStringChannel on which message must be sent. The acceptable value is "whatsapp".WhatsAppYes

The following table describes the different attributes used for the sections array.

ParameterData TypeDescriptionExamplesMandatory?
titleStringSpecifies the category of the product.pantYes
Product_itemsArraySpecifies the product that is listed under the specified title."product_items": [
{
"product_retailer_id": "2lxxxx05pp"
}
]
Yes
product_retailer_idStringSpecifies the product to be shown from the catalogue.2lxxxx05pdYes

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.