Templates
Reusable emails with variables, sent by id or alias.
- POSTCreate a template
/templates - POSTPublish a template
/templates/{id}/publish - GETRetrieve a template
/templates/{id|alias} - GETList templates
/templates - PATCHUpdate a template
/templates/{id|alias} - POSTDuplicate a template
/templates/{id|alias}/duplicate - DELETEDelete a template
/templates/{id|alias} - POSTSend with a template
/emails
Write variables as {{{NAME}}} (inserted as is) or {{NAME}} (HTML-escaped). A template must be published before you can send it; send with template: { id, variables } using its id or alias.
Create a template
/templatesCreates a draft.
namestringrequiredThe template's name.
htmlstringrequiredHTML with variables, up to 2 MB.
textstringPlain-text version, up to 1 MB.
subjectstringDefault subject (can use variables). Required to publish.
aliasstringA stable name to send with: lowercase letters, numbers,
_and-, up to 64 characters.from · reply_tostringDefaults used when a send leaves them out.
variablesarrayUp to 50
{ key, type, fallback_value };typeisstring(default) ornumber. Variables used but not declared are added for you.
curl -X POST 'https://api.iresendly.com/templates' \
-H 'Authorization: Bearer irs_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"name": "Welcome",
"alias": "welcome",
"subject": "Welcome, {{{NAME}}}!",
"html": "<p>Hi {{{NAME}}}</p>",
"variables": [
{
"key": "NAME",
"type": "string",
"fallback_value": "there"
}
]
}'{
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"object": "template"
}Publish a template
/templates/{id}/publishMakes the template sendable. Needs a subject.
idstringrequiredThe template id.
curl -X POST 'https://api.iresendly.com/templates/{id}/publish' \
-H 'Authorization: Bearer irs_xxxxxxxxx'{
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"object": "template"
}Retrieve a template
/templates/{id|alias}The full template.
id|aliasstringrequiredThe template id or alias.
curl -X GET 'https://api.iresendly.com/templates/{id|alias}' \
-H 'Authorization: Bearer irs_xxxxxxxxx'{
"object": "template",
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"name": "Welcome",
"alias": "welcome",
"status": "published"
}List templates
/templatesEvery template, without bodies.
limitnumberResults per page, 1–100. Default 20.
afterstringReturn results after this id (next page).
beforestringReturn results before this id (previous page). Don't send with
after.
curl -X GET 'https://api.iresendly.com/templates' \
-H 'Authorization: Bearer irs_xxxxxxxxx'{
"object": "list",
"has_more": false,
"data": [
{
"object": "template",
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"name": "Welcome",
"alias": "welcome",
"status": "published"
}
]
}Update a template
/templates/{id|alias}Changes any field. A published template stays published, so the change is live at once.
id|aliasstringrequiredThe template id or alias.
curl -X PATCH 'https://api.iresendly.com/templates/{id|alias}' \
-H 'Authorization: Bearer irs_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"subject": "Welcome aboard, {{{NAME}}}!"
}'{
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"object": "template"
}Duplicate a template
/templates/{id|alias}/duplicateCreates a draft copy named “(copy)”, without the alias.
id|aliasstringrequiredThe template id or alias.
curl -X POST 'https://api.iresendly.com/templates/{id|alias}/duplicate' \
-H 'Authorization: Bearer irs_xxxxxxxxx'{
"id": "b8f51c2e-9d3a-4f6b-8e1c-2a7d9f0b3c41",
"object": "template"
}Delete a template
/templates/{id|alias}Deletes it permanently.
id|aliasstringrequiredThe template id or alias.
curl -X DELETE 'https://api.iresendly.com/templates/{id|alias}' \
-H 'Authorization: Bearer irs_xxxxxxxxx'{
"object": "template",
"id": "34a080c9-b17d-4187-ad80-5af20266e535",
"deleted": true
}Send with a template
/emailsSending keys allowedPass template instead of html and text. A variable with no value and no fallback returns 422.
curl -X POST 'https://api.iresendly.com/emails' \
-H 'Authorization: Bearer irs_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"from": "Acme <hello@acme.com>",
"to": [
"jane@example.com"
],
"template": {
"id": "welcome",
"variables": {
"NAME": "Jane"
}
}
}'{
"id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c"
}