Skip to main content
Resend Docs

Search documentation

Type to search this documentation.

On this pageOverview

Using Templates

With Templates, you can define the structure and layout of a message once, then reuse it for multiple emails.

Use Templates for transactional emails you send often, like:

  • Login/Auth
  • Onboarding
  • Ecommerce
  • Notifications
  • Automations

With Resend's Template features, you can:

You can even embed the React Email editor in your own application to let your users create their own transactional emails from Templates and ship HTML-ready email content directly to Resend.

To create transactional email Templates, you can use a variety of tools:

  • Editor: create using Resend's no-code editor
  • SDKs: create with an SDK built for your language
  • Integrations: create with a framework or tool you already use
  • API: create with raw cURL calls
  • CLI: create templates from the terminal
  • MCP: create through your agent with MCP
  • React Email: create from a React Email Template file
  • HTML: create from an HTML file

When you send a transactional email from your application, you can reference a published Template to use as your content instead of passing the HTML directly.

Specify the Template ID and include any Template variables in your API endpoint or CLI command. Resend will replace the Template variables with the actual variables specified in your code.

Node.js
import { Resend } from 'resend';const resend = new Resend('re_xxxxxxxxx');await resend.emails.send({  from: 'Acme <onboarding@resend.dev>',  to: 'delivered@resend.dev',  template: {    id: 'order-confirmation',    variables: {      PRODUCT: 'Vintage Macintosh',      PRICE: 499,    },  },});
PHP
$resend = Resend::client('re_xxxxxxxxx');$resend->emails->send([  'from' => 'Acme <onboarding@resend.dev>',  'to' => ['delivered@resend.dev'],  'subject' => 'hello world',  'template'=> [    'id' => 'f3b9756c-f4f4-44da-bc00-9f7903c8a83f',    'variables' => [      'PRODUCT' => 'Vintage Macintosh',      'PRICE' => 499,    ]  ]]);
Python
import resendresend.api_key = "re_xxxxxxxxx"resend.Emails.send({  "from": "Acme <onboarding@resend.dev>",  "to": "delivered@resend.dev",  "template": {    "id": "order-confirmation",    "variables": {      "PRODUCT": "Vintage Macintosh",      "PRICE": 499    }  }})
Ruby
require "resend"Resend.api_key = "re_xxxxxxxxx"Resend::Emails.send({  from: "Acme <onboarding@resend.dev>",  to: "delivered@resend.dev",  template: {    id: "order-confirmation",    variables: {      PRODUCT: "Vintage Macintosh",      PRICE: 499    }  }})
Go
import "github.com/resend/resend-go/v4"client := resend.NewClient("re_xxxxxxxxx")params := &resend.SendEmailRequest{  From: "Acme <onboarding@resend.dev>",  To: []string{"delivered@resend.dev"},  Template: &resend.EmailTemplate{    Id: "order-confirmation",    Variables: map[string]interface{}{      "PRODUCT": "Vintage Macintosh",      "PRICE": 499,    },  },}client.Emails.Send(params)
Rust
use resend_rs::{  json,  types::{CreateEmailBaseOptions, EmailTemplate},  Resend, Result,};#[tokio::main]async fn main() -> Result<()> {  let resend = Resend::new("re_xxxxxxxxx");  let template = EmailTemplate::new("order-confirmation")    .with_variable("PRODUCT", json!("Vintage Macintosh"))    .with_variable("PRICE", json!(499));  let email = CreateEmailBaseOptions::new(    "Acme <onboarding@resend.dev>",    ["delivered@resend.dev"],    "hello world",  )  .with_template(template);  let _email = resend.emails.send(email).await?;  Ok(())}
Java
import com.resend.*;import com.resend.services.emails.model.CreateEmailOptions;import com.resend.services.emails.model.CreateEmailResponse;import com.resend.services.emails.model.Template;import java.util.Arrays;import java.util.HashMap;import java.util.Map;Resend resend = new Resend("re_xxxxxxxxx");Map<String, Object> variables = new HashMap<>();variables.put("PRODUCT", "Vintage Macintosh");variables.put("PRICE", 499);CreateEmailOptions params = CreateEmailOptions.builder()  .from("Acme <onboarding@resend.dev>")  .to(Arrays.asList("customer@email.com"))  .template(Template.builder()    .id("order-confirmation")    .variables(variables)    .build())  .build();CreateEmailResponse data = resend.emails().send(params);
.NET
using Resend;IResend resend = ResendClient.Create("re_xxxxxxxxx");var variables = new Dictionary<string, object>{  { "PRODUCT", "Vintage Macintosh" },  { "PRICE", 499 }};var resp = await resend.EmailSendAsync(  new EmailMessage()  {    From = "Acme <onboarding@resend.dev>",    To = new[] { "delivered@resend.dev" },    Template = new EmailMessageTemplate()    {      TemplateId = "b6d24b8e-af0b-4c3c-be0c-359bbd97381e",      Variables = variables    }  });Console.WriteLine($"Email Id={resp.Content}");
cURL
curl -X POST 'https://api.resend.com/emails' \  -H 'Authorization: Bearer re_xxxxxxxxx' \  -H 'Content-Type: application/json' \  -d $'{    "from": "Acme <onboarding@resend.dev>",    "to": "delivered@resend.dev",    "template": {      "id": "order-confirmation",      "variables": {        "PRODUCT": "Vintage Macintosh",        "PRICE": 499      }    }}'

See how to use Resend's email Template features.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu