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

# Templates

> Create and manage reusable email templates independently from broadcasts.

Templates are reusable email content resources for workflows that want a named, versioned message definition.

Templates are separate from broadcasts. A broadcast owns the exact content it sends and does not store template references. If you want to use a template as the starting point for a broadcast, resolve the desired template content first and copy it into the Broadcast API request.

## Categories

Every template has a category. Supported values are:

* `otp`
* `welcome`
* `receipt`
* `alert`
* `notification`
* `custom`

`category` is required when creating a template and can be changed when updating one.

## Template content

A template can include:

* `name` and optional `alias`
* `category`
* sender fields such as `from` and `reply_to`
* `subject`
* `html` and optional `text`
* typed variables with optional fallback values

Supported variable types are currently `string` and `number`.

## Versions and publishing

Templates keep versions so content can evolve without losing previous definitions. You can list versions, retrieve a specific version, publish the current template, and revert to an earlier version.

Publishing is a template lifecycle operation. It is not part of the broadcast send path.

## Preview and test send

Preview a template with variable values before using it in an application workflow. You can also issue a test send to a specific recipient without creating a broadcast.

## Pagination

Both `GET /templates` and `GET /templates/{template}/versions` use `limit` and `offset` pagination.

* `limit` defaults to `50` when omitted or non-positive.
* Values above `100` are capped at `100` by the HTTP handler.
* `offset` defaults to `0`, and negative values are treated as `0`.
* Malformed integer values for `limit` or `offset` return `400 Bad Request`.

`GET /templates` returns an object with `data` and `has_more`. The service requests one extra template internally to determine whether another page exists.

`GET /templates/{template}/versions` returns a plain array of versions and does not include `has_more`. For version history, advance `offset` by the number of versions returned and stop when a page contains fewer than the effective limit.

<CardGroup cols={2}>
  <Card title="API Reference" icon="square-terminal" href="/docs/api-reference/introduction">
    Explore the template endpoints, request bodies, and responses.
  </Card>

  <Card title="Broadcasts" icon="bullhorn" href="/docs/broadcasts/overview">
    Learn how broadcast-owned content differs from reusable templates.
  </Card>
</CardGroup>
