Appearance
Update a template
Change a template's name, alias, defaults, bodies or variable flags.
http
PATCH /v1/templates/{id}Requires a Full access API key.
{id} is the template's id or its alias (the slug) — both resolve to the same template.
Path parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The template id or its alias. |
Body parameters
Every field is optional — send only what you're changing. The shape matches Create a template.
| Parameter | Type | Description |
|---|---|---|
name | string | A new name. Max 120 characters. |
html | string | A new HTML body. |
alias | string | A new slug. Re-deduplicated within your team. Max 64 characters. |
from | string | null | A new default sender, or null to clear it. Max 320 characters. |
subject | string | null | A new default subject, or null to clear it. Max 998 characters. |
reply_to | string | null | A new default Reply-To, or null to clear it. Max 320 characters. |
text | string | null | A new plain-text body, or null to derive it from HTML at send. |
variables | array | Per-variable flags — { key, required?, fallback_value? }. See Variables. |
Changing a body re-discovers the variables
Variables are discovered from the body, so editing the html, subject or text re-extracts them. A {{{tag}}} you removed stops being a variable; one you added appears. Send an updated variables array alongside the body to keep the required flags and fallbacks in step — flags for a tag no longer in the body are dropped.
Example
bash
curl -X PATCH "https://api.sendgrail.com/v1/templates/$TEMPLATE_ID" \
-H "Authorization: Bearer $SENDGRAIL_API_KEY" \
-H 'Content-Type: application/json' \
-d '{ "subject": "Your order is on its way, {{{first_name}}}" }'js
await fetch(`https://api.sendgrail.com/v1/templates/${id}`, {
method: 'PATCH',
headers: {
Authorization: `Bearer ${process.env.SENDGRAIL_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
subject: 'Your order is on its way, {{{first_name}}}',
}),
});Response
Just the id — fetch the full object with Get a template.
json
{
"object": "template",
"id": "d3f8c2a1-6b47-4e9a-b25c-1f0e7a9d4c83"
}Errors
A template belonging to another team answers 404, by id or alias. A Sending access key gets 403. See Errors.