Create a template
Templates
Add Template
POST
Create a template
Overview
Create a new WhatsApp message template. Templates must be approved by Meta before they can be used to send messages.Templates typically take 5-30 minutes for approval. Use the Sync endpoint to check approval status.
Request Body Schema
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Unique template name (only lowercase + underscores). |
language | string | Yes | Language code (e.g., en, es, fr). |
category | string | Yes | One of: MARKETING, UTILITY, AUTHENTICATION. |
header | object/null | No | Template header. Can be null, text, or media (image/video/document). |
body | object | Yes | Main message body. Supports variables ({{1}}, {{2}}). |
body.text | string | Yes | Message text (max 1024 chars). |
body.variables | array | Conditional | Required if variables exist in text. |
footer | string | No | Footer text (max 60 chars, no emojis). |
buttons | array | No | Interactive buttons (URL, Phone, Quick Reply). Max 3. |
unsubscribeButton | boolean | No | Show Unsubscribe button (MARKETING only). |
blockButton | boolean | No | Show Block button (MARKETING only). |
addSecurityRecommendation | boolean | Auth only | Include security warning (AUTHENTICATION only). |
codeExpirationMinutes | integer | Auth only | OTP validity period in minutes (1-1440, AUTHENTICATION only). |
copyCodeButton | boolean | Auth only | Add one-tap copy button (AUTHENTICATION only). |
Complete Examples
Example 1: Marketing Template with Image Header
Example 2: Authentication (OTP) Template
Authentication templates are auto-generated by Meta with standard security messaging. You only need to specify the three parameters above.
Example 3: Utility Template with Multiple Buttons
Example 4: Simple Text Template
Example 5: URL Button with Variable
Example 6: Video Header Template
Example 7: Document Header Template
Validation Rules
Name Rules
Name Rules
- Must be unique in workspace
- Only lowercase letters and underscores
- Examples: ✅
welcome_message,order_confirmation_v2 - Invalid: ❌
WelcomeMessage,order-confirmation,template 1
Language Codes
Language Codes
Must be valid ISO language code:
- English:
en - Spanish:
es - French:
fr - German:
de - Portuguese:
pt - Arabic:
ar - And more…
Header Rules
Header Rules
Text Header:
- Max 60 characters
- Max 1 variable:
{{1}} - Cannot start/end with variable
- Example: ✅
Welcome {{1}} - Invalid: ❌
{{1}} Welcome
- Image: JPG/PNG, max 5MB (5120KB)
- Video: MP4, max 10MB (10240KB)
- Document: PDF, max 30MB (30720KB)
Body Rules
Body Rules
- Required field
- Max 1024 characters
- Cannot start or end with variable
- Max 2 consecutive newlines (
\n\nallowed,\n\n\nnot allowed) - Variables must match: if text has
{{1}}and{{2}}, variables array must have exactly 2 items - Variables are numbered sequentially:
{{1}},{{2}},{{3}}, etc.
Footer Rules
Footer Rules
Button Rules
Button Rules
Authentication Templates
Authentication Templates
- Only 3 fields required:
addSecurityRecommendation,codeExpirationMinutes,copyCodeButton - No custom header, body, footer, or buttons
- Meta auto-generates the template content
codeExpirationMinutesrange: 1-1440 (1 min to 24 hours)
Response
Success (201 Created)
Validation Error (422)
Template Status Flow
After creation, templates go through this lifecycle:Common Validation Errors
| Error Message | Cause | Solution |
|---|---|---|
| ”not_start_or_end_with_var” | Text starts/ends with variable | Remove variable from start/end |
| ”only_one_variable” | Header has more than 1 variable | Use max 1 variable in header |
| ”Variable count mismatch” | Variables array doesn’t match placeholders | Count {{1}}, {{2}} in text and provide exact number |
| ”File too large” | Media exceeds size limit | Compress file (Image: 5MB, Video: 10MB, PDF: 30MB) |
| “Invalid phone number” | Missing country code | Add country code: +1234567890 |
| ”Template name exists” | Name already used | Choose unique name |
| ”no_more_than_two_consecutive_newlines” | Too many blank lines | Use max \n\n (2 newlines) |
Best Practices
Test Variables
Always test with actual variable values before submission
Keep It Simple
Start with basic templates, add complexity gradually
Follow Meta Guidelines
Avoid promotional language in UTILITY templates
Use Descriptive Names
Use clear names like
order_confirmation not template_1Optimize Media
Compress images/videos before upload
Plan Variables
Map out all dynamic values before creating template
Category Guidelines
- MARKETING
- UTILITY
- AUTHENTICATION
Purpose: Promotional messages, offers, announcementsCharacteristics:
- Can include unsubscribe/block buttons
- Subject to stricter Meta review
- Rate limits may apply
- Sales and promotions
- New product launches
- Event invitations
- Newsletter updates
Example cURL Request
Next Steps
After creating a template:- Wait for Review: Meta reviews templates within 5-30 minutes
- Sync Status: Use POST /templates/sync
- Check Approval: Use GET /templates to verify status
- Send Messages: Once approved, use Send Template Message
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
ID of the workspace.
Body
application/json
Example:
"login_otp_template"
Example:
"en"
Available options:
MARKETING, UTILITY, AUTHENTICATION Option 2: Text Header
- Option 1
- Option 2
Maximum string length:
60Response
Template created successfully