Skip to main content
PATCH
/
templates
/
:id
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

await resend.templates.update('34a080c9-b17d-4187-ad80-5af20266e535', {
  name: 'welcome-email',
  html: '<strong>Hey, {{{NAME}}}, you are {{{AGE}}} years old.</strong>',
  variables: [
    {
      key: 'NAME',
      type: 'string',
      fallbackValue: 'user',
    },
    {
      key: 'AGE',
      type: 'number',
      fallbackValue: 25,
    },
    {
      key: 'OPTIONAL_VARIABLE',
      type: 'string',
    },
  ],
});
{
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "object": "template"
}
Templates API is currently in private beta and only available to a limited number of users.

Path Parameters

id | alias
string
The ID or alias of the template to duplicate.

Body Parameters

name
string
required
The name of the template.
alias
string
The alias of the template.
from
string
Sender email address.To include a friendly name, use the format "Your Name <sender@domain.com>".If provided, this value can be overridden when sending an email using the template.
subject
string
Email subject.If provided, this value can be overridden when sending an email using the template.
html
string
required
The HTML version of the template.
text
string
The plain text version of the message.
If not provided, the HTML will be used to generate a plain text version. You can opt out of this behavior by setting value to an empty string.
react
React.ReactNode
The React component used to write the template. Only available in the Node.js SDK.
variables
array
The array of variables used in the template. Each template may contain up to 20 variables.Each variable is an object with the following properties:
Before you can use a template, you must publish it first. To publish a template, use the Templates dashboard or publish template API.
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

await resend.templates.update('34a080c9-b17d-4187-ad80-5af20266e535', {
  name: 'welcome-email',
  html: '<strong>Hey, {{{NAME}}}, you are {{{AGE}}} years old.</strong>',
  variables: [
    {
      key: 'NAME',
      type: 'string',
      fallbackValue: 'user',
    },
    {
      key: 'AGE',
      type: 'number',
      fallbackValue: 25,
    },
    {
      key: 'OPTIONAL_VARIABLE',
      type: 'string',
    },
  ],
});
{
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "object": "template"
}
I