Lewati ke konten

create_template

POST
/v1/{target_id}/templates
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.

target_id
required
string

The Target Identifier. Accepts:

  1. Virtual Phone Number ID (Subscription) -> Creates a Virtual Template (Broadcast).
  2. Meta WABA ID -> Creates on specific WABA.
  3. Meta Phone Number ID -> Resolves WABA and creates there.
Media type application/json

Request to create a new WhatsApp template.

object
allow_category_change

When true, Meta may move the template to the category it detects (e.g. UTILITY -> MARKETING) instead of rejecting it.

boolean
category
required

MARKETING, UTILITY or AUTHENTICATION.

string
Example
MARKETING
components
required

Meta 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.

Array<object>
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"
}
]
}
]
language
required

Meta language code, e.g. “id”, “en”, “en_US”.

string
Example
en_US
message_send_ttl_seconds

Optional. The time-to-live in seconds for messages sent using this template.

integer | null format: int32
Example
3600
name
required

Template name: lowercase letters, digits and underscores only.

string
Example
seasonal_promo
parameter_format

Optional. The parameter format for template variables (‘POSITIONAL’ or ‘NAMED’).

string | null
Example
POSITIONAL

Template accepted and queued for submission to Meta (status PENDING).

Media type application/json
object
id
required

Template id. For a virtual phone number target this is the virtual template id.

string
status
required

Always PENDING at creation; the final status comes via the template.status webhook.

string
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.