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

# Introduction

> Decouple email design and copywriting from your codebase with reusable templates.

# Templates Introduction

Mailofly Templates allow you to decouple email design and copywriting from your application code.

Design responsive templates in the dashboard, test them with live preview data, and trigger them with a single API call by passing a `template_id` and dynamic merge variables.

***

## Why Use Mailofly Templates?

* **Code Separation**: Marketing and design teams can edit copy, layout, and colors without redeploying backend code.
* **Reusable Layouts**: Create consistent headers, footers, and brand styles across all transactional and marketing messages.
* **Dynamic Personalization**: Use Handlebars-style merge tags (`{{first_name}}`, `{{order_id}}`) to inject user data at send time.
* **Version Safety**: Test changes in draft mode before publishing to production.

***

## Triggering a Template via API

Instead of passing raw `html` in your API payload, pass `template_id` and `variables`:

```typescript theme={null}
import { Mailofly } from "mailofly";

const mailofly = new Mailofly("mfly_live_your_api_key");

await mailofly.emails.send({
  from: "Acme <hello@acme.com>",
  to: ["alex@example.com"],
  template_id: "tmpl_welcome_v1",
  variables: {
    first_name: "Alex",
    login_url: "https://acme.com/login?token=abc123xyz",
    support_email: "support@acme.com"
  },
});
```

***

## Next Steps

* [Creating & Managing Templates](manage-templates.md)
* [Using the Template Editor](template-editor.md)
* [Working with Variables & Fallbacks](variables.md)
* [Previewing & Testing](preview-and-test.md)


## Related topics

- [Introduction](/introduction.md)
