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": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"chatId": "string",
"channelId": "string",
"type": "message",
"sender": "outbound",
"sources": [],
"status": "none",
"scheduledAt": "string",
"content": {
"body": "string",
"attachments": [],
"header": "string",
"footer": "string",
"payload": "string"
},
"forwarded": true,
"replyTo": {
"id": "string",
"vendorId": "string",
"sender": "outbound",
"type": "text",
"timestamp": "string",
"text": "string"
},
"reactions": [],
"errors": [],
"history": [],
"vendorId": "string",
"timestamp": "string",
"vendorDetails": {
"whatsapp": {
"context": {
"frequentlyForwarded": true,
"referredProduct": {
"catalogId": "string",
"productRetailerId": "string"
}
},
"order": {
"catalogId": "string",
"productItems": []
}
},
"instagram": {
"commentId": "string"
},
"messenger": {
"commentId": "string"
}
},
"metadata": {
"campaignContactId": "string",
"campaignExecutionId": "string"
},
"isSensitive": true,
"aiGenerationId": "string",
"chat": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"status": "open",
"isUnread": true,
"openUntil": "string",
"unreadCount": 0,
"channelId": "string",
"contactId": "string",
"contact": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"firstName": "string",
"lastName": "string",
"fullName": "string",
"isSubscribed": true,
"handles": [],
"labels": [],
"attributes": [],
"displayName": "string",
"phoneNumber": "string",
"email": "string",
"chats": [],
"metadata": {}
},
"handleId": "string",
"handle": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"type": "phone_number",
"isPrimary": true,
"value": "string",
"extra": {},
"hasChats": true
},
"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
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": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"chatId": "string",
"channelId": "string",
"type": "message",
"sender": "outbound",
"sources": [],
"status": "none",
"scheduledAt": "string",
"content": {
"body": "string",
"attachments": [],
"header": "string",
"footer": "string",
"payload": "string"
},
"forwarded": true,
"replyTo": {
"id": "string",
"vendorId": "string",
"sender": "outbound",
"type": "text",
"timestamp": "string",
"text": "string"
},
"reactions": [],
"errors": [],
"history": [],
"vendorId": "string",
"timestamp": "string",
"vendorDetails": {
"whatsapp": {
"context": {
"frequentlyForwarded": true,
"referredProduct": {
"catalogId": "string",
"productRetailerId": "string"
}
},
"order": {
"catalogId": "string",
"productItems": []
}
},
"instagram": {
"commentId": "string"
},
"messenger": {
"commentId": "string"
}
},
"metadata": {
"campaignContactId": "string",
"campaignExecutionId": "string"
},
"isSensitive": true,
"aiGenerationId": "string",
"chat": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"status": "open",
"isUnread": true,
"openUntil": "string",
"unreadCount": 0,
"channelId": "string",
"contactId": "string",
"contact": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"firstName": "string",
"lastName": "string",
"fullName": "string",
"isSubscribed": true,
"handles": [],
"labels": [],
"attributes": [],
"displayName": "string",
"phoneNumber": "string",
"email": "string",
"chats": [],
"metadata": {}
},
"handleId": "string",
"handle": {
"id": "string",
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z",
"type": "phone_number",
"isPrimary": true,
"value": "string",
"extra": {},
"hasChats": true
},
"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"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
Was this page helpful?
⌘I