Create a template
curl --request POST \
--url https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template": {
"name": "hotel_checkout_reminder",
"language": "fr",
"components": {
"body": {
"text": "Hello {{1}}, your order {{2}} is ready."
}
},
"variable_examples": {
"body": [
"John",
"ORD-123"
]
}
}
}
'import requests
url = "https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates"
payload = { "template": {
"name": "hotel_checkout_reminder",
"language": "fr",
"components": { "body": { "text": "Hello {{1}}, your order {{2}} is ready." } },
"variable_examples": { "body": ["John", "ORD-123"] }
} }
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({
template: {
name: 'hotel_checkout_reminder',
language: 'fr',
components: {body: JSON.stringify({text: 'Hello {{1}}, your order {{2}} is ready.'})},
variable_examples: {body: JSON.stringify(['John', 'ORD-123'])}
}
})
};
fetch('https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates', 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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates",
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([
'template' => [
'name' => 'hotel_checkout_reminder',
'language' => 'fr',
'components' => [
'body' => [
'text' => 'Hello {{1}}, your order {{2}} is ready.'
]
],
'variable_examples' => [
'body' => [
'John',
'ORD-123'
]
]
]
]),
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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates"
payload := strings.NewReader("{\n \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates")
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 \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "tpl_c0eaed0650f895d0196257d7",
"meta_template_id": "925378236746625",
"name": "hotel_checkout_reminder",
"category": "marketing",
"status": "draft",
"language": "fr",
"header_type": "text",
"components": {
"body": {
"text": "Hello {{1}}, your checkout is at {{2}}."
}
},
"variable_examples": {
"1": "John",
"2": "11:00"
},
"rejection_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": "Invalid or missing API key"
}{
"error": "Validation failed",
"details": {
"to": [
"can't be blank"
]
}
}Templates
Create a template
Creates the template locally and submits it to Meta for approval.
This call includes a round-trip to Meta’s API, so it may take a few seconds.
The template is returned with status pending once Meta accepts it.
POST
/
business_accounts
/
{business_account_id}
/
templates
Create a template
curl --request POST \
--url https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template": {
"name": "hotel_checkout_reminder",
"language": "fr",
"components": {
"body": {
"text": "Hello {{1}}, your order {{2}} is ready."
}
},
"variable_examples": {
"body": [
"John",
"ORD-123"
]
}
}
}
'import requests
url = "https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates"
payload = { "template": {
"name": "hotel_checkout_reminder",
"language": "fr",
"components": { "body": { "text": "Hello {{1}}, your order {{2}} is ready." } },
"variable_examples": { "body": ["John", "ORD-123"] }
} }
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({
template: {
name: 'hotel_checkout_reminder',
language: 'fr',
components: {body: JSON.stringify({text: 'Hello {{1}}, your order {{2}} is ready.'})},
variable_examples: {body: JSON.stringify(['John', 'ORD-123'])}
}
})
};
fetch('https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates', 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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates",
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([
'template' => [
'name' => 'hotel_checkout_reminder',
'language' => 'fr',
'components' => [
'body' => [
'text' => 'Hello {{1}}, your order {{2}} is ready.'
]
],
'variable_examples' => [
'body' => [
'John',
'ORD-123'
]
]
]
]),
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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates"
payload := strings.NewReader("{\n \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\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://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\n ]\n }\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://whatsrb.com/api/v1/business_accounts/{business_account_id}/templates")
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 \"template\": {\n \"name\": \"hotel_checkout_reminder\",\n \"language\": \"fr\",\n \"components\": {\n \"body\": {\n \"text\": \"Hello {{1}}, your order {{2}} is ready.\"\n }\n },\n \"variable_examples\": {\n \"body\": [\n \"John\",\n \"ORD-123\"\n ]\n }\n }\n}"
response = http.request(request)
puts response.read_body{
"data": {
"id": "tpl_c0eaed0650f895d0196257d7",
"meta_template_id": "925378236746625",
"name": "hotel_checkout_reminder",
"category": "marketing",
"status": "draft",
"language": "fr",
"header_type": "text",
"components": {
"body": {
"text": "Hello {{1}}, your checkout is at {{2}}."
}
},
"variable_examples": {
"1": "John",
"2": "11:00"
},
"rejection_reason": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}
}{
"error": "Invalid or missing API key"
}{
"error": "Validation failed",
"details": {
"to": [
"can't be blank"
]
}
}
