> ## 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

> Manage templates with the Go SDK

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

```go theme={null}
result, err := client.Templates.Create(context.TODO(), zavudev.TemplateCreateParams{
	Name:             zavudev.String("order_confirmation"),
	Language:         zavudev.String("en"),
	Body:             zavudev.String("Hi {{1}}, your order #{{2}} is confirmed!"),
	WhatsappCategory: zavudev.String("UTILITY"),
	Variables:        []string{"customer_name", "order_id"},
})
if err != nil {
	panic(err)
}

fmt.Println(result.ID)     // tpl_xxx
fmt.Println(result.Status) // draft, pending, approved, rejected
```

## List Templates

```go theme={null}
result, err := client.Templates.List(context.TODO(), zavudev.TemplateListParams{})
if err != nil {
	panic(err)
}

for _, template := range result.Items {
	fmt.Println(template.ID, template.Name, template.Status)
}

// With pagination
result, err := client.Templates.List(context.TODO(), zavudev.TemplateListParams{
	Limit:  zavudev.Int(50),
	Cursor: zavudev.String("cursor_xxx"),
})
```

## Get Template

```go theme={null}
result, err := client.Templates.Get(context.TODO(), "tpl_abc123")
if err != nil {
	panic(err)
}

fmt.Println(result.Name)
fmt.Println(result.Body)
fmt.Println(result.Status)
```

## Delete Template

```go theme={null}
err := client.Templates.Delete(context.TODO(), "tpl_abc123")
if err != nil {
	panic(err)
}
```

## Submit Template for Approval

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

```go theme={null}
result, err := client.Templates.Submit(context.TODO(), "tpl_abc123", zavudev.TemplateSubmitParams{
	SenderID: zavudev.String("sender_xyz"),
	Category: zavudev.String("UTILITY"), // Optional if already set on template
})
if err != nil {
	panic(err)
}

fmt.Println(result.Status) // "pending"
```

<Info>
  The `SenderID` 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

```go theme={null}
result, err := client.Messages.Send(context.TODO(), zavudev.MessageSendParams{
	To:          zavudev.String("+14155551234"),
	MessageType: zavudev.String("template"),
	Content: &zavudev.MessageContent{
		TemplateID: zavudev.String("tpl_abc123"),
		TemplateVariables: map[string]string{
			"1": "John",
			"2": "ORD-12345",
		},
	},
})
```
