Skip to content

Limited-Time Offer Template Messages

Limited-time offer templates allow you to display expiration dates and running countdown timers for offer codes in template messages, making it easy for you to communicate time-bound offers and drive customer engagement.

Image Alt Text

LTO Object

Parameter Type Description
*expiration_time_ms number Offer code expiration time as a UNIX timestamp in milliseconds.
buttons Object Details of the button object.
Parameter Type Description
*index String Position index of the button. Required if you have copy code button in your template.
*type String Type of the coupen code
*coupon_code String The coupon code to be copied when the customer taps the button.
    /* Required if template uses offer expiration details, otherwise omit */
    "limited_time_offer": {
                "expiration_time_ms": 1708804800000
            },
    "buttons": {
            /* Copy code button optional */
            "coupon_code": [
                {
                    "index": 0,
                    "type": "copy_code",
                    "coupon_code": "GCBTS23"
                }
            ],
            /* Can be omitted if url button in template has no variables */
            "actions": [
                        {
                            "action_type": "url",
                            "action_index": "1",
                            "action_payload": "/login"
                        }
                    ]
        }

Programing Examples:

curl --location 'https://api.d7networks.com/whatsapp/v2/send' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{api_access_token}}' \
--data '{
    "messages": [
        {
            "originator": "{{originator}}",
            "content": {
                "preview_url": false,
                "message_type": "TEMPLATE",
                "template": {
                    "template_id": "{{template_id}}", 
                    "language" : "en",
                    "body_parameter_values": {
                        "0": "first_parameter_in_your_template",
                        "1": "second_parameter_in_your_template"
                    },
                    "media": {
                        "media_type": "image",
                        "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
                    },
                    "limited_time_offer": {
                        "expiration_time_ms": 1708804800000
                    },
                    "buttons": {
                        "coupon_code": [
                            {
                                "index": 0,
                                "type": "copy_code",
                                "coupon_code": "GCBTS23"
                            }
                        ]
                    }
                }
            },
                "recipients": [
                    {
                        "recipient": "{{recipient1}}",
                        "recipient_type": "individual"
                    }
                ],
                "report_url": "https://the_url_to_recieve_delivery_report.com"

        }
    ]
}'
npm i direct7
const Client = require('direct7')
const client = new Client(apiToken="Your API token")
const response = await client.whatsapp.sendWhatsAppTemplatedMessage({
        originator: "{{originator}}",
        recipients: [{"recipient": "{{recipient1}}","recipient_type": "individual"}],
        template_id: "{{template_id}}",
        language: "en",
        media_type: "image",
        media_url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
        lto_expiration_time_ms: "1708804800000",
        coupon_code: "DWS44"
    });
console.log('Templated message sent successfully. Response:', response);
pip install direct7
from direct7 import Client

client = Client(api_token="Your API token")

client.whatsapp.send_whatsapp_templated_message(originator="{{originator}}",
                                                recipients=[{"recipient": "{{recipient1}}","recipient_type": "individual"}], language="en",
                                                template_id="{{template_id}}",
                                                media_type="image",
                                                media_url="https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
                                                lto_expiration_time_ms="1708804800000",
                                                coupon_code="DWS44")
composer require direct7/direct7-php
require_once 'vendor/autoload.php';
require_once __DIR__ . '/vendor/autoload.php';

use direct7\Direct7\Client;

$direct7 = new Client(api_token="Your API token");

$response = $direct7->whatsapp->sendWhatsAppTemplatedMessage(
    originator:"{originator}", 
    recipients: [["recipient" => "{recipient}", "recipient_type" => "individual"]], 
    template_id: "{template_id}", 
    language: 'en',
    media_type: "image",
    media_url: "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg", 
    lto_expiration_time_ms: "1708804800000", 
    coupon_code: "DWS44"
);

var_dump($response);
go get -u github.com/d7networks/direct7-go-sdk
import (
    "github.com/d7networks/direct7-go-sdk/direct7"
    )
    apiToken := "Your Api Token"
    client := direct7.NewClient(apiToken)
    whatsapp := direct7.NewWhatsApp(client)
    originator := "{{originator}}"
    recipients := []map[string]string{
        "recipient": "{recipient}",
        "recipient_type": "individual",
    }
    templateId := "limited_time_offer"
    language := "en"
    optParams := &OptionalParams{
        mediaType: "image"
        mediaURL:               "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg",
        ltoExpirationTimeMS:    "1704272804",
        couponCode:             "DWS44",
    }
    response, err := client.whatsapp.SendWhatsAppTemplatedMessage(originator, recipients, templateId, language, optParams)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                    },\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"limited_time_offer\": {\n                        \"expiration_time_ms\": 1708804800000\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"index\": 0,\n                                \"type\": \"copy_code\",\n                                \"coupon_code\": \"GCBTS23\"\n                            }\n                        ]\n                    }\n                }\n            },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\"\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            \n        }\n    ]\n}\n");
Request request = new Request.Builder()
.url("https://api.d7networks.com/whatsapp/v2/send")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer {{api_access_token}}")
.build();
Response response = client.newCall(request).execute();
var headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{api_access_token}}'
};
var request = http.Request('POST', Uri.parse('https://api.d7networks.com/whatsapp/v2/send'));
request.body = json.encode({
"messages": [
    {
    "originator": "{{originator}}",
    "content": {
        "preview_url": false,
        "message_type": "TEMPLATE",
        "template": {
        "template_id": "{{template_id}}", 
        "language" : "en",
        "body_parameter_values": {},
        "media": {
            "media_type": "image",
            "media_url": "https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg"
        },
        "limited_time_offer": {
            "expiration_time_ms": 1708804800000
        },
        "buttons": {
            "coupon_code": [
            {
                "index": 0,
                "type": "copy_code",
                "coupon_code": "GCBTS23"
            }
            ]
        }
        }
    },
    "recipients": [
        {
        "recipient": "{{recipient1}}",
        "recipient_type": "individual"
        }
    ],
    "report_url": "https://the_url_to_recieve_delivery_report.com"
    }
]
});
request.headers.addAll(headers);

http.StreamedResponse response = await request.send();

if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Authorization", "Bearer {{api_access_token}}")

$body = @"
{
    `"messages`": [
        {
            `"originator`": `"{{originator}}`",
            `"content`": {
                `"preview_url`": false,
                `"message_type`": `"TEMPLATE`",
                `"template`": {
                    `"template_id`": `"{{template_id}}`",
                    `"body_parameter_values`": {
                        `"0"`: `"first_parameter_in_your_template"`,
                        `"1"`: `"second_parameter_in_your_template"`
                    },
                    `"media`": {
                        `"media_type`": `"image`",
                        `"media_url`": `"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg`"
                    },
                    `"limited_time_offer`": {
                        `"expiration_time_ms`": 1708804800000
                    },
                    `"buttons`": {
                        `"coupon_code`": [
                            {
                                `"index`": 0,
                                `"type`": `"copy_code`",
                                `"coupon_code`": `"GCBTS23`"
                            }
                        ]
                    }
                }
            },
                `"recipients`": [
                    {
                        `"recipient`": `"{{recipient1}}`",
                        `"recipient_type`": `"individual`"
                    }
                ],
                `"report_url`": `"https://the_url_to_recieve_delivery_report.com`"

        }
    ]
}

"@

$response = Invoke-RestMethod 'https://api.d7networks.com/whatsapp/v2/send' -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Json
gem install direct7
require 'direct7'

client = Direct7::Client.new('Your API token')

client.whatsapp.send_whatsapp_templated_message(
    originator='{originator}', 
    recipients=[{ "recipient" => "{recipient}", "recipient_type" => "individual" }],
    template_id="{template_id}", 
    language="en",
    body_parameter_values=nil,
    media_type="image",
    text_header_title=nil,
    media_url="https://t4.ftcdn.net/jpg/01/43/23/83/360_F_143238306_lh0ap42wgot36y44WybfQpvsJB5A1CHc.jpg",
    latitude=nil, longitude=nil, name=nil, address=nil,
    lto_expiration_time_ms="1708804800000",
    coupon_code="DWS44"
)
1
2
3
4
5
6
7
8
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api.d7networks.com/whatsapp/v2/send");
request.Headers.Add("Authorization", "Bearer {{api_access_token}}");
var content = new StringContent("{\n    \"messages\": [\n        {\n            \"originator\": \"{{originator}}\",\n            \"content\": {\n                \"preview_url\": false,\n                \"message_type\": \"TEMPLATE\",\n                \"template\": {\n                    \"template_id\": \"{{template_id}}\",\n                    \"body_parameter_values\": {\n                        \"0\": \"first_parameter_in_your_template\",\n                        \"1\": \"second_parameter_in_your_template\"\n                    },\n                    \"media\": {\n                        \"media_type\": \"image\",\n                        \"media_url\": \"https://miro.medium.com/max/780/1*9Wdo1PuiJTZo0Du2A9JLQQ.jpeg\"\n                    },\n                    \"limited_time_offer\": {\n                        \"expiration_time_ms\": 1708804800000\n                    },\n                    \"buttons\": {\n                        \"coupon_code\": [\n                            {\n                                \"index\": 0,\n                                \"type\": \"copy_code\",\n                                \"coupon_code\": \"GCBTS23\"\n                            }\n                        ]\n                    }\n                }\n            },\n                \"recipients\": [\n                    {\n                        \"recipient\": \"{{recipient1}}\",\n                        \"recipient_type\": \"individual\"\n                    }\n                ],\n                \"report_url\": \"https://the_url_to_recieve_delivery_report.com\"\n            \n        }\n    ]\n}\n", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());