home / skills / resend / resend-skills / templates

templates skill

/templates

This skill helps you manage Resend email templates end-to-end, including create, publish, update, and alias handling for consistent messaging.

This is most likely a fork of the resend-skills skill from openclaw
npx playbooks add skill resend/resend-skills --skill templates

Review the files below or copy the command above to add this skill to your agents.

Files (3)
SKILL.md
3.5 KB
---
name: templates
description: Use when creating, updating, publishing, deleting, or listing Resend email templates via the API, or when defining template variables, understanding draft vs published state, or managing template lifecycle programmatically.
---

# Resend Templates

## Overview

Templates are reusable email structures stored on Resend. Define HTML and variables once; reference the template ID or alias when sending.

**Use templates when:** the same structure is reused across many sends, non-engineers need to edit copy without touching code, or you want version history.

**Use inline `html` when:** the structure changes per send, you need more than 50 dynamic variables, or you want tighter rendering control.

## Template Lifecycle

```
Create (draft) → Publish → Send
      ↑ edit                 |
      └─────────────────────┘
```

Editing a published template creates a new draft — the published version keeps sending until you publish again.

| State | Can send? |
|-------|-----------|
| **Draft** | No |
| **Published** | Yes |

## SDK Methods (Node.js)

| Operation | Method |
|-----------|--------|
| Create | `resend.templates.create(params)` |
| Get | `resend.templates.get(id)` |
| List | `resend.templates.list(params)` |
| Update | `resend.templates.update(id, params)` |
| Delete | `resend.templates.remove(id)` ← not `.delete()` |
| Publish | `resend.templates.publish(id)` |
| Duplicate | `resend.templates.duplicate(id)` |

### Chainable Create → Publish

The SDK supports chaining `.publish()` after `.create()` or `.duplicate()`:

```typescript
const { data, error } = await resend.templates.create({
  name: 'Welcome',
  html: '<p>Hi {{{NAME}}}</p>',
}).publish();
// Template is created AND published in one call
```

## Aliases

An alias is a stable, human-readable slug you set at create time. Pass it in the `id` field anywhere you'd use the auto-generated template ID.

```typescript
// Set alias at create time
await resend.templates.create({
  name: 'Order Confirmation',   // display-only
  alias: 'order-confirmation',  // referenceable slug
  html: '<p>Hi {{{CUSTOMER_NAME}}}</p>',
});

// Reference by alias — no need to store the generated tmpl_ ID
template: { id: 'order-confirmation', variables: { CUSTOMER_NAME: 'Alice' } }
```

## Variable Syntax

Use **triple mustache** in HTML and subject: `{{{VARIABLE_NAME}}}`

```html
<!-- ✅ Correct -->
<p>Hi {{{CUSTOMER_NAME}}}, your order #{{{ORDER_ID}}} has shipped!</p>

<!-- ❌ Wrong — double braces don't render in Resend -->
<p>Hi {{CUSTOMER_NAME}}</p>
```

Plain substitution only — no `{{#each}}`, `{{#if}}`, or other Handlebars control flow. Pre-render dynamic lists server-side into a single HTML variable.

Variable key casing is arbitrary (`ORDER_ID`, `orderId`, `order_id` all work) but must be consistent: whatever casing you use in the template definition must match exactly in the send call.

## Sending with a Template

```typescript
const { data, error } = await resend.emails.send(
  {
    from: 'Acme <[email protected]>',
    to: ['[email protected]'],
    template: {
      id: 'order-confirmation',  // alias or auto-generated ID
      variables: { CUSTOMER_NAME: 'Alice', ORDER_ID: '12345' },
    },
  },
  { idempotencyKey: `order-confirm/${orderId}` }
);
```

Cannot combine `template` with `html`, `text`, or `react` — mutually exclusive. `subject` and `from` from the template can be overridden per-send.

For variable constraints, reserved names, full CRUD examples, pagination, and version history, see [reference.md](reference.md).

Overview

This skill manages Resend email templates programmatically. Use it to create, update, publish, duplicate, delete, and list templates, and to define template variables, aliases, and lifecycle behavior. It helps enforce draft vs published semantics so sends always use a stable published version.

How this skill works

The skill calls Resend’s templates API or SDK methods to operate on template resources: create produces a draft, publish makes a version available for sending, update creates a new draft and preserves the published copy until republished, and delete removes a template. It supports aliasing, chainable create→publish, and variable substitution using triple-mustache placeholders in HTML and subject fields.

When to use it

  • When the same email structure is reused across many sends and you want central editing.
  • When non-engineers need to edit copy without changing application code.
  • When you want version history and safe publishing workflows (draft vs published).
  • When creating or maintaining reusable aliases for stable template references.
  • When automating template lifecycle: create → edit → publish → duplicate → retire.

Best practices

  • Use aliases as stable, human-readable IDs so your application needn’t store generated template IDs.
  • Always publish templates before sending; drafts cannot be sent.
  • Use triple-mustache {{{VAR}}} for all template variables and keep casing consistent between template and send call.
  • Pre-render arrays or complex lists server-side into a single HTML variable (no Handlebars control flow supported).
  • Chain create().publish() or duplicate().publish() when you want an atomic create-and-publish operation.
  • Don’t combine template with html/text/react in the same send request; subject/from can be overridden per send.

Example use cases

  • Create a welcome email template with variables for dynamic customer data and publish it for production sends.
  • Duplicate an existing order receipt template, edit the draft for seasonal layout changes, then publish when ready.
  • Assign an alias like order-confirmation and reference it directly in send calls to avoid storing tmpl_ IDs.
  • Update copy in a published template by editing and publishing a new version without interrupting current sends.
  • List templates programmatically to show editable templates in a CMS for non-developer editors.

FAQ

Can I send emails using a draft template?

No. Draft templates are not sendable. Publish the template to make it available for sending.

How do I reference a template without storing the generated ID?

Set an alias when creating the template and use that alias as the template id in send requests.

What variable syntax should I use?

Use triple mustache like {{{VARIABLE_NAME}}}. Double braces will not render in Resend.