Skip to main content
Templates are pre-approved message formats required for initiating WhatsApp conversations outside the 24-hour window.

Create Template

$result = $client->templates->create([
    'name' => 'order_confirmation',
    'language' => 'en',
    'body' => 'Hi {{1}}, your order #{{2}} is confirmed!',
    'whatsappCategory' => 'UTILITY',
    'variables' => ['customer_name', 'order_id'],
]);

echo $result->id . "\n"; // tpl_xxx
echo $result->status . "\n"; // draft, pending, approved, rejected

List Templates

$result = $client->templates->list([]);

foreach ($result->items as $template) {
    echo $template->id . " " . $template->name . " " . $template->status . "\n";
}

// With pagination
$result = $client->templates->list([
    'limit' => 50,
    'cursor' => 'cursor_xxx',
]);

Get Template

$result = $client->templates->get([
    'templateId' => 'tpl_abc123',
]);

echo $result->name . "\n";
echo $result->body . "\n";
echo $result->status . "\n";

Delete Template

$client->templates->delete([
    'templateId' => 'tpl_abc123',
]);

Submit Template for Approval

After creating a template, you need to submit it to Meta for approval before you can use it:
$result = $client->templates->submit([
    'templateId' => 'tpl_abc123',
    'senderId' => 'sender_xyz',
    'category' => 'UTILITY', // Optional if already set on template
]);

echo $result->status . "\n"; // "pending"
The senderId must reference a sender that has a WhatsApp Business Account configured. Templates are submitted to the WABA associated with that sender.

Template Categories

CategoryUse Case
UTILITYOrder updates, account alerts, appointment reminders
MARKETINGPromotions, offers, newsletters
AUTHENTICATIONOTP codes, verification messages

Using Templates in Messages

$result = $client->messages->send([
    'to' => '+14155551234',
    'messageType' => 'template',
    'content' => [
        'templateId' => 'tpl_abc123',
        'templateVariables' => [
            '1' => 'John',
            '2' => 'ORD-12345',
        ],
    ],
]);