Sync Templates
Templates
Sync Templates
Synchronize templates in the specified workspace.
POST
Sync Templates
Overview
Synchronize template statuses from Meta (WhatsApp Business API provider). Updates all pending templates with their current approval status.This endpoint only syncs templates with
PENDING status. It fetches the latest status from Meta and updates your local database.How It Works
- Checks if workspace has any templates with
status: PENDING - Fetches all templates from Meta’s API
- Matches templates by
provider_id - Updates local template statuses (
APPROVED,REJECTED, etc.)
Response
Success (200 OK)
No Pending Templates (404)
Sync Failed (500)
When to Use
After Template Creation
Sync after creating templates to check if they’ve been approved
After Template Update
Check status after updating existing templates
Periodic Checks
Run periodic syncs (e.g., every 30 minutes) for pending templates
Before Sending Messages
Ensure templates are approved before attempting to send
Status Transitions
Example Usage
cURL
JavaScript
Python
Workflow Example
1
Create Template
Create a new template via POST /templatesResponse:
status: "PENDING"2
Wait for Review
Meta typically reviews templates within 5-30 minutes
3
Sync Status
Call sync endpoint to update status
4
Check Result
Use GET /templates to verify new statusPossible results:
APPROVED or REJECTEDBest Practices
Automatic Sync Schedule
Automatic Sync Schedule
Set up a background job to sync every 30 minutes:
Handle Failures Gracefully
Handle Failures Gracefully
Only Sync When Needed
Only Sync When Needed
Check for pending templates before syncing: