Waitlist open: get early access

API reference: Templates

11 endpoints of the Templates group.

List templates

GET/v1/templates

Parameters

NameInTypeDescription
limitqueryintegerPage size. The default and the maximum depend on the endpoint (emails 50 up to 500, received mail 50 up to 200, audit up to 200, the others 100 up to 500 or 1000). Default: 100
cursorquerystringThe next_cursor of the previous page. Opaque; pass it unchanged to the same endpoint with the same filters.

Example

curl "https://api.sendtide.ch/v1/templates" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 Templates
Response fields
dataarray<Template>
data[].idstring
data[].aliasstring
data[].namestring
data[].kindenum: visual | code
data[].published_versioninteger | null
data[].sub_allowboolean
data[].draftTemplateVersion
data[].draft.kindenum: visual | code
data[].draft.styleobject
data[].draft.langsobject
data[].languagesarray<string>
data[].updated_atstring (date-time)
next_cursorstring | null

Create a template

POST/v1/templates

Request body application/json

FieldTypeDescription
aliasstring
namestring
kindenum: visual | code
styleobject
langsobject
sub_allowboolean
publishboolean
notestring

Example

curl -X POST "https://api.sendtide.ch/v1/templates" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"alias":"welcome","name":"Willkommen","kind":"code","langs":{"de-CH":{"subject":"Willkommen, {{ data.name }}","html":"<p>Hallo {{ data.name }}</p>"}},"publish":true}'

Responses

StatusDescription
201 Created Template
Response fields
idstring
aliasstring
namestring
kindenum: visual | code
published_versioninteger | null
sub_allowboolean
draftTemplateVersion
draft.kindenum: visual | code
draft.styleobject
draft.style.accentstring
draft.style.bgstring
draft.style.fontstring
draft.style.widthinteger
draft.langsobject
languagesarray<string>
updated_atstring (date-time)
409 Error in the usual format, errors and limits
422 Error in the usual format, errors and limits

Get a template (draft and published version)

GET/v1/templates/{id}

Parameters

NameInTypeDescription
id *pathstringAlias or tpl_ id

Example

curl "https://api.sendtide.ch/v1/templates/welcome" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 The template Template
Response fields
idstring
aliasstring
namestring
kindenum: visual | code
published_versioninteger | null
sub_allowboolean
draftTemplateVersion
draft.kindenum: visual | code
draft.styleobject
draft.style.accentstring
draft.style.bgstring
draft.style.fontstring
draft.style.widthinteger
draft.langsobject
languagesarray<string>
updated_atstring (date-time)

Change the draft (publish with "publish": true)

PATCH/v1/templates/{id}

A language set to null is removed. Sending always uses the published version.

Parameters

NameInTypeDescription
id *pathstringAlias or tpl_ id

Request body application/json

FieldTypeDescription
aliasstring
namestring
kindenum: visual | code
styleobject
langsobject
sub_allowboolean
publishboolean
notestring

Example

curl -X PATCH "https://api.sendtide.ch/v1/templates/welcome" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"langs":{"de-CH":{"subject":"Willkommen, {{ data.name }}"}},"publish":true}'

Responses

StatusDescription
200 Updated Template
Response fields
idstring
aliasstring
namestring
kindenum: visual | code
published_versioninteger | null
sub_allowboolean
draftTemplateVersion
draft.kindenum: visual | code
draft.styleobject
draft.style.accentstring
draft.style.bgstring
draft.style.fontstring
draft.style.widthinteger
draft.langsobject
languagesarray<string>
updated_atstring (date-time)

Delete a template

DELETE/v1/templates/{id}

Parameters

NameInTypeDescription
id *pathstringAlias or tpl_ id

Example

curl -X DELETE "https://api.sendtide.ch/v1/templates/welcome" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
204 Deleted

Publish the draft as a new version

POST/v1/templates/{id}/publish

Parameters

NameInTypeDescription
id *pathstring

Request body application/json

FieldTypeDescription
notestring

Example

curl -X POST "https://api.sendtide.ch/v1/templates/welcome/publish" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{}'

Responses

StatusDescription
200 Published Template
Response fields
idstring
aliasstring
namestring
kindenum: visual | code
published_versioninteger | null
sub_allowboolean
draftTemplateVersion
draft.kindenum: visual | code
draft.styleobject
draft.style.accentstring
draft.style.bgstring
draft.style.fontstring
draft.style.widthinteger
draft.langsobject
languagesarray<string>
updated_atstring (date-time)

Render a preview with data

POST/v1/templates/{id}/render

Parameters

NameInTypeDescription
id *pathstring

Request body application/json

FieldTypeDescription
dataobject
localestring
versionstring"draft", "published" or a version number Default: "draft" Example: 3
contentTemplateVersionUnsaved working copy to render instead of a stored version
content.kindenum: visual | code
content.styleobject
content.style.accentstring
content.style.bgstring
content.style.fontstring
content.style.widthinteger
content.langsobject

Example

curl -X POST "https://api.sendtide.ch/v1/templates/welcome/render" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"version":"3"}'

Responses

StatusDescription
200 Rendered
Response fields
localestring
subjectstring
htmlstring
textstring
missing_variablesarray<string>

Send a test mail

POST/v1/templates/{id}/test

Renders the template and sends one mail with "[Test]" before the subject. Needs a key with send rights.

Parameters

NameInTypeDescription
id *pathstring

Request body application/json

FieldTypeDescription
from *stringExample: Shop <hallo@example.ch>
to *string (email)
dataobject
localestring
versionstring"draft" (default), "published" or a version number
contentTemplateVersionUnsaved working copy
content.kindenum: visual | code
content.styleobject
content.style.accentstring
content.style.bgstring
content.style.fontstring
content.style.widthinteger
content.langsobject
attachmentsarray<Attachment>Files sent with the test mail
attachments[].filename *stringSanitized: path and control characters are removed. Executable and script files are refused. Example: rechnung.pdf
attachments[].content *string (base64)
attachments[].content_typestringTaken from the file extension if missing Example: application/pdf
attachments[].content_idstringMakes the file an inline image; the HTML refers to it as src="cid:logo" Example: logo
attachments[].dispositionenum: attachment | inlineDefault inline with a content_id, else attachment
streamstring

Example

curl -X POST "https://api.sendtide.ch/v1/templates/welcome/test" \
  -H "Authorization: Bearer sk_test_…" \
  -H "Content-Type: application/json" \
  -d '{"from":"Shop <hallo@example.ch>","to":"anna@example.com"}'

Responses

StatusDescription
202 Queued EmailAccepted
Response fields
idstringExample: msg_8kq2m4bt
statusenum: queued | suppressed | held
send_atstring (date-time)
held_reasonenum: bulk_reviewOnly when the status is held: the mail was accepted but waits for a review of the platform (see Held mail)
422 Error in the usual format, errors and limits

List published versions, newest first

GET/v1/templates/{id}/versions

Parameters

NameInTypeDescription
id *pathstring

Example

curl "https://api.sendtide.ch/v1/templates/welcome/versions" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 Versions
Response fields
dataarray<TemplateVersionInfo>
data[].versioninteger
data[].notestring
data[].publishedbooleanThis is the version that mail is sent with
data[].created_atstring (date-time)
data[].contentTemplateVersionOnly when getting one version
data[].content.kindenum: visual | code
data[].content.styleobject
data[].content.langsobject

Get one version with its content

GET/v1/templates/{id}/versions/{version}

Parameters

NameInTypeDescription
id *pathstring
version *pathstringA number or "published"

Example

curl "https://api.sendtide.ch/v1/templates/welcome/versions/3" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 The version TemplateVersionInfo
Response fields
versioninteger
notestring
publishedbooleanThis is the version that mail is sent with
created_atstring (date-time)
contentTemplateVersionOnly when getting one version
content.kindenum: visual | code
content.styleobject
content.style.accentstring
content.style.bgstring
content.style.fontstring
content.style.widthinteger
content.langsobject
404 Error in the usual format, errors and limits

Copy a version into the draft

POST/v1/templates/{id}/versions/{version}/restore

The published version stays until the draft is published again.

Parameters

NameInTypeDescription
id *pathstring
version *pathstring

Example

curl -X POST "https://api.sendtide.ch/v1/templates/welcome/versions/3/restore" \
  -H "Authorization: Bearer sk_test_…"

Responses

StatusDescription
200 Draft restored Template
Response fields
idstring
aliasstring
namestring
kindenum: visual | code
published_versioninteger | null
sub_allowboolean
draftTemplateVersion
draft.kindenum: visual | code
draft.styleobject
draft.style.accentstring
draft.style.bgstring
draft.style.fontstring
draft.style.widthinteger
draft.langsobject
languagesarray<string>
updated_atstring (date-time)