Send a marketing message
Send a WhatsApp marketing template message.
Use to for phone numbers. Use recipient for a BSUID or parent BSUID.
If both are present, the phone number in to takes precedence.
curl --request POST \
--url https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"recipient": "US.13491208655302741918",
"type": "template",
"template": {
"name": "promo_template",
"language": {
"code": "en_US"
}
}
}
'import requests
url = "https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages"
payload = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"recipient": "US.13491208655302741918",
"type": "template",
"template": {
"name": "promo_template",
"language": { "code": "en_US" }
}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messaging_product: 'whatsapp',
recipient_type: 'individual',
recipient: 'US.13491208655302741918',
type: 'template',
template: {name: 'promo_template', language: {code: 'en_US'}}
})
};
fetch('https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages', 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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages",
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([
'messaging_product' => 'whatsapp',
'recipient_type' => 'individual',
'recipient' => 'US.13491208655302741918',
'type' => 'template',
'template' => [
'name' => 'promo_template',
'language' => [
'code' => 'en_US'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages"
payload := strings.NewReader("{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "US.13491208655302741918",
"user_id": "US.13491208655302741918"
}
],
"messages": [
{
"id": "wamid.HBgNMTU1NTE0OTU5Nzg1FQIAERgSMDhGRjdCMDEyOTcxQzFFQkFBAA==",
"message_status": "accepted"
}
]
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}Authorizations
Project API key for authentication. This is the recommended authentication method.
Get your API key from the Kapso dashboard under Integrations > API keys.
Path Parameters
WhatsApp Business Phone Number ID
Body
- Option 1
- Option 2
Always "whatsapp"
whatsapp "whatsapp"
Recipient phone number. Use recipient for BSUID sends.
"15551234567"
Marketing messages must use a WhatsApp template.
template "template"
Show child attributes
Show child attributes
Marketing messages are sent to individual recipients.
individual Arbitrary string for tracking (echoed in webhooks)
512Recipient BSUID or parent BSUID. If to is also present, the phone number in to takes precedence.
"US.13491208655302741918"
Was this page helpful?
curl --request POST \
--url https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"messaging_product": "whatsapp",
"recipient_type": "individual",
"recipient": "US.13491208655302741918",
"type": "template",
"template": {
"name": "promo_template",
"language": {
"code": "en_US"
}
}
}
'import requests
url = "https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages"
payload = {
"messaging_product": "whatsapp",
"recipient_type": "individual",
"recipient": "US.13491208655302741918",
"type": "template",
"template": {
"name": "promo_template",
"language": { "code": "en_US" }
}
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
messaging_product: 'whatsapp',
recipient_type: 'individual',
recipient: 'US.13491208655302741918',
type: 'template',
template: {name: 'promo_template', language: {code: 'en_US'}}
})
};
fetch('https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages', 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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages",
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([
'messaging_product' => 'whatsapp',
'recipient_type' => 'individual',
'recipient' => 'US.13491208655302741918',
'type' => 'template',
'template' => [
'name' => 'promo_template',
'language' => [
'code' => 'en_US'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages"
payload := strings.NewReader("{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
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.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.kapso.ai/meta/whatsapp/v24.0/{phone_number_id}/marketing_messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"messaging_product\": \"whatsapp\",\n \"recipient_type\": \"individual\",\n \"recipient\": \"US.13491208655302741918\",\n \"type\": \"template\",\n \"template\": {\n \"name\": \"promo_template\",\n \"language\": {\n \"code\": \"en_US\"\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"messaging_product": "whatsapp",
"contacts": [
{
"input": "US.13491208655302741918",
"user_id": "US.13491208655302741918"
}
],
"messages": [
{
"id": "wamid.HBgNMTU1NTE0OTU5Nzg1FQIAERgSMDhGRjdCMDEyOTcxQzFFQkFBAA==",
"message_status": "accepted"
}
]
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}{
"error": {
"message": "Invalid phone number format",
"type": "OAuthException",
"code": 400,
"error_subcode": 1001,
"fbtrace_id": "AXk7s_8dR4eVHp9Kq2MmNlO"
}
}
