Skip to content

Templates

Reusable emails with variables, sent by id or alias.

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

POST/templates

Creates a draft.

Body
  • namestringrequired

    The template's name.

  • htmlstringrequired

    HTML with variables, up to 2 MB.

  • textstring

    Plain-text version, up to 1 MB.

  • subjectstring

    Default subject (can use variables). Required to publish.

  • aliasstring

    A stable name to send with: lowercase letters, numbers, _ and -, up to 64 characters.

  • from · reply_tostring

    Defaults used when a send leaves them out.

  • variablesarray

    Up to 50 { key, type, fallback_value }; type is string (default) or number. Variables used but not declared are added for you.

POST/templates
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"
    }
  ]
}'
Response
{
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "object": "template"
}

Publish a template

POST/templates/{id}/publish

Makes the template sendable. Needs a subject.

Path parameters
  • idstringrequired

    The template id.

POST/templates/{id}/publish
curl -X POST 'https://api.iresendly.com/templates/{id}/publish' \
  -H 'Authorization: Bearer irs_xxxxxxxxx'
Response
{
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "object": "template"
}

Retrieve a template

GET/templates/{id|alias}

The full template.

Path parameters
  • id|aliasstringrequired

    The template id or alias.

GET/templates/{id|alias}
curl -X GET 'https://api.iresendly.com/templates/{id|alias}' \
  -H 'Authorization: Bearer irs_xxxxxxxxx'
Response
{
  "object": "template",
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "name": "Welcome",
  "alias": "welcome",
  "status": "published"
}

List templates

GET/templates

Every template, without bodies.

Query parameters
  • limitnumber

    Results per page, 1–100. Default 20.

  • afterstring

    Return results after this id (next page).

  • beforestring

    Return results before this id (previous page). Don't send with after.

GET/templates
curl -X GET 'https://api.iresendly.com/templates' \
  -H 'Authorization: Bearer irs_xxxxxxxxx'
Response
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "template",
      "id": "34a080c9-b17d-4187-ad80-5af20266e535",
      "name": "Welcome",
      "alias": "welcome",
      "status": "published"
    }
  ]
}

Update a template

PATCH/templates/{id|alias}

Changes any field. A published template stays published, so the change is live at once.

Path parameters
  • id|aliasstringrequired

    The template id or alias.

PATCH/templates/{id|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}}}!"
}'
Response
{
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "object": "template"
}

Duplicate a template

POST/templates/{id|alias}/duplicate

Creates a draft copy named “(copy)”, without the alias.

Path parameters
  • id|aliasstringrequired

    The template id or alias.

POST/templates/{id|alias}/duplicate
curl -X POST 'https://api.iresendly.com/templates/{id|alias}/duplicate' \
  -H 'Authorization: Bearer irs_xxxxxxxxx'
Response
{
  "id": "b8f51c2e-9d3a-4f6b-8e1c-2a7d9f0b3c41",
  "object": "template"
}

Delete a template

DELETE/templates/{id|alias}

Deletes it permanently.

Path parameters
  • id|aliasstringrequired

    The template id or alias.

DELETE/templates/{id|alias}
curl -X DELETE 'https://api.iresendly.com/templates/{id|alias}' \
  -H 'Authorization: Bearer irs_xxxxxxxxx'
Response
{
  "object": "template",
  "id": "34a080c9-b17d-4187-ad80-5af20266e535",
  "deleted": true
}

Send with a template

POST/emailsSending keys allowed

Pass template instead of html and text. A variable with no value and no fallback returns 422.

POST/emails
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"
    }
  }
}'
Response
{
  "id": "4ef9a417-02e9-4d39-ad75-9611e0fcc33c"
}
Still stuck? Write to us and we'll reply by email.Contact ussupport@iresendly.com