create_template
const url = 'https://example.com/v1/example/templates';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"allow_category_change":false,"category":"MARKETING","components":[{"type":"HEADER","format":"IMAGE","example":{"header_handle":["00000000-0000-4000-8000-000000000001"]}},{"type":"BODY","text":"Hi {{1}}, your order {{2}} has shipped.","example":{"body_text":[["Budi","ORD-1234"]]}},{"type":"BUTTONS","buttons":[{"type":"QUICK_REPLY","text":"Track order"}]}],"language":"en_US","message_send_ttl_seconds":3600,"name":"seasonal_promo","parameter_format":"POSITIONAL"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/v1/example/templates \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "allow_category_change": false, "category": "MARKETING", "components": [ { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": [ "00000000-0000-4000-8000-000000000001" ] } }, { "type": "BODY", "text": "Hi {{1}}, your order {{2}} has shipped.", "example": { "body_text": [ [ "Budi", "ORD-1234" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Track order" } ] } ], "language": "en_US", "message_send_ttl_seconds": 3600, "name": "seasonal_promo", "parameter_format": "POSITIONAL" }'Creates a WhatsApp message template and queues it for submission to Meta. The response returns immediately with status PENDING; the final status (APPROVED / REJECTED, with rejection_reason) arrives later through the template.status webhook. For IMAGE, VIDEO or DOCUMENT headers, set components[].example.header_handle[0] to either a media id returned by POST /v1/media (recommended) or a public https URL of the file. Meta upload handles are not needed: the platform uploads the file to Meta for you. When target_id is a virtual phone number, the returned id identifies the virtual template; track it through the template.status webhook.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”The Target Identifier. Accepts:
- Virtual Phone Number ID (Subscription) -> Creates a Virtual Template (Broadcast).
- Meta WABA ID -> Creates on specific WABA.
- Meta Phone Number ID -> Resolves WABA and creates there.
Request Body required
Section titled “Request Body required ”Request to create a new WhatsApp template.
object
When true, Meta may move the template to the category it detects (e.g. UTILITY -> MARKETING) instead of rejecting it.
MARKETING, UTILITY or AUTHENTICATION.
Example
MARKETINGMeta template components: HEADER (TEXT, IMAGE, VIDEO or DOCUMENT), BODY, FOOTER, BUTTONS. For a media HEADER, example.header_handle[0] is a media id from POST /v1/media or a public https URL.
object
Example
[ { "type": "HEADER", "format": "IMAGE", "example": { "header_handle": [ "00000000-0000-4000-8000-000000000001" ] } }, { "type": "BODY", "text": "Hi {{1}}, your order {{2}} has shipped.", "example": { "body_text": [ [ "Budi", "ORD-1234" ] ] } }, { "type": "BUTTONS", "buttons": [ { "type": "QUICK_REPLY", "text": "Track order" } ] }]Meta language code, e.g. “id”, “en”, “en_US”.
Example
en_USOptional. The time-to-live in seconds for messages sent using this template.
Example
3600Template name: lowercase letters, digits and underscores only.
Example
seasonal_promoOptional. The parameter format for template variables (‘POSITIONAL’ or ‘NAMED’).
Example
POSITIONALResponses
Section titled “ Responses ”Template accepted and queued for submission to Meta (status PENDING).
object
Template id. For a virtual phone number target this is the virtual template id.
Always PENDING at creation; the final status comes via the template.status webhook.
Example
{ "status": "PENDING"}Invalid request: unknown category, invalid components, or header_handle is neither a media id from POST /v1/media owned by this account nor a public https URL.
Unauthorized
Target_id not found for this account: not a virtual phone number, WABA id or phone number id you own.