API

Templatesv1

Store reusable subjects and bodies, then reference them in transmissions.

Why templates

Templates let you:

  • Keep email content versioned and reusable
  • Avoid shipping large HTML blobs from every service
  • Personalize with substitution variables

You can reference a template when sending by setting content.template_id.

Endpoints

POST Request
Bearer
POST/v1/templates

Create a template.

GET Request
Bearer
GET/v1/templates

List templates.

GET Request
Bearer
GET/v1/templates/{id}

Fetch a template.

PATCH Request
Bearer
PATCH/v1/templates/{id}

Update a template (partial).

DELETE Request
Bearer
DELETE/v1/templates/{id}

Delete a template.

Authentication

  • Required scope: send:transmissions

Create a template (example)

bash
curl -sS -X POST https://api.sendlib.com/v1/templates \
  -H "Authorization: Bearer $SENDLIB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome Email",
    "subject": "Welcome, {{.first_name}}",
    "html": "<h1>Hi {{.first_name}}</h1>",
    "text": "Hi {{.first_name}}"
  }'

HTML or text

Provide at least one of html or text.

Use a template in a transmission

json
{
  "recipients": [{"email": "user@example.com"}],
  "content": {
    "template_id": "TEMPLATE_ID",
    "substitution_data": {"first_name": "Ada"}
  }
}

Next