# POST /messages — Send LTO template

> Product: **Pabbly Chatflow** (v1)
> Base URL: `https://chatflow.pabbly.com/api/v1`
> Auth: Bearer via `Authorization` header
> Canonical: `/chatflow/messages/send-lto-template`

Prerequisites: You need to create an LTO (Limited Time Offer) template through Pabbly Chatflow or WhatsApp Manager. LTO templates allow you to send time-bound offers (limited-time / expiring deals) with a media header (image or video), body text variables and interactive buttons like copy code and URL. Hit the API with the POST method and fill the following data according to your requirements to send an LTO template message.

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| to | integer | Yes | Recipient number with dialing code |
| type | string | Yes | Type of message you want to send. It should be "template" in case you want to send an LTO template message |
| templateName | string | Yes | Name of the approved LTO template you want to send |
| languageCode | string | No | Language code of the template (e.g., "en", "hi"). Defaults to the template's language if omitted |
| link | string | Yes | Public file URL of the header media (image or video). LTO templates support IMAGE or VIDEO header only |
| bodyParams | array | No | Values for variables in the main body text. e.g., ["John", "50%"] for {{1}}, {{2}} |
| copyCodeParam | string | No | Offer / coupon code value, used by the copy code button if present |
| urlVariables | array | No | Dynamic URL button parameter values, generally one per dynamic URL button (for LTO usually ek hi URL hota hai) |
| ltoFields | object | No | LTO expiry fields. Required if your template includes the Limited-Time Offer component with expiration enabled |
|   ↳ unixTimestamp | integer | No |  |
| quickReplies | string | No | List of quick reply payload values, if template includes quick reply buttons |
| contact | string | No | An object containing contact details. This field is used to upsert the contact matched with recipient number |

**Example request body:**

```json
{
  "to": 1123456789,
  "type": "template",
  "templateName": "lto_t",
  "languageCode": "en",
  "link": "https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
  "bodyParams": [
    "John",
    "50%",
    "Thanks"
  ],
  
  "copyCodeParam": "SAVE50",
  "urlVariables": [
    "flash-sale"
  ],
  "ltoFields": {
    "unixTimestamp": 1760000000000
  }
}
```

**Response (200)** — Send LTO template:

```json
{
  "status": "success",
  "message": "Message sent",
  "data": {
    "to": "1123456789",
    "chatId": "68c3f35e139c7e8edeXXXXXX",
    "metaResponse": {
      "messaging_product": "whatsapp",
      "contacts": [
        {
          "input": "1123456789",
          "wa_id": "1123456789"
        }
      ],
      "messages": [
        {
          "id": "wamid.HBgMOTE3Njk3ODYyMTE1FQIAERgSNTEzNUUxNEQ5MEY3RkJGMEXXXX==",
          "message_status": "accepted"
        }
      ],
      "status": 200
    }
  }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://chatflow.pabbly.com/api/v1/messages \
  -H "Authorization: Bearer {{YOUR_API_KEY}}" \
  -H "Content-Type: application/json" \
  -d '{
    "to": 1123456789,
    "type": "template",
    "templateName": "lto_t",
    "languageCode": "en",
    "link": "https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
    "bodyParams": [
      "John",
      "50%",
      "Thanks"
    ],
    "copyCodeParam": "SAVE50",
    "urlVariables": [
      "flash-sale"
    ],
    "ltoFields": {
      "unixTimestamp": 1760000000000
    }
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://chatflow.pabbly.com/api/v1/messages')
request = Net::HTTP::Post.new(uri)
request['Authorization'] = 'Bearer {{YOUR_API_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"to\":1123456789,\"type\":\"template\",\"templateName\":\"lto_t\",\"languageCode\":\"en\",\"link\":\"https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\"bodyParams\":[\"John\",\"50%\",\"Thanks\"],\"copyCodeParam\":\"SAVE50\",\"urlVariables\":[\"flash-sale\"],\"ltoFields\":{\"unixTimestamp\":1760000000000}}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests

response = requests.post(
    'https://chatflow.pabbly.com/api/v1/messages',
    headers={'Authorization': 'Bearer {{YOUR_API_KEY}}'},
    json={
    'to': 1123456789,
    'type': 'template',
    'templateName': 'lto_t',
    'languageCode': 'en',
    'link': 'https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D',
    'bodyParams': [
        'John',
        '50%',
        'Thanks'
    ],
    'copyCodeParam': 'SAVE50',
    'urlVariables': [
        'flash-sale'
    ],
    'ltoFields': {
        'unixTimestamp': 1760000000000
    }
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://chatflow.pabbly.com/api/v1/messages');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Authorization: Bearer {{YOUR_API_KEY}}', 'Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"to":1123456789,"type":"template","templateName":"lto_t","languageCode":"en","link":"https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D","bodyParams":["John","50%","Thanks"],"copyCodeParam":"SAVE50","urlVariables":["flash-sale"],"ltoFields":{"unixTimestamp":1760000000000}}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://chatflow.pabbly.com/api/v1/messages"))
    .header("Authorization", "Bearer {{YOUR_API_KEY}}")
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"to\":1123456789,\"type\":\"template\",\"templateName\":\"lto_t\",\"languageCode\":\"en\",\"link\":\"https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\"bodyParams\":[\"John\",\"50%\",\"Thanks\"],\"copyCodeParam\":\"SAVE50\",\"urlVariables\":[\"flash-sale\"],\"ltoFields\":{\"unixTimestamp\":1760000000000}}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const response = await fetch('https://chatflow.pabbly.com/api/v1/messages', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer {{YOUR_API_KEY}}',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "to": 1123456789,
    "type": "template",
    "templateName": "lto_t",
    "languageCode": "en",
    "link": "https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
    "bodyParams": [
      "John",
      "50%",
      "Thanks"
    ],
    "copyCodeParam": "SAVE50",
    "urlVariables": [
      "flash-sale"
    ],
    "ltoFields": {
      "unixTimestamp": 1760000000000
    }
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"to\":1123456789,\"type\":\"template\",\"templateName\":\"lto_t\",\"languageCode\":\"en\",\"link\":\"https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\"bodyParams\":[\"John\",\"50%\",\"Thanks\"],\"copyCodeParam\":\"SAVE50\",\"urlVariables\":[\"flash-sale\"],\"ltoFields\":{\"unixTimestamp\":1760000000000}}")
    req, _ := http.NewRequest("POST", "https://chatflow.pabbly.com/api/v1/messages", payload)
    req.Header.Set("Content-Type", "application/json")
    req.Header.Set("Authorization", "Bearer {{YOUR_API_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://chatflow.pabbly.com/api/v1/messages");
request.Headers.TryAddWithoutValidation("Authorization", "Bearer {{YOUR_API_KEY}}");
request.Content = new StringContent("{\"to\":1123456789,\"type\":\"template\",\"templateName\":\"lto_t\",\"languageCode\":\"en\",\"link\":\"https://images.unsplash.com/photo-1772223610205-0a8f53d83b42?q=80&w=687&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D\",\"bodyParams\":[\"John\",\"50%\",\"Thanks\"],\"copyCodeParam\":\"SAVE50\",\"urlVariables\":[\"flash-sale\"],\"ltoFields\":{\"unixTimestamp\":1760000000000}}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Messages:**

- [POST /messages — Send Text template](/chatflow/messages/send-text-template)
- [POST /messages — Send Media based template](/chatflow/messages/send-media-based-template)
- [POST /messages — Send Authentication template](/chatflow/messages/send-authentication-template)
- [POST /messages — Send CTA/Buttons template](/chatflow/messages/send-cta-buttons-template)
- [POST /messages — Send Carousel template](/chatflow/messages/send-carousel-template)
- [POST /messages — Send Text Message](/chatflow/messages/send-text-message)
- [POST /messages — Send Image Message](/chatflow/messages/send-image-message)
- [POST /messages — Send Audio Message](/chatflow/messages/send-audio-message)
- [POST /messages — Send Video Message](/chatflow/messages/send-video-message)
- [POST /messages — Send Document Message](/chatflow/messages/send-document-message)
- [POST /messages — Send Single Product Message](/chatflow/messages/send-single-product-message)
- [POST /messages — Send Multi Product Message](/chatflow/messages/send-multi-product-message)
- [POST /messages — Send Catalog Message](/chatflow/messages/send-catalog-message)
- [POST /messages — Send List Message](/chatflow/messages/send-list-message)
- [POST /messages — Send CTA URL Message](/chatflow/messages/send-cta-url-message)
- [POST /messages — Send Address Request Message](/chatflow/messages/send-address-request-message)
- [POST /messages — Send Location Request Message](/chatflow/messages/send-location-request-message)

