# POST /messages — Send CTA/Buttons template

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

Prerequisites: You need to create a template with CTA/Buttons through Pabbly Chatflow or WhatsApp Manager. CTA/Buttons are interactive elements embedded in various templates that enable recipients to take direct actions without leaving the messaging interface. Hit the API with the POST method and fill the following data according to your requirements to send a CTA/Buttons 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" incase you want to send template message |
| templateName | string | Yes | Name of template you want to send |
| urlVariables | array | No | Specify path variables or query parameters you want to concatenate in the URL. This is only useful if the template has Dynamic URL CTA Buttons |
| copyCodeParam | string | No | Code to send with the template, includes a copy code button |
| quickReplies | array | No | List of quick reply buttons to include with the message, allowing users to respond with predefined replies |
| 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": "summer_time",
    "urlVariables": ["?tab=repositories"],
    "copyCodeParam": "QWEASD",
    "quickReplies": ["Yes", "No"]
}
```

**Response (200)** — Send CTA/Buttons template:

```json
{
    "status": "success",
    "message": "Message sent",
    "data": {
        "to": "9176978XXXXX",
        "chatId": "67762380b9e6371dXXXXXXXX",
        "metaResponse": {
            "messaging_product": "whatsapp",
            "contacts": [
                {
                    "input": "9176978XXXXX",
                    "wa_id": "9176978XXXXX"
                }
            ],
            "messages": [
                {
                    "id": "wamid.HBgMOTE3Njk3ODYyMTE1FQIAERgSQTQwMTBFQkEwNDJDXXXXXXXXXX==",
                    "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": "summer_time",
    "urlVariables": [
      "?tab=repositories"
    ],
    "copyCodeParam": "QWEASD",
    "quickReplies": [
      "Yes",
      "No"
    ]
  }'
```

_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\":\"summer_time\",\"urlVariables\":[\"?tab=repositories\"],\"copyCodeParam\":\"QWEASD\",\"quickReplies\":[\"Yes\",\"No\"]}"

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': 'summer_time',
    'urlVariables': [
        '?tab=repositories'
    ],
    'copyCodeParam': 'QWEASD',
    'quickReplies': [
        'Yes',
        'No'
    ]
},
)

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":"summer_time","urlVariables":["?tab=repositories"],"copyCodeParam":"QWEASD","quickReplies":["Yes","No"]}');

$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\":\"summer_time\",\"urlVariables\":[\"?tab=repositories\"],\"copyCodeParam\":\"QWEASD\",\"quickReplies\":[\"Yes\",\"No\"]}"));

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": "summer_time",
    "urlVariables": [
      "?tab=repositories"
    ],
    "copyCodeParam": "QWEASD",
    "quickReplies": [
      "Yes",
      "No"
    ]
  }),
});

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\":\"summer_time\",\"urlVariables\":[\"?tab=repositories\"],\"copyCodeParam\":\"QWEASD\",\"quickReplies\":[\"Yes\",\"No\"]}")
    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\":\"summer_time\",\"urlVariables\":[\"?tab=repositories\"],\"copyCodeParam\":\"QWEASD\",\"quickReplies\":[\"Yes\",\"No\"]}");
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 Carousel template](/chatflow/messages/send-carousel-template)
- [POST /messages — Send LTO template](/chatflow/messages/send-lto-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)

