curl -X POST https://tawked.com/v1/whatsapp/templates \
-H "Authorization: Bearer tk_live_xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: document_attached-ar" \
-d '{
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
}'const res = await fetch("https://tawked.com/v1/whatsapp/templates", {
method: "POST",
headers: {
Authorization: "Bearer tk_live_xxxxxxxxxxxxxxxxxxxx",
"Content-Type": "application/json",
"Idempotency-Key": "document_attached-ar",
},
body: JSON.stringify({
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
}),
});
const data = await res.json();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://tawked.com/v1/whatsapp/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([
'name' => '<string>',
'language' => '<string>',
'category' => '<string>',
'body' => '<string>',
'header' => '<string>',
'header_format' => '<string>',
'header_sample_url' => '<string>',
'footer' => '<string>',
'buttons' => '<array>',
'examples' => [
]
]),
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;
}import requests
res = requests.post(
"https://tawked.com/v1/whatsapp/templates",
headers={"Authorization": "Bearer tk_live_xxxxxxxxxxxxxxxxxxxx", "Idempotency-Key": "document_attached-ar"},
json={
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
},
)
data = res.json(){
"id": "7100",
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"status": "PENDING"
}Create a template
For a connected app’s key alone: an application’s own key, full access included, answers 403 insufficient_scope, and writes its templates in the console. Submits a template to Meta’s review under the rules of the console’s editor, and answers Meta’s id, the category as Meta filed it and the status (PENDING at first, usually). The template opens with a text header or none, or, with header_format and header_sample_url, with an image or a PDF document; the example is an invoice sent when a customer pays. Any field outside the ones below is ignored. A refused field answers 400 invalid_request with fields naming it and errors giving each field’s reasons; what Meta refuses after that answers 422 template_refused with Meta’s own sentence.
curl -X POST https://tawked.com/v1/whatsapp/templates \
-H "Authorization: Bearer tk_live_xxxxxxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: document_attached-ar" \
-d '{
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
}'const res = await fetch("https://tawked.com/v1/whatsapp/templates", {
method: "POST",
headers: {
Authorization: "Bearer tk_live_xxxxxxxxxxxxxxxxxxxx",
"Content-Type": "application/json",
"Idempotency-Key": "document_attached-ar",
},
body: JSON.stringify({
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
}),
});
const data = await res.json();<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://tawked.com/v1/whatsapp/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([
'name' => '<string>',
'language' => '<string>',
'category' => '<string>',
'body' => '<string>',
'header' => '<string>',
'header_format' => '<string>',
'header_sample_url' => '<string>',
'footer' => '<string>',
'buttons' => '<array>',
'examples' => [
]
]),
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;
}import requests
res = requests.post(
"https://tawked.com/v1/whatsapp/templates",
headers={"Authorization": "Bearer tk_live_xxxxxxxxxxxxxxxxxxxx", "Idempotency-Key": "document_attached-ar"},
json={
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"header_format": "DOCUMENT",
"header_sample_url": "https://flowers.example/samples/contract-sample.pdf",
"body": "مرحبًا {{name}}، أرفقنا لك {{document}} في هذه الرسالة.",
"footer": "متجر الورد",
"examples": {
"body:name": "سارة",
"body:document": "عقد الاشتراك"
}
},
)
data = res.json(){
"id": "7100",
"name": "document_attached",
"language": "ar",
"category": "UTILITY",
"status": "PENDING"
}Authorizations
Authorization: Bearer . An application key (tk_live_, tk_test_) has full access, which covers every product and any product added later, or custom access, chosen when the key is created: one or more of the scopes verify:check, verify:send (includes verify:check), notifications:read, notifications:send (includes notifications:read), email:read, email:send (includes email:read), email:manage (includes email:send), webhooks:manage, email:inbound, notifications:templates (includes notifications:read), chat:menus, chat:attendant. No key made on the API keys page holds notifications:templates, full access included: the three template writes answer such a key 403 insufficient_scope. A connected app's key holds it. Nor chat:menus: the five conversation menu operations answer such a key 403 insufficient_scope, and a connected app's key holds it once the client approved it. Nor chat:attendant: the five auto-attendant operations answer such a key 403 insufficient_scope too, and a connected app's key holds it once the client approved it. email:manage and webhooks:manage are held only by a key someone chose them for: a full-access key, old or new, never holds them. email:inbound, which reads, deletes and forwards received e-mail, is opt-in on every key, full access included: a key holds it only when it was turned on when the key was created. A call outside the key's access answers 403 insufficient_scope and names the scope it needs in the WWW-Authenticate response header. A partner key (tk_partner_) always has full access. Whatever its access, a key is a server-side secret.
Headers
A 1 to 128 printable-ASCII-character key you generate, scoped to your API key. Replaying it with the same request answers the original 2xx unchanged, with the response header Idempotent-Replayed: true, and runs nothing again; the same key with another request answers 409 idempotency_key_reused, and a request still in flight 409 idempotency_in_progress. A refused request is never stored, so a corrected retry under the same key runs. Keys expire after 24 hours.
Body
Up to 1024 characters. Placeholders are all named ({{name}}, lowercase) or all numbered ({{1}}, {{2}} in order), never at the very start or end of the text. A placeholder's name is at most 20 characters ({{start_date}}, not {{subscription_start_date}}): Meta approves a longer one but refuses every message from it, so it is refused as placeholderName.
What the template opens with: TEXT (the default, for a text header or none), IMAGE or DOCUMENT (a PDF: an invoice, a contract, an attendance sheet). Each message to an IMAGE or DOCUMENT template carries its own file in header.image or header.document when it is sent. Any other value answers 400 invalid_request with headerFormatInvalid. On an edit of a template that opens with an image or a document, send it again: an edit without it answers 409 template_not_editable with MEDIA_HEADER, so an edit written for text never drops the file; TEXT makes it a text template.
An https link to the sample Meta reviews the template with: a PDF for DOCUMENT, a JPG or PNG for IMAGE, at most 5 MB (Tawked's limit). Tawked downloads it once from a public address (at most 3 redirects, 8 seconds) and uploads it to Meta; the sample is for the review only. Required on a creation with IMAGE or DOCUMENT; optional on an edit, which keeps the sample Meta already holds when it is left out. A refusal answers 400 invalid_request naming header_sample_url, with headerSampleMissing (no link for an IMAGE or DOCUMENT creation), headerSampleUnreachable (not https, a private address, an error status, a timeout), headerSampleInvalid (not a PDF for DOCUMENT, not a JPG or PNG for IMAGE) or headerSampleTooLarge (over 5 MB).
Up to 10 objects, each with a text of up to 25 characters: { "type": "QUICK_REPLY", "text" }, { "type": "URL", "text", "url" } (https, optionally ending in {{1}}; two at most) or { "type": "PHONE_NUMBER", "text", "phone_number" } (E.164; one at most). Quick replies sit together, before or after the other buttons.