Templates
Create reusable HTML/text email templates with named variables and Resend-style triple-brace substitution. Every create or update appends an immutable version.
/templatesCreate a templatename and html are required. variables is up to 50 { key, type: "string" | "number", fallback_value? } declarations — a key can't be one of the reserved names (FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, RESEND_UNSUBSCRIBE_URL, contact, this), reserved for contact-derived substitutions. A new template starts as draft — it can't be used to send until POST /templates/:id/publish.
curl -X POST https://api.irisend.com/templates \
-H "Authorization: Bearer $IRISEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome",
"from": "[email protected]",
"subject": "Welcome, {{{CUSTOMER_NAME}}}!",
"html": "<p>Hi {{{CUSTOMER_NAME}}}, thanks for joining!</p>",
"variables": [
{
"key": "CUSTOMER_NAME",
"type": "string",
"fallback_value": "there"
}
]
}'{
"object": "template",
"id": "d58da373-e335-4140-8edd-fe7d680e915b",
"alias": null,
"status": "draft",
"name": "Welcome",
"subject": "Welcome, {{{CUSTOMER_NAME}}}!",
"from": "[email protected]",
"reply_to": null,
"html": "<p>Hi {{{CUSTOMER_NAME}}}, thanks for joining!</p>",
"text": null,
"variables": [{ "key": "CUSTOMER_NAME", "type": "string", "fallback_value": "there" }],
"version": 1,
"created_at": "2026-09-25T09:00:12.481Z",
"updated_at": "2026-09-25T09:00:12.481Z"
}/templates/:id/publishPublish a templatePoints published at the current draft version. Required before template: { id } on POST /emails will render it. Once published, status never reverts to draft, even after further unpublished edits.
curl -X POST https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b/publish \
-H "Authorization: Bearer $IRISEND_API_KEY"{ "object": "template", "id": "d58da373-e335-4140-8edd-fe7d680e915b" }/templatesList templatescurl https://api.irisend.com/templates \
-H "Authorization: Bearer $IRISEND_API_KEY"/templates/:idRetrieve a template:id accepts the UUID or the alias you set at creation.
curl https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b \
-H "Authorization: Bearer $IRISEND_API_KEY"/templates/:idUpdate a templateSame fields as create, all optional — an omitted field carries over from the current version unchanged. Appends a new version and returns its number; it does not touch published.
curl -X PATCH https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b \
-H "Authorization: Bearer $IRISEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"html": "<p>Hi {{{CUSTOMER_NAME}}}, thanks for trying Irisend!</p>"
}'{ "object": "template", "id": "d58da373-e335-4140-8edd-fe7d680e915b", "version": 2 }/templates/:id/duplicateDuplicate a templateCreates a brand-new template (new id, fresh draft status) seeded from the source's current draft content. name/alias are optional.
curl -X POST https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b/duplicate \
-H "Authorization: Bearer $IRISEND_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "Welcome (copy)" }'/templates/:id/versionsList version historycurl https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b/versions \
-H "Authorization: Bearer $IRISEND_API_KEY"{
"object": "list",
"has_more": false,
"data": [
{
"object": "template_version",
"id": "f0451a59-e134-43b7-b1b3-2c07c27cbdf4",
"template_id": "d58da373-e335-4140-8edd-fe7d680e915b",
"version": 2,
"name": "Welcome",
"subject": "Welcome, {{{CUSTOMER_NAME}}}!",
"from": "[email protected]",
"reply_to": null,
"html": "<p>Hi {{{CUSTOMER_NAME}}}, thanks for trying Irisend!</p>",
"text": null,
"variables": [{ "key": "CUSTOMER_NAME", "type": "string", "fallback_value": "there" }],
"created_at": "2026-09-25T10:14:02.009Z"
}
]
}/templates/:id/versions/:version_id/rollbackRoll back to a versionHistory is append-only — a rollback copies the target version's content into a new version rather than rewriting history. Publishing the rolled-back draft is still a separate publish call.
curl -X POST https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b/versions/f0451a59-e134-43b7-b1b3-2c07c27cbdf4/rollback \
-H "Authorization: Bearer $IRISEND_API_KEY"{ "object": "template", "id": "d58da373-e335-4140-8edd-fe7d680e915b" }/templates/:idDelete a templatecurl -X DELETE https://api.irisend.com/templates/d58da373-e335-4140-8edd-fe7d680e915b \
-H "Authorization: Bearer $IRISEND_API_KEY"{ "object": "template", "id": "d58da373-e335-4140-8edd-fe7d680e915b", "deleted": true }