sendsend.email

Create or publish a template

POST/v1/templates

Publishes an immutable version. Posting an existing id publishes the next version; versions are never edited. Write the content as html and/or text, or build it from a visual design (a list of blocks, the same builder as the dashboard) and we generate the HTML and plain text. If you send only HTML, a plain-text version is made for you. Use {{name}} placeholders and declare each one under variables (types: string, number, boolean, array, object); values are escaped in HTML when sending. The template language also has {{name | fallback}}, filters such as upper, currency:'USD' and date, conditions ({{#if plan == 'pro'}}…{{else}}…{{/if}}) and loops ({{#each items as item}}{{item.name}}{{/each}}). Add translations ({ fr: { subject, html, text } }) and send with language to use them; anything a translation leaves out comes from the main version. A mistake in a template, or a variable it uses without declaring, is refused with a message that says where.

Required scope: templates:manage

Request body

FieldType
idrequiredstring
nameoptionalstring
categoryoptionalstring
subjectrequiredstring
htmloptionalstring
textoptionalstring
designoptionalobject
translationsoptionalobject
variablesoptionalobject

Unknown fields are rejected, so a typo never silently does nothing.

Example

curl -X POST 'https://api.sendsend.email/v1/templates' \
  -H "Authorization: Bearer $SENDSEND_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "id": "welcome",
  "name": "Welcome",
  "subject": "Welcome, {{first_name}}",
  "html": "<p>Hi {{first_name}}!</p>",
  "variables": {
    "first_name": {
      "type": "string",
      "required": true
    }
  }
}'

Response 201

{
  "object": "template",
  "id": "welcome",
  "version": 1
}

Errors

StatusCodeWhen
400validation_errorThe request body or parameters are invalid. The message says which field.
401unauthorizedThe API key is missing, invalid or revoked.
403forbiddenThe key does not have the scope this endpoint needs.

Every error has the same shape. See Errors.