Create a Limited Time Offer (LTO) Code Template

The Limited Time Offer (LTO) WhatsApp templates have a limited-time-offer with an expiration date and a countdown timer displayed in the LTO template messages. The WhatsApp messages with these LTO offers, enable you to communicate with your customers about offers with limited time and help in better customer engagement.

Following are the steps to create a WhatsApp LTO code template.

  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 WhatsApp LTO code template.
  3. Use the LTO code template in a WhatsApp message to send an LTO code message.
    You can use the LTO template in a WhatsApp message to send an LTO message.
    The following is a sample screen of a WhatsApp LTO message on the end customer’s phone:

WhatsApp API request format to create LTO template

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

curl --location 'https://api.kaleyra.io/v1/<sid>/whatsapp/template' \
--header 'api-key: <api-key>' \
--form 'name="<template_name>"' \
--form 'category="<category_name>"' \
--form 'language="<language>"' \
--form 'header="{\"type\": \"image\"}";type=application/json' \
--form 'body="<body>"' \
--form 'button_data="[
		{
       \"type\": \"<COPY_CODE>\",
       \"text\": \"<text>\"
       },
{
	\"type\":\"<type>\",
	\"website_url_type\":\"<website_url_type>\",
	\"website_button_text\":\"<website_button_text>\",
	\"website_url\":\"<website_url>\",
	\"website_url_sample\":\"<website_url_sample>\"
}
] ";type=application/json' \
--form 'sample_body="<body>"' \
--form 'sample_header_content="{\"type\": \"image\"}"' \
--form 'allow_category_change="<allow_categroy_change>"' \
--form 'waba_id="<waba_id>"' \
--form 'example="{
       \"body_text\": [
         [
           \"<body_text>\",
           \"<body_text>\"
         ]
       ]
     }"' \
--form 'sample_media_file=@"<media_file>"' \
--form 'limited_time_offer="{
       \"text\": \"<text>\",
       \"has_expiration\": <has_expiration_value>
}"'

Sample WhatsApp request for LTO template

The following API request creates an LTO template.

curl --location 'https://api.kaleyra.io/v1/HXIN1784509XXXXX/whatsapp/template' \
--header 'api-key: XXXXX77c4d1cfa6854a7423a68e7XXXXX' \
--form 'name="lto_true_vid_dyan_test"' \
--form 'category="marketing"' \
--form 'language="en"' \
--form 'header="{\"type\": \"video\"}";type=application/json' \
--form 'body="Renew now at just ₹1499 💸
  Catch the latest releases, Hotstar Specials and LIVE cricket:"' \
--form 'button_data="[
		{
        \"type\": \"COPY_CODE\",
        \"text\": \"HAPPY_HOURS\"
        },
  {
		\"type\":\"url\",
		\"website_url_type\":\"dynamic\",
		\"website_button_text\":\"button\",
		\"website_url\":\"https://www.favorite_shop/\",
		\"website_url_sample\":\"https://www.favorite_shop.com"
}
] ";type=application/json' \
--form 'sample_body="Renew now at just ₹1499 💸
Catch the latest releases, Hotstar Specials and LIVE cricket:"' \
--form 'allow_category_change="1"' \
--form 'sample_media_file=@"https://www.kaleyra.com/wp-content/uploads/kaleyra.png"' \
--form 'limited_time_offer="{
        \"text\": \"Hurry Up\",
        \"has_expiration\": true
}"' \
--form 'sample_media_url="https://d38vr2u95vsr9f.cloudfront.net/docs/1684759885mp4_file.mp4"'

Parameter Description Table

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

ParameterData TypeDescriptionExampleMandatory?
SIDStringSecurity Identifier of your kaleyra.io account.HXXXXXXX071USYes
api_keyStringYour API Key generated by Kaleyra.io.Ac4XXXXX21fYes
to_number StringA 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.
+1202XXXXXXXYes
channel_name StringChannel on which message must be sent.
For the WhatsApp channel, the only allowed value is WhatsApp.
WhatsAppYes
from_number StringThe 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
body StringThe body of the message.Hi UserNo
languageStringThe language in which the message is sent.enYes
categoryStringThe message category.

Note: Only the ‘Marketing’ category is supported for LTO templates.
MarketingYes
sample_media_fileStringThe location of the media file that will be embedded in the message.
Ensure you upload only the formats supported. Refer to
Messaging on WhatsApp Business for more details.
@"https://www.kaleyra.com/wp-content/uploads/kaleyra.png"Yes
samplemedia_url StringThe 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_file and media_url are passed in API request, then only "media_url" is considered.
If a header is used, then only image/ video type is supported in the sample media field or sample _ media_url. Otherwise, this is not a mandatory field.
https://www.kaleyra.com/wp-content/uploads/image.pngNo
button_data ObjectThis is the button object that holds the button related details. The button appears as part of the message.button_data=
"[
{
"type": "COPY_CODE",
"text": "DIWALI"
},
{ "type":"url",
"website_url_type":
"dynamic", "website_button_text":"button", "website_url":

"https://www.favorite_shop.com/", "website_url_sample":"https://www.favorite_shop.com"
}
] "
Yes
limited_time_offer ObjectThis field will hold in the values which define the LTO template.
Note: This object parameter is mandatory for an LTO template.
limited_time_offer =
"{
"text": "Expiring offer!",
"has_expiration": true
}
No

Button_data object parameters description table

ParameterData TypeDescriptionExampleMandatory?
type StringThe type of the button based on its purpose.COPY_CODE, URLYes
text StringThe text that the button displays on the button.HAPPY_HOURSYes
website_url_typeStringThe type of URL the button contains
The values can be ‘static’ or ‘dynamic’.
Dynamic, StaticYes
website_button_text StringThe text (caption) the button displays buttonYes
website_url StringThe URL that the button takes you to, when clicked.https://www.favorite_shop.comYes
website_url_sample StringThe sample URL shown by the button.https://www.my_favorite_shop.comYes

Limited_time_offer object parameters description table

ParameterData TypeDescriptionExampleMandaotry?
textStringThe text that you want to show as ‘limited time offer’ text.Hurry Up! Ends in 2 days.Yes
has_expirationStringThe flag that indicates if the limited time offer has an expiration date.True, FalseYes

Sample success Response

The following is a sample success response.

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

Sample error response

The following is a sample error response.

{  
    "error": {  
        "code": "E1020",  
        "type": "VALIDATION_ERROR",  
        "parameter": "sample media url",  
        "message": "Sample Media URL is not valid!",  
        "reference": ""  
    }  
}

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."  
    }  
}