Create a Multi-Product Message Template

POST Method

The Create a Multi-Product Message Template API allows you to create Multi-Product Message (MPM) templates in template messages.

  1. Sign up for free

Before you get started, create a Kaleyra.io account for free and Create an API Key. To view the API Key and the SID, see View API Key and SID.

  1. Pre-requisites

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

To have a product catalogue associated with the WABA, For more information, see Product Catalog Messages page.

  1. Create a Multi-Product Template Message API request.

You can use this API to create a Multi-Product Message template through your WhatsApp account.

Base URL:

<https://api.kaleyra.io/v1/<SID>

API request to create a Multi-Product Message Template

To create a Multi-Product Message template, use the /whatsapp/template endpoint with the following request method:

Request Format

The following is the request format to create a Multi-Product Message Template:

curl --location --request POST 'https://api.kaleyra.io/v1/<sid>/whatsapp/template' \
--header 'api-key: <api_key>' \
--form 'name="<template_name>"' \
--form 'category="<category>"' \
--form 'language="<language>"' \
--form 'header="{\"type\": \"<header_type>\",
     \"content\": \"<content>\"
}";type=application/json' \
--form 'body="\"<body>\""' \
--form 'sample_body="\"<sample_body>\""' \
--form 'button_data="[{
          \"type\": \"<type>\",
          \"text\": \"<text>\"
        }]";type=application/json' \
--form 'sample_header_content="<sample_header_content>"'

Sample Request Format

The following is the sample request format to create a Multi-Product Message Template:

curl --location--request POST 'https://api.kaleyra.io/v1/HXAP16XXXXXX97IN/whatsapp/template' \
--header 'api-key: Axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx3' \
--form 'name="my_first_mpm"' \
--form 'category="marketing"' \
--form 'language="en"' \
--form 'header="{\"type\": \"text\",
     \"content\": \"Hi there\"
}";type=application/json' \
--form 'body="\"come and see our latest product collections"\""' \
--form 'sample_body="\"come and see our latest product collections"\""' \
--form 'button_data="[{
          \"type\": \"MPM\",
          \"text\": \"View items\"
        }]";type=application/json' \
--form 'sample_header_content="Hi there"'

Parameters and Data Types

Following is the list of parameters and data types supported for 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
categoryStringEnter the template category. Only Marketing is supported.marketingYes
languageStringThe language in which, you want to create the template.enYes
header_typeStringSpecifies the header type. Only supported type is "Text".TextYes
contentStringSpecifies the text data that has to be sent". The supported format is Text.Hi thereYes
bodyStringBody of the message. Maximum 1024 characters. Body can have different variables that are included in the text.come and see our latest product collectionsYes
sample_bodyStringSpecifies the sample body of the message. You can send any value in the body variable.come and see our latest product collectionsYes
button_dataStringThe button_data object in the API request defines the fields that will be shown to the end-user. The supported button data type is MPM.Type is MPM and the text is View itemsYes
sample_header_contentStringSpecifies the sample header text.Hi thereYes

The following table describes the different attributes used for the button_data object

parameterData TypeDescriptionExamplesMandatory?
typeStringSpecifies the button data type.MPMYes
textStringSpecifies the text to be displayed on the button with 25 characters.View itemsYes

Sample Success Response to create MPM template

The following success message appears with the status 200 Accepted:

{
    "status": 200,
    "message": "Template created successfully.",
    "data": [],
    "error": {}
}

Sample Failure Response to create MPM template

The following is the failure response to create an MPM template.

{
    "error": {
        "code": "E1035",
        "type": "VALIDATION_ERROR",
        "parameter": "button_data",
        "message": "Text for button type 'MPM' cannot be modified and must always be 'View items'.",
        "reference": ""
    }
}

Error Codes

For information related to the WhatsApp error code, see WhatsApp Error Codes.