Send a Coupon Code Template Message
Using a WhatsApp coupon code template, you can send a WhatsApp coupon code message.
Following are the steps to send a WhatsApp coupon code message.
- Pre-requisites:
- An active kaleyra.io account, if you do not have, you can contact a kaleyra representative to sign up for free to the platform. Before you get started, Create a Kaleyra Account and Create an API Key.
To view the API Key and the SID, see View API Key and SID.. - An active WhatsApp for Business API plan that includes:
A WhatsApp business number.
An associated profile with the business number.
A WhatsApp verified and approved profile.
- An active kaleyra.io account, if you do not have, you can contact a kaleyra representative to sign up for free to the platform. Before you get started, Create a Kaleyra Account and Create an API Key.
- Create a WhatsApp coupon code template. See, Create a Coupon Code template.
- Use the WhatsApp coupon code template in a WhatsApp message to send a coupon code message.
The following WhatsApp API request format uses a coupon code template.
curl --location 'https://api.kaleyra.io/v1/<sid>/messages' \
--header 'api-key: <api-key>' \
--form 'to="<to-number>"' \
--form 'type="mediatemplate"' \
--form 'template_name="<template_name>"' \
--form 'params="\"<params>\""' \
--form 'channel="whatsapp"' \
--form 'from="<from-no>"' \
--form 'callback_profile_id’="<callback_profile_id>”’ \
--form 'coupon_code="\"<coupon_code>"”’ \
--form 'media_url="<media_url>”’
Sample WhatsApp API request message with coupon code template
The following API request sends a WhatsApp message with a coupon code template.
curl --location 'https://api.kaleyra.io/v1/HXIN1784509XXXXX/messages' \
--header 'api-key: XXXXX77c4d1cfa6854a7423a68e7XXXXX' \
--form 'to="1202XXXXXXX"' \
--form 'type="mediatemplate"' \
--form 'template_name="cc_img_statics20"' \
--form 'params="\"Mike\",\"25%\""' \
--form 'channel="whatsapp"' \
--form 'from="+1202XXXXXXX"' \
--form 'callback_profile_id="IN_b86b078e-046b-4565-892c-XXXXXXXXXXXX"' \
--form 'coupon_code="\"2532334\""' \
--form 'media_url="https://d38vr2u95vsr9f.cloudfront.net/docs/16879300632.jpg"'
Parameter description table
Following table shows the list of parameters and data types supported:
Parameter | Data Type | Description | Example | Mandatory? |
---|---|---|---|---|
SID | String | Security Identifier of your kaleyra.io account. | HXXXXXXX071US | Yes |
api_key | String | Your API Key generated by Kaleyra.io. | Ac4XXXXX21f | Yes |
to | 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 and separate each number using the comma (,) delimiter. | +1202XXXXXXX | Yes |
type | String | The message type. | media template | Yes |
template_name | String | The template name. | coupon_template | Yes |
channel | String | Channel on which the message is sent. For the WhatsApp channel, the only allowed value is WhatsApp. | Yes | |
from | String | The number registered with WhatsApp business from which the message is to be sent. Ensure that the country code is prefixed to the number. (E164 format). | +1202XXXXXXX | Yes |
coupon_code | String | This field will hold the text that needs to be copied when the COPY CODE button is clicked. | coupon_code: “2532334” | Yes |
callback_profile_id | String | The callback ID created for WhatsApp channel to receive updates about the message delivery status. Note: You can also use callback_url to get updates about the message delivery status to the specified URL. | IN_b86b078e-046b-4565-892c-XXXXXXXXXXXX | No |
media_url | String | The media URL should be public and have a file extension. Note: URL path is supported for image/video/media instead of uploading it. If both media and media_url are passed in API request, then only "media_url" will be considered. This parameter is mandatory only if used in the template header. | https://www.kaleyra.com/wp-content/uploads/kaleyra.png | No |
Sample success response
The following is a sample success response.
{
"id": "2a584df7-79df-44a2-8cb0-efa5fc276125",
"type": "mediatemplate",
"body": null,
"createdDateTime": "2024-01-09 13:00:14+00:00",
"totalCount": 1,
"data": [
{
"message_id": "2a584df7-79df-44a2-8cb0-efa5fc276125:0",
"recipient": "919986517019"
}
],
"error": {}
}
Sample error response
The following is a sample error response.
{
"code": "RBC201",
"message": "Incorrect SID or API key.",
"data": \[],
"error": {
"error": "Incorrect SID or API key."
}
}
Updated 5 months ago
What’s Next