# Create and Sync Templates

> Build WhatsApp message templates with header, body, footer and buttons, submit them to Meta for approval, sync statuses, and see the rejection reason when a template is declined.

Source: https://edesy.in/docs/whatsapp-number/templates/create-and-sync

WhatsApp message templates are pre-approved messages you need for business-initiated chats and for replies after the 24-hour window. In wa-connect.edesy.in you build a template with a live preview and submit it to Meta. **Sync with Meta** pulls the latest status of every template, and a rejected template shows Meta's rejection reason.

## Template builder

| Part | Options |
|---|---|
| Name | Lowercase letters, digits and underscores, e.g. `order_update` |
| Language | e.g. `en_US` (default), `hi` |
| Category | `MARKETING`, `UTILITY`, `AUTHENTICATION` |
| Header | None, text, or image (with a sample image URL) |
| Body | Text with variables `{{1}}`, `{{2}}`, e.g. `Hi {{1}}, your order {{2}} has shipped.` |
| Footer | Optional, e.g. `Reply STOP to unsubscribe` |
| Buttons | Quick reply, URL, call (phone number) |
| Sample values | Every variable needs a sample value for Meta's review |
| Preview | Shows the message with your sample values filled in |

## Status values

| Status | Meaning |
|---|---|
| `PENDING` | Submitted, waiting for Meta's review |
| `APPROVED` | Ready to send |
| `REJECTED` | Declined by Meta; see `rejected_reason` |
| `PAUSED` | Paused by Meta |
| `DISABLED` | Disabled |
| `DELETED` | Deleted |

The template list also shows sent, delivered and read counts per template.

## How it works

1. **Open Templates** and click **New template**.
2. **Fill in** name, language, category, header, body, footer and buttons.
3. **Add sample values** for each variable and check the preview.
4. **Submit.** The template goes to Meta and shows `PENDING`.
5. **Sync with Meta** to pull the latest statuses. Meta's status updates are also received automatically.
6. **Send** approved templates from the [API](https://edesy.in/docs/whatsapp-number/api/send-messages).

## Templates API

Base URL: `https://voice-api.edesy.in/v1/whatsapp`. Auth: `Authorization: Bearer sk_...`.

| Method | Path | Description |
|---|---|---|
| `POST` | `/templates` | Create and submit. Body: `name`, `language`, `category`, `components` |
| `GET` | `/templates` | List. Query: `status`, `category`, `search`, `page`, `per_page` |
| `GET` | `/templates/{id}` | One template |
| `DELETE` | `/templates/{id}` | Delete (also deleted at Meta) |
| `POST` | `/templates/sync` | Pull templates and statuses from Meta |

```bash
curl -X POST https://voice-api.edesy.in/v1/whatsapp/templates \
  -H "Authorization: Bearer sk_your_api_key_here" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "order_update",
    "language": "en_US",
    "category": "UTILITY",
    "components": [
      {
        "type": "BODY",
        "text": "Hi {{1}}, your order {{2}} has shipped.",
        "example": { "body_text": [["Asha", "#1042"]] }
      },
      { "type": "FOOTER", "text": "Reply STOP to unsubscribe" },
      {
        "type": "BUTTONS",
        "buttons": [{ "type": "URL", "text": "Track order", "url": "https://example.com/track/{{1}}", "example": ["1042"] }]
      }
    ]
  }'
```

Component `type` is `HEADER`, `BODY`, `FOOTER` or `BUTTONS`. A header can set `format` to `TEXT`, `IMAGE`, `VIDEO` or `DOCUMENT`. Button `type` is `QUICK_REPLY`, `URL` or `PHONE_NUMBER`.

## FAQ

### Why do I need templates?
WhatsApp requires an approved template to start a conversation, or to message a customer more than 24 hours after their last message.

### How long does approval take?
Meta reviews templates; Edesy does not control the timing. Use **Sync with Meta** to check for updates.

### Where do I see why a template was rejected?
Open the template in the list. The **Rejection reason** from Meta is shown, and the API returns it as `rejected_reason`.

### Can I use templates I created in WhatsApp Manager?
Yes. **Sync with Meta** imports templates from your connected WhatsApp Business Account.

### What category should I choose?
`UTILITY` for order and account updates, `AUTHENTICATION` for one-time codes, `MARKETING` for offers and promotions. Meta can re-categorise a template during review.

### Can I add variables?
Yes. Use `{{1}}`, `{{2}}` and so on in the header or body, and give a sample value for each.

### What does it cost to send a template?
WhatsApp conversation charges are set by Meta and depend on the template category. Number rental and wallet charges from Edesy are separate.
