Send a Limited Time Offer (LTO) Code Template Message

The following API request format is for sending a WhatsApp message with an LTO 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 'channel="whatsapp"' \
--form 'from="<from-no>"' \
--form 'coupon_code="\"<coupon_code>\""' \
--form 'limited_time_offer="[
          {
            \"type\": \"limited_time_offer\",
            \"limited_time_offer\": {
              \"expiration_time_ms\": <expiration_time>
            }
          }
        ]"' \
--form 'media=@"/path/to/file"' \
--form 'callback_profile_id="<callback_profile_id>"' \
--form 'param_url="login"' \
--form 'media_url="<media_url>"'

WhatsApp message API request with LTO template

The following API request sends a WhatsApp message with an LTO template.

curl --location 'https://api.kaleyra.io/v1/HXIN1784509XXXXX/messages' \
--header 'api-key: Abf2e77c4d1cfa6854a7423a68e7XXXXX' \
--form 'to="1202XXXXXXX"' \
--form 'type="mediatemplate"' \
--form 'template_name="lto_true_vid_dyan_test"' \
--form 'channel="whatsapp"' \
--form 'from="1202XXXXXXX"' \
--form 'coupon_code="\"happy76\""' \
--form 'limited_time_offer="[
          {
            \"type\": \"limited_time_offer\",
            \"limited_time_offer\": {
              \"expiration_time_ms\":1209600000}
          }
        ]"' \
--form 'media=@"/path/to/file"' \
--form 'callback_profile_id="IN_XXXXXXXX-046b-4565-892c-XXXXXXXXXXXX"' \
--form 'param_url="login"' \
--form 'media_url="https://d38vr2u95vsr9f.cloudfront.net/docs/1684759885mp4_file.mp4"'

Parameter Description Table

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

ParameterData TypeDescriptionExampleMandatory?
SIDStringSecurity Identifier of your kaleyra.io accountHXXXXXXX071USYes
api_keyStringYour API Key generated by Kaleyra.io.Ac4XXXXX21fYes
to StringA valid WhatsApp number of the recipient. Ensure that the country code is prefixed to the number. (E164 format).
Note: You can add multiple recipients, separate each number using the comma (,) delimiter.
+1202XXXXXXXYes
type StringThe message type. mediatemplateYes
template_name StringThe template name.LTO_templateYes
channel StringChannel on which message must be sent.
For the WhatsApp channel, the only allowed value is WhatsApp.
WhatsApp Yes
from 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).+1202XXXXXXX Yes
callback_profile_id StringThe 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_XXXXXXXX-04XX-XXXX-XXXX-deac8de3c83dNo
media_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 and mediaurl are passed in API request, then only "media_url" will be 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/kaleyra.pngNo
coupon_code StringThis field will hold the text that needs to be copied when the COPY CODE button is clicked.coupon_code: “happy76”.Yes
limited_time_offer objectThis field holds the offer expiration time as UNIX TIMESTAMP which indicates the date on which the offer ends.
Note: This object parameter is mandatory for an LTO template.
limited_time_offer: [
{
"type": "limited_time_offer",
"limited_time_offer": {
"expiration_time_ms": 1209600000
}}]

Note: This parameter is mandatory when the LTO template has ‘has_expiration’ parameter set to true.
No

Limited_time_offer object parameters description table

The following table describes the object parameters in WhatsApp Message request that uses an LTO template.

ParameterData TypeDescriptionExampleMandatory?
type StringType of the limited time offer objectlimited_time_offerYes
limited_time_offer ObjectThis is an object parameter within the limited time offer object that has a time parameter to define the validity period of the offer.

The ‘limited_time_offer’ parameter is an offer code expiration time in UNIX timestamp measured in milliseconds.
“limited_time_offer": {
"expiration_time_ms": 1209600000}
Note: This expiration time equals to 14 days when converted to days from milliseconds.
Yes
expiration_time_ms NumericThe number of milliseconds after which the LTO expires. This number represents the date on which the offer ends.
This is a Unix timestamp that represent time in milliseconds from a given date.
For example, March, 1st 2024 4:30:00pm
1209600000Yes

Sample success response

The following is a sample success response.

{  
    "id": "08a72b9e-9e0e-46af-a41b-2d87bf30e036",  
    "type": "mediatemplate",  
    "body": null,  
    "createdDateTime": "2024-01-12 07:08:43+00:00",  
    "totalCount": 1,  
    "data": [  
        {  
            "message_id": "08a72b9e-9e0e-46af-a41b-2d87bf30e036: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."  
    }  
}