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.
- 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.
- 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.
- 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:
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 |
category | String | Enter the template category. Only Marketing is supported. | marketing | Yes |
language | String | The language in which, you want to create the template. | en | Yes |
header_type | String | Specifies the header type. Only supported type is "Text". | Text | Yes |
content | String | Specifies the text data that has to be sent". The supported format is Text. | Hi there | Yes |
body | String | Body of the message. Maximum 1024 characters. Body can have different variables that are included in the text. | come and see our latest product collections | Yes |
sample_body | String | Specifies the sample body of the message. You can send any value in the body variable. | come and see our latest product collections | Yes |
button_data | String | The 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 items | Yes |
sample_header_content | String | Specifies the sample header text. | Hi there | Yes |
The following table describes the different attributes used for the button_data object
parameter | Data Type | Description | Examples | Mandatory? |
---|---|---|---|---|
type | String | Specifies the button data type. | MPM | Yes |
text | String | Specifies the text to be displayed on the button with 25 characters. | View items | Yes |
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.
Updated 8 months ago