curl --request POST \
--url https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "14155552671",
"from": "14155552672",
"template": {
"name": "order_update",
"language": "en_US",
"variables": {
"header": {
"1": "#1042"
},
"body": {
"1": "Jane",
"2": "Friday"
}
}
}
}
'import requests
url = "https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template"
payload = {
"to": "14155552671",
"from": "14155552672",
"template": {
"name": "order_update",
"language": "en_US",
"variables": {
"header": { "1": "#1042" },
"body": {
"1": "Jane",
"2": "Friday"
}
}
}
}
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({
to: '14155552671',
from: '14155552672',
template: {
name: 'order_update',
language: 'en_US',
variables: {header: {'1': '#1042'}, body: JSON.stringify({'1': 'Jane', '2': 'Friday'})}
}
})
};
fetch('https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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([
'to' => '14155552671',
'from' => '14155552672',
'template' => [
'name' => 'order_update',
'language' => 'en_US',
'variables' => [
'header' => [
'1' => '#1042'
],
'body' => [
'1' => 'Jane',
'2' => 'Friday'
]
]
]
]),
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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template"
payload := strings.NewReader("{\n \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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 \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"messageId": "<string>",
"conversationId": "<string>",
"to": "<string>"
}Send a WhatsApp template message
Sends an approved WhatsApp template to a recipient from one of the agent’s connected phone numbers. Recipients are identified by phone number only — no user ID is required. A Chatbase user is resolved or created from the to number automatically, and their reply flows through the agent’s regular WhatsApp pipeline. The message is also appended to that conversation, unless a human has taken it over or it has ended — see conversationId in the response.
curl --request POST \
--url https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"to": "14155552671",
"from": "14155552672",
"template": {
"name": "order_update",
"language": "en_US",
"variables": {
"header": {
"1": "#1042"
},
"body": {
"1": "Jane",
"2": "Friday"
}
}
}
}
'import requests
url = "https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template"
payload = {
"to": "14155552671",
"from": "14155552672",
"template": {
"name": "order_update",
"language": "en_US",
"variables": {
"header": { "1": "#1042" },
"body": {
"1": "Jane",
"2": "Friday"
}
}
}
}
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({
to: '14155552671',
from: '14155552672',
template: {
name: 'order_update',
language: 'en_US',
variables: {header: {'1': '#1042'}, body: JSON.stringify({'1': 'Jane', '2': 'Friday'})}
}
})
};
fetch('https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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([
'to' => '14155552671',
'from' => '14155552672',
'template' => [
'name' => 'order_update',
'language' => 'en_US',
'variables' => [
'header' => [
'1' => '#1042'
],
'body' => [
'1' => 'Jane',
'2' => 'Friday'
]
]
]
]),
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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template"
payload := strings.NewReader("{\n \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\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://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/template")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.chatbase.co/api/v2/agents/{agentId}/whatsapp/messages/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 \"to\": \"14155552671\",\n \"from\": \"14155552672\",\n \"template\": {\n \"name\": \"order_update\",\n \"language\": \"en_US\",\n \"variables\": {\n \"header\": {\n \"1\": \"#1042\"\n },\n \"body\": {\n \"1\": \"Jane\",\n \"2\": \"Friday\"\n }\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"messageId": "<string>",
"conversationId": "<string>",
"to": "<string>"
}Path Parameters
Body
Recipient phone number in international format (digits with country code, + and separators are tolerated). The phone number is the recipient identity: no user ID is needed — a Chatbase user is automatically resolved or created from this number (matching an existing contact with the same phone when one exists), and replies continue in that user’s conversation.
1"14155552671"
Response
The message was accepted by WhatsApp