> ## Documentation Index
> Fetch the complete documentation index at: https://docs.zavu.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates

> Create, list and submit WhatsApp message templates via the Zavu Python SDK. Manage variables, categories and approval status from your code.

Templates are reusable message formats for sending structured messages across WhatsApp, SMS, Telegram, and other channels. WhatsApp requires template approval for business-initiated conversations.

## Create Template

```python theme={null}
result = client.templates.create(
    name="order_confirmation",
    language="en",
    body="Hi {{1}}, your order #{{2}} is confirmed!",
    whatsapp_category="UTILITY",
    variables=["customer_name", "order_id"]
)

print(result.id)      # tpl_xxx
print(result.status)  # draft, pending, approved, rejected
```

## List Templates

```python theme={null}
result = client.templates.list()
for template in result.items:
    print(template.id, template.name, template.status)

# With pagination
result = client.templates.list(
    limit=50,
    cursor="cursor_xxx"
)
```

## Get Template

```python theme={null}
result = client.templates.get(template_id="tpl_abc123")

print(result.name)
print(result.body)
print(result.status)
```

## Delete Template

```python theme={null}
client.templates.delete(template_id="tpl_abc123")
```

## Submit Template for Approval

After creating a template, you need to submit it to Meta for approval before you can use it:

```python theme={null}
result = client.templates.submit(
    template_id="tpl_abc123",
    sender_id="sender_xyz",
    category="UTILITY"  # Optional if already set on template
)

print(result.status)  # "pending"
```

<Info>
  The `sender_id` must reference a sender that has a WhatsApp Business Account configured. Templates are submitted to the WABA associated with that sender.
</Info>

## Template Categories

| Category         | Use Case                                             |
| ---------------- | ---------------------------------------------------- |
| `UTILITY`        | Order updates, account alerts, appointment reminders |
| `MARKETING`      | Promotions, offers, newsletters                      |
| `AUTHENTICATION` | OTP codes, verification messages                     |

## Using Templates in Messages

```python theme={null}
result = client.messages.send(
    to="+14155551234",
    message_type="template",
    content={
        "template_id": "tpl_abc123",
        "template_variables": {
            "1": "John",
            "2": "ORD-12345"
        }
    }
)
```
