Skip to content

Duplicate a template

Copy a template into a fresh draft you can edit without touching the original.

http
POST /v1/templates/{id}/duplicate

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

ParameterTypeRequiredDescription
idstringYesThe template id or its alias to copy from.

Example

bash
curl -X POST "https://api.sendgrail.com/v1/templates/$TEMPLATE_ID/duplicate" \
  -H "Authorization: Bearer $SENDGRAIL_API_KEY"
js
const res = await fetch(
  `https://api.sendgrail.com/v1/templates/${id}/duplicate`,
  {
    method: 'POST',
    headers: { Authorization: `Bearer ${process.env.SENDGRAIL_API_KEY}` },
  },
);

const copy = await res.json();

Response

201 Created. The id is the new copy's — the source is untouched.

json
{
  "object": "template",
  "id": "a71c4e93-2f08-4b6d-9c15-8e3a0d7b2f14"
}

What you get

  • A fresh draft — the copy always starts in draft, whatever the source's status, so it can't be sent until you publish it.
  • A new id and a new alias, deduplicated within your team so nothing collides.
  • The name suffixed with (copy) — e.g. Welcome email becomes Welcome email (copy).
  • The same bodies, defaults and variables as the source.

Errors

A template belonging to another team answers 404, by id or alias. A Sending access key gets 403. See Errors.

Transactional email on your own domain.