Create a Coupon Code Template

The coupon code templates are templates that can be used to send a ‘coupon code’ displayed as a button on the end user’s device. When this button is tapped, the code gets copied to the end user’s phone clipboard. Each Coupon Code template can contain only one coupon code. The coupon code templates have the ‘marketing’ category mandated by Meta.
Using Kaleyra’s API, you can create coupon code templates and send the coupon code template messages to your customers.

Following are the steps to create a WhatsApp coupon code template message.

  1. Pre-requisites:
    1. 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..
    2. 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.
  2. Create a coupon code WhatsApp template.
  3. Use the coupon code template in a WhatsApp message to send a coupon code message.
    The following is a sample screen for a WhatsApp coupon code message on the end customer’s phone:

API Domain and Value

api_domainValue
IN podapi.in.kaleyra.io
SG Podapi.ap.kaleyra.io
EU Podapi.eu.kaleyra.io

WhatsApp API request format to create a coupon code template

The following API request creates a marketing template that has a coupon code.

curl --location 'https://<api_domain>/v1/<sid>/whatsapp/template' \
--header 'api-key: <api-key>' \
--form 'name="<name>"' \
--form 'category="<category>"' \
--form 'language="<language>"' \
--form 'header="{\"type\": \"image\"}";type=application/json' \
--form 'body="<body>"' \
--form 'button_data="[
 {
	\"type\":\"<type>l\",
	\"website_url_type\":\"<website_url_type>",
	\"website_button_text\":\"<button_text>",
	\"website_url\":\"<website_url>\"
},


{
        \"type\": \"<type>",
        \"text\": \"<text>\"
 }
] ";type=application/json' \
--form 'sample_body="<body>"' \
--form 'example="{
        \"body_text\": [
          [
            \"<body_text>",
            \"<body_text>"
          ]
        ]
      }"' \
--form 'sample_media_file=@"<sample_media>"' \
--form 'sample_media_url="<sample_media_url>"'

Sample WhatsApp API request for coupon code template

The following API request creates a coupon code template.

curl --location 'https://api.in.kaleyra.io/v1/HXXXXXXX071IN/whatsapp/template' \
--header 'api-key: XXXXX77c4d1cfa6854a7423a68e7XXXXX' \
--form 'name="cc_img_statics20"' \
--form 'category="marketing"' \
--form 'language="en"' \
--form 'header="{\"type\": \"image\"}";type=application/json' \
--form 'body="Hi {{$1}}, please avail {{$2}} off of all items!! grab now"' \
--form 'button_data="[
 {
				\"type\":\"url\",
				\"website_url_type\":\"static\",
				\"website_button_text\":\"button\",
				\"website_url\":\"https://www.favorite_shop.com\"
			},
	{
        \"type\": \"COPY_CODE\",
        \"text\": \"250OFF\"
        }
] ";type=application/json' \
--form 'sample_body="Hi {{$1}}, please avail {{$2}} off of all items!! grab now"' \
--form 'example="{
        \"body_text\": [
          [
            \"pablo\",
            \"25%\"
          ]
        ]
      }"' \
--form 'sample_media_file=@"https://www.kaleyra.com/wp-content/uploads/kaleyra.png"' \
--form 'sample_media_url="https://d38vr2u95vsr9f.cloudfront.net/docs/16879300632.jpg"'

Parameter Description Table

Following table shows the list of parameters and data types supported for Coupon Code template:

ParameterData TypeDescriptionExampleMandatory?
SIDStringSecurity Identifier of your Kaleyra.io account.HXXXXXXX071INYes
content_typeStringIndicates the format of the content the API will be processing.application/jsonYes
api_keyStringYour API Key generated by Kaleyra.io.Ac4XXXXX21fYes
nameStringThe template name.
The template name can be a maximum of 512 characters.
coupon_cd_templateYes
to_numberStringValid 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.
+1202XXXXXXXYes
channel_nameStringChannel on which the message is sent.
For the WhatsApp channel, the only allowed value is WhatsApp.
WhatsAppYes
from_noStringThe 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).+1202XXXXXXXYes
bodyStringBody of the message.Hi UserNo
languageStringThe language in which the message is sent.enYes
categoryStringThe message category.
Note: Only ‘Marketing’ value is accepted for the Coupon Code template.
MarketingYes
sample_media_fileStringThe location of the media file that is embedded in the message.
Ensure that you only use the media files in the supported formats.
Refer to
Messaging on WhatsApp Business for more details.
@"https://www.kaleyra.com/wp-content/uploads/kaleyra.png"Yes
sample_media_urlString

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 sample_media and media_url are passed in API request, then only "media_url" will be considered.
If the template header has media then the sample media should have a media file or upload the path of the media file in the sample media URL field. Otherwise, it's not mandatory.

https://www.kaleyra.com/wp-content/uploads/kaleyra.pngNo
button_dataObjectThis is the button object that holds the details about the buttons that appear as part of the message.button_data=
"[
{
"type":"url",
"website_url_type":"static",
"website_button_text":"button",
"website_url":"https://www.favorite_shop.com/"
},
Yes
exampleObject

Example object shows how to pass dynamic values in the dynamic variables in the message body.

Note: This parameter is required only, if the message body has dynamic variables.

example="{
"body_text": [
[
"pablo",
"25%"
][
\"pablo\",
\"25%\"
]
]
}"
No

The following table describes the objects’ parameters in the Coupon Code template request.

Example object parameters description table

ParameterData TypeDescriptionExampleMandatory?
body_textStringThe values in this field are the dynamic values that you pass for each of the dynamic variables in the message body.

body_text:Pablo
body_text:CARIBE25

In the message body:
Hi {{$1}}, please avail {{$2}} off of all items! grab now!!

{{$1}} and {{$2}} are the two dynamic variables.

For these two variables, you can pass the values:
"Pablo" and "CARIBE25" respectively.

Yes

Button_data object parameters description table

ParameterData TypeDescriptionExampleMandatory?
typeStringThe type of the button based on its purpose.urlYes
website_url_typeStringThe type of url the button contains
The values can be ‘static’ or ‘dynamic’.
staticYes
website_button_textStringThe text (caption) the button displaysbuttonYes
website_urlStringThe URL that the button takes you to, when clicked.https://www.favorite_shop.comYes

Sample success response

The following is a sample success response.

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

Samples error response

The following is a sample error response.

 "error": {  
        "code": "E413",  
        "type": "VALIDATION_ERROR",  
        "parameter": "category",  
        "message": "Invalid template category. Accepted categories are authentication, marketing, utility",  
        "reference": ""
        }

Sample error response

The following is a sample error response.

{  
    "error": {  
        "code": "E996",  
        "type": "VALIDATION_ERROR",  
        "parameter": "name",  
        "message": "Template name already taken!",  
        "reference": ""  
    }  
}



© 2026 Kaleyra Inc. All rights reserved.
Trademarks, logos and service marks displayed on this site are registered and unregistered trademarks of Kaleyra Inc.