Send Template Message (Phone Number)
Send Template Messages
Send Template Message (Number)
Send a WhatsApp template message to a contact using their phone number. If the contact doesn’t exist, it will be automatically created. Templates can include text/media headers, body with variables, footers, and buttons.
POST
Send Template Message (Phone Number)
Description
This endpoint allows you to send WhatsApp template messages to a contact using their phone number. If the contact doesn’t exist in your workspace, it will be automatically created. Templates can include various components such as headers (text/media), body text with variables, footers, and buttons.Template Components
Templates may contain the following components:- Header: Text (with variables) or Media (image, video, document)
- Body: Message text with dynamic variables (
{{1}},{{2}}, etc.) - Footer: Static footer text
- Buttons: URL buttons (with variables), phone buttons, or quick reply buttons
Request Payload Structure
Basic Structure
Examples by Template Type
1. Simple Body-Only Template
For templates with only body text and no variables:2. Body with Variables
Template body:"Hello \{\{1\}\}, your order \{\{2\}\} is confirmed!"
- Maximum 20 variables in body
- Each variable max 1000 characters
- Total body length (with variables) max 1024 characters
- Authentication templates: variables max 11 characters, no links allowed
3. Text Header with Variables
Template header:"Welcome \{\{1\}\}!"
- Maximum 1 variable in text header
- Variable max 60 characters
- Total header length (with variables) max 60 characters
4. Image Header Template
Option A: Using Image URL (JSON)
Option B: Uploading Image File (multipart/form-data)
- Allowed types: jpg, jpeg, png
- Maximum size: 5 MB (5120 KB)
5. Video Header Template
Using Video URL
Uploading Video File
- Allowed type: video/mp4
- Maximum size: 16 MB (16384 KB)
6. Document Header Template
Using Document URL
Uploading Document File
- Allowed type: application/pdf
- Maximum size: 30 MB (30720 KB)
7. Authentication/OTP Template
For one-time password templates:- Variables max 11 characters
- No links allowed in variables
8. URL Button with Variables
Template with dynamic URL button:https://example.com/promo/\{\{1\}\}
- Each URL button variable max 2000 characters
- Number of variables must match template definition
9. Multiple URL Buttons with Variables
For templates with multiple URL buttons:10. Complex Template (All Components)
Image header + body variables + URL button with variable:Phone Number Format
The phone number in the URL should be in international format without the+ symbol:
- ✅ Correct:
14155552671(USA),447911123456(UK),919876543210(India) - ❌ Incorrect:
+14155552671,+44 7911 123456,(415) 555-2671
Media File Requirements
Image Header
- Required: When template has image header
- Allowed types: jpg, jpeg, png
- Maximum size: 5 MB (5120 KB)
Video Header
- Required: When template has video header
- Allowed type: mp4
- Maximum size: 16 MB (16384 KB)
Document Header
- Required: When template has document header
- Allowed type: PDF
- Maximum size: 30 MB (30720 KB)
Complete Example with cURL
Auto-Contact Creation
When sending to a number that doesn’t exist in your workspace:- The system validates the phone number format
- Automatically creates a new contact with:
- Name: “Unknown” (can be updated later)
- WhatsApp number: The provided number
- Country: Auto-detected from phone number
- Timezone: Set based on country
- Sends the template message to the newly created contact
Error Responses
Invalid Phone Number
Invalid Template ID
Missing Required Variables
Variable Count Mismatch
Body Text Too Long
Invalid Media File
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
ID of the workspace.
WhatsApp phone number in international format without + symbol (e.g., 14155552671 for US, 447911123456 for UK).
Pattern:
^[1-9][0-9]{7,14}$Example:
"14155552671"