# Update Template

PATCH

/

templates

/

:template\_id

:::code-group
```typescript title="Node.js"
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.templates.update(
  '34a080c9-b17d-4187-ad80-5af20266e535',
  {
    name: 'order-confirmation',
    html: '<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>',
  },
);
```

```php title="PHP"
$resend = Resend::client('re_xxxxxxxxx');

$resend->templates->update('34a080c9-b17d-4187-ad80-5af20266e535', [
  'name' => 'order-confirmation',
  'html' => '<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>',
]);
```

```python title="Python"
import resend

resend.api_key = "re_xxxxxxxxx"

resend.Templates.update({
    "id": "34a080c9-b17d-4187-ad80-5af20266e535",
    "name": "order-confirmation",
    "html": "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
})
```

```ruby title="Ruby"
require "resend"

Resend.api_key = "re_xxxxxxxxx"

Resend::Templates.update("34a080c9-b17d-4187-ad80-5af20266e535", {
  name: "order-confirmation",
  html: "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
})
```

```go title="Go"
package main

import (
	"context"

	"github.com/resend/resend-go/v4"
)

func main() {
	client := resend.NewClient("re_xxxxxxxxx")

	client.Templates.UpdateWithContext(context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", &resend.UpdateTemplateRequest{
		Name: "order-confirmation",
		Html: "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
	})
}
```

```rust title="Rust"
use resend_rs::{
  types::UpdateTemplateOptions,
  Resend, Result,
};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let name = "order-confirmation";
  let html = "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>";

  let update = UpdateTemplateOptions::new(name, html);

  let _template = resend
    .templates
    .update("34a080c9-b17d-4187-ad80-5af20266e535", update)
    .await?;

  Ok(())
}
```

```java title="Java"
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.templates.model.UpdateTemplateOptions;
import com.resend.services.templates.model.UpdateTemplateResponseSuccess;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        UpdateTemplateOptions params = UpdateTemplateOptions.builder()
                .name("order-confirmation")
                .html("<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>")
                .build();

        UpdateTemplateResponseSuccess data = resend.templates().update("34a080c9-b17d-4187-ad80-5af20266e535", params);
    }
}
```

```csharp title=".NET"
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

await resend.TemplateUpdateAsync(
    templateId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ),
    new TemplateData()
    {
        HtmlBody = "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
    }
);
```

```shellscript title="cURL"
curl -X PATCH 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "order-confirmation",
  "html": "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
}'
```

```shellscript title="CLI"
resend templates update 34a080c9-b17d-4187-ad80-5af20266e535 \
  --name order-confirmation \
  --html "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
```
:::

:::code-group
```json title="Response"
{
  "object": "template",
  "id": "34a080c9-b17d-4187-ad80-5af20266e535"
}
```
:::

## Path Parameters

string

The ID or alias of the template to duplicate.

## Body Parameters

string

The name of the template.

string

The HTML version of the template.

string

The alias of the template.

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.

string

Default email subject.This value can be overridden when sending an email using the template.

string

The plain text version of the message.

:::callout{intent="info"}
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.ReactNode

The React component used to write the template. _Only available in the Node.js SDK._

array

The array of variables used in the template. Each template may contain up to 50 variables.Each variable is an object with the following properties:

:::accordion{title="Hide properties" open="true"}
string

required

The key of the variable. We recommend capitalizing the key (e.g. `PRODUCT_NAME`). The following variable names are reserved and cannot be used: `FIRST_NAME`, `LAST_NAME`, `EMAIL`, `RESEND_UNSUBSCRIBE_URL`, `contact`, and `this`.

'string' | 'number'

required

The type of the variable.Can be `'string'` or `'number'`
:::

:::callout{intent="info"}
Before you can use a template, you must publish it first. To publish a template, use the [Templates dashboard](https://resend.com/templates) or [publish template API](/guides/templates-publish-template).[Learn more about Templates](/guides/learn-dashboard-templates-introduction).
:::

:::code-group
```typescript title="Node.js"
import { Resend } from 'resend';

const resend = new Resend('re_xxxxxxxxx');

const { data, error } = await resend.templates.update(
  '34a080c9-b17d-4187-ad80-5af20266e535',
  {
    name: 'order-confirmation',
    html: '<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>',
  },
);
```

```php title="PHP"
$resend = Resend::client('re_xxxxxxxxx');

$resend->templates->update('34a080c9-b17d-4187-ad80-5af20266e535', [
  'name' => 'order-confirmation',
  'html' => '<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>',
]);
```

```python title="Python"
import resend

resend.api_key = "re_xxxxxxxxx"

resend.Templates.update({
    "id": "34a080c9-b17d-4187-ad80-5af20266e535",
    "name": "order-confirmation",
    "html": "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
})
```

```ruby title="Ruby"
require "resend"

Resend.api_key = "re_xxxxxxxxx"

Resend::Templates.update("34a080c9-b17d-4187-ad80-5af20266e535", {
  name: "order-confirmation",
  html: "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
})
```

```go title="Go"
package main

import (
	"context"

	"github.com/resend/resend-go/v4"
)

func main() {
	client := resend.NewClient("re_xxxxxxxxx")

	client.Templates.UpdateWithContext(context.TODO(), "34a080c9-b17d-4187-ad80-5af20266e535", &resend.UpdateTemplateRequest{
		Name: "order-confirmation",
		Html: "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
	})
}
```

```rust title="Rust"
use resend_rs::{
  types::UpdateTemplateOptions,
  Resend, Result,
};

#[tokio::main]
async fn main() -> Result<()> {
  let resend = Resend::new("re_xxxxxxxxx");

  let name = "order-confirmation";
  let html = "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>";

  let update = UpdateTemplateOptions::new(name, html);

  let _template = resend
    .templates
    .update("34a080c9-b17d-4187-ad80-5af20266e535", update)
    .await?;

  Ok(())
}
```

```java title="Java"
import com.resend.Resend;
import com.resend.core.exception.ResendException;
import com.resend.services.templates.model.UpdateTemplateOptions;
import com.resend.services.templates.model.UpdateTemplateResponseSuccess;

public class Main {
    public static void main(String[] args) throws ResendException {
        Resend resend = new Resend("re_xxxxxxxxx");

        UpdateTemplateOptions params = UpdateTemplateOptions.builder()
                .name("order-confirmation")
                .html("<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>")
                .build();

        UpdateTemplateResponseSuccess data = resend.templates().update("34a080c9-b17d-4187-ad80-5af20266e535", params);
    }
}
```

```csharp title=".NET"
using Resend;

IResend resend = ResendClient.Create( "re_xxxxxxxxx" ); // Or from DI

await resend.TemplateUpdateAsync(
    templateId: new Guid( "e169aa45-1ecf-4183-9955-b1499d5701d3" ),
    new TemplateData()
    {
        HtmlBody = "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>",
    }
);
```

```shellscript title="cURL"
curl -X PATCH 'https://api.resend.com/templates/34a080c9-b17d-4187-ad80-5af20266e535' \
     -H 'Authorization: Bearer re_xxxxxxxxx' \
     -H 'Content-Type: application/json' \
     -d $'{
  "name": "order-confirmation",
  "html": "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
}'
```

```shellscript title="CLI"
resend templates update 34a080c9-b17d-4187-ad80-5af20266e535 \
  --name order-confirmation \
  --html "<p>Total: {{{PRICE}}}</p><p>Name: {{{PRODUCT}}}</p>"
```
:::

```json
{
  "object": "template",
  "id": "34a080c9-b17d-4187-ad80-5af20266e535"
}
```

Was this page helpful?

⌘I

## Related pages

- [Account Management](./account-management-index.md)
- [API Keys](./api-keys-2-index.md)
- [API Keys](./api-keys-index.md)
- [API Reference](./api-reference-index.md)
- [AudiencesDEPRECATED](./audiencesdeprecated-index.md)
- [Authorized Apps](./authorized-apps-index.md)
- [Automations](./automations-index.md)
- [Broadcasts](./broadcasts-index.md)
- [Build with AI](./build-with-ai-index.md)
- [Changelog](../changelog.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
