Send template message
curl --request POST \
--url https://api.heyy.io/v3/messages/send_template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"chat": {
"chatId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"messageTemplate": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"variables": {}
},
"scheduledAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.heyy.io/v3/messages/send_template"
payload = {
"chat": { "chatId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" },
"messageTemplate": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"variables": {}
},
"scheduledAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chat: {chatId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'},
messageTemplate: {
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
attachments: [
{
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
fileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
],
variables: {}
},
scheduledAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.heyy.io/v3/messages/send_template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.heyy.io/v3/messages/send_template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat' => [
'chatId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'messageTemplate' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'attachments' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'fileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'variables' => [
]
],
'scheduledAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.heyy.io/v3/messages/send_template"
payload := strings.NewReader("{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.heyy.io/v3/messages/send_template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heyy.io/v3/messages/send_template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"chatId": "<string>",
"channelId": "<string>",
"type": "message",
"sender": "outbound",
"sources": [
{
"type": "campaign",
"campaignExecutionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"status": "none",
"scheduledAt": "<string>",
"content": {
"body": "<string>",
"attachments": [
{
"id": "<string>",
"type": "image",
"file": {
"id": "<string>",
"createdAt": "<string>",
"type": "image",
"name": "<string>",
"contentType": "<string>",
"url": "<string>",
"size": 123
}
}
],
"header": "<string>",
"footer": "<string>",
"payload": "<string>"
},
"forwarded": true,
"reactions": [
{
"sender": "outbound",
"text": "<string>",
"timestamp": "<string>",
"userId": "<string>"
}
],
"errors": [
{
"messageKey": "<string>",
"message": "<string>",
"vendorError": {
"code": 123,
"title": "<string>",
"type": "<string>",
"message": "<string>",
"errorData": {
"messagingProduct": "<string>",
"details": "<string>"
},
"fbtraceId": "<string>"
}
}
],
"history": [
{
"event": "status_update",
"newStatus": "none",
"timestamp": "<string>"
}
],
"vendorId": "<string>",
"timestamp": "<string>",
"vendorDetails": {
"whatsapp": {
"context": {
"frequentlyForwarded": true,
"referredProduct": {
"catalogId": "<string>",
"productRetailerId": "<string>"
}
},
"order": {
"catalogId": "<string>",
"productItems": [
{
"productRetailerId": "<string>",
"quantity": "<string>",
"itemPrice": "<string>",
"currency": "<string>"
}
]
}
},
"instagram": {
"commentId": "<string>"
},
"messenger": {
"commentId": "<string>"
}
},
"metadata": {
"campaignContactId": "<string>",
"campaignExecutionId": "<string>",
"assignment": {
"userId": "<string>",
"teamId": "<string>"
},
"exitRoute": {
"id": "<string>",
"name": "<string>"
},
"summary": {
"text": "<string>",
"messageCount": 123,
"anchorMessageId": "<string>",
"anchorTimestamp": "2023-11-07T05:31:56Z",
"anchorType": "summary"
}
},
"isSensitive": true,
"aiGenerationId": "<string>",
"replyTo": {
"id": "<string>",
"vendorId": "<string>",
"sender": "outbound",
"type": "text",
"timestamp": "<string>",
"text": "<string>"
},
"chat": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"status": "open",
"isUnread": true,
"openUntil": "<string>",
"unreadCount": 123,
"channelId": "<string>",
"contactId": "<string>",
"handleId": "<string>",
"latestMessage": {
"id": "<string>",
"vendorId": "<string>",
"sender": "outbound",
"type": "text",
"timestamp": "<string>",
"text": "<string>"
},
"assignedUserId": "<string>",
"assignedTeamId": "<string>",
"isSensitive": true
}
}
}{
"success": false,
"error": {
"messageKey": "invalid_body_params",
"message": "Invalid body params",
"invalidParams": {
"email": {
"key": "invalid_string",
"message": "Invalid email"
}
}
}
}{
"success": false,
"error": {
"messageKey": "unauthorized",
"message": "Unauthorized"
}
}{
"success": false,
"error": {
"messageKey": "insufficient_billing_plan",
"message": "Insufficient billing plan"
}
}{
"success": false,
"error": {
"messageKey": "forbidden",
"message": "Forbidden"
}
}{
"success": false,
"error": {
"messageKey": "contact_not_found",
"message": "Contact not found"
}
}{
"success": false,
"error": {
"messageKey": "too_many_requests",
"message": "Too many requests. Limit is applied per minute per tenant. Please retry after the time indicated by the X-RateLimit-Reset header."
}
}{
"success": false,
"error": {
"messageKey": "internal_error",
"message": "Oops! Something went wrong"
}
}Message
Send template message
Send a template message to a contact on a connected channel.
POST
/
messages
/
send_template
Send template message
curl --request POST \
--url https://api.heyy.io/v3/messages/send_template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"chat": {
"chatId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"messageTemplate": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"variables": {}
},
"scheduledAt": "2023-11-07T05:31:56Z"
}
'import requests
url = "https://api.heyy.io/v3/messages/send_template"
payload = {
"chat": { "chatId": "3c90c3cc-0d44-4b50-8888-8dd25736052a" },
"messageTemplate": {
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"attachments": [
{
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"fileId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"variables": {}
},
"scheduledAt": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chat: {chatId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'},
messageTemplate: {
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
attachments: [
{
id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
fileId: '3c90c3cc-0d44-4b50-8888-8dd25736052a'
}
],
variables: {}
},
scheduledAt: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.heyy.io/v3/messages/send_template', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.heyy.io/v3/messages/send_template",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'chat' => [
'chatId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
],
'messageTemplate' => [
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'attachments' => [
[
'id' => '3c90c3cc-0d44-4b50-8888-8dd25736052a',
'fileId' => '3c90c3cc-0d44-4b50-8888-8dd25736052a'
]
],
'variables' => [
]
],
'scheduledAt' => '2023-11-07T05:31:56Z'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.heyy.io/v3/messages/send_template"
payload := strings.NewReader("{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.heyy.io/v3/messages/send_template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.heyy.io/v3/messages/send_template")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"chat\": {\n \"chatId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n },\n \"messageTemplate\": {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"attachments\": [\n {\n \"id\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\",\n \"fileId\": \"3c90c3cc-0d44-4b50-8888-8dd25736052a\"\n }\n ],\n \"variables\": {}\n },\n \"scheduledAt\": \"2023-11-07T05:31:56Z\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"chatId": "<string>",
"channelId": "<string>",
"type": "message",
"sender": "outbound",
"sources": [
{
"type": "campaign",
"campaignExecutionId": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"status": "none",
"scheduledAt": "<string>",
"content": {
"body": "<string>",
"attachments": [
{
"id": "<string>",
"type": "image",
"file": {
"id": "<string>",
"createdAt": "<string>",
"type": "image",
"name": "<string>",
"contentType": "<string>",
"url": "<string>",
"size": 123
}
}
],
"header": "<string>",
"footer": "<string>",
"payload": "<string>"
},
"forwarded": true,
"reactions": [
{
"sender": "outbound",
"text": "<string>",
"timestamp": "<string>",
"userId": "<string>"
}
],
"errors": [
{
"messageKey": "<string>",
"message": "<string>",
"vendorError": {
"code": 123,
"title": "<string>",
"type": "<string>",
"message": "<string>",
"errorData": {
"messagingProduct": "<string>",
"details": "<string>"
},
"fbtraceId": "<string>"
}
}
],
"history": [
{
"event": "status_update",
"newStatus": "none",
"timestamp": "<string>"
}
],
"vendorId": "<string>",
"timestamp": "<string>",
"vendorDetails": {
"whatsapp": {
"context": {
"frequentlyForwarded": true,
"referredProduct": {
"catalogId": "<string>",
"productRetailerId": "<string>"
}
},
"order": {
"catalogId": "<string>",
"productItems": [
{
"productRetailerId": "<string>",
"quantity": "<string>",
"itemPrice": "<string>",
"currency": "<string>"
}
]
}
},
"instagram": {
"commentId": "<string>"
},
"messenger": {
"commentId": "<string>"
}
},
"metadata": {
"campaignContactId": "<string>",
"campaignExecutionId": "<string>",
"assignment": {
"userId": "<string>",
"teamId": "<string>"
},
"exitRoute": {
"id": "<string>",
"name": "<string>"
},
"summary": {
"text": "<string>",
"messageCount": 123,
"anchorMessageId": "<string>",
"anchorTimestamp": "2023-11-07T05:31:56Z",
"anchorType": "summary"
}
},
"isSensitive": true,
"aiGenerationId": "<string>",
"replyTo": {
"id": "<string>",
"vendorId": "<string>",
"sender": "outbound",
"type": "text",
"timestamp": "<string>",
"text": "<string>"
},
"chat": {
"id": "<string>",
"createdAt": "2023-11-07T05:31:56Z",
"updatedAt": "2023-11-07T05:31:56Z",
"status": "open",
"isUnread": true,
"openUntil": "<string>",
"unreadCount": 123,
"channelId": "<string>",
"contactId": "<string>",
"handleId": "<string>",
"latestMessage": {
"id": "<string>",
"vendorId": "<string>",
"sender": "outbound",
"type": "text",
"timestamp": "<string>",
"text": "<string>"
},
"assignedUserId": "<string>",
"assignedTeamId": "<string>",
"isSensitive": true
}
}
}{
"success": false,
"error": {
"messageKey": "invalid_body_params",
"message": "Invalid body params",
"invalidParams": {
"email": {
"key": "invalid_string",
"message": "Invalid email"
}
}
}
}{
"success": false,
"error": {
"messageKey": "unauthorized",
"message": "Unauthorized"
}
}{
"success": false,
"error": {
"messageKey": "insufficient_billing_plan",
"message": "Insufficient billing plan"
}
}{
"success": false,
"error": {
"messageKey": "forbidden",
"message": "Forbidden"
}
}{
"success": false,
"error": {
"messageKey": "contact_not_found",
"message": "Contact not found"
}
}{
"success": false,
"error": {
"messageKey": "too_many_requests",
"message": "Too many requests. Limit is applied per minute per tenant. Please retry after the time indicated by the X-RateLimit-Reset header."
}
}{
"success": false,
"error": {
"messageKey": "internal_error",
"message": "Oops! Something went wrong"
}
}When you send a marketing message through this endpoint, you are responsible for confirming the contact is subscribed before you call it. The message will be sent even if the contact is unsubscribed. You can use the trigger automation API instead to trigger an automation where you check using a condition that the contact is subscribed.
Authorizations
Body
application/json
Was this page helpful?