Home / Docs / API reference / API reference: Templates API reference: Templates 11 endpoints of the Templates group.
List templates GET /v1/templates
Parameters Name In Type Description limitquery integer Page 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 cursorquery string The 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 Status Description 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 Field Type Description 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 Status Description 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 Name In Type Description id * path string Alias or tpl_ id
Example curl "https://api.sendtide.ch/v1/templates/welcome" \
-H "Authorization: Bearer sk_test_…" Responses Status Description 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 Name In Type Description id * path string Alias or tpl_ id
Request body application/json Field Type Description 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 Status Description 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 Name In Type Description id * path string Alias or tpl_ id
Example curl -X DELETE "https://api.sendtide.ch/v1/templates/welcome" \
-H "Authorization: Bearer sk_test_…" Responses Status Description 204 Deleted
Publish the draft as a new version POST /v1/templates/{id}/publish
Parameters Name In Type Description id * path string
Request body application/json Field Type Description 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 Status Description 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 Name In Type Description id * path string
Request body application/json Field Type Description dataobject localestring versionstring "draft", "published" or a version number Default: "draft" Example: 3 contentTemplateVersion Unsaved 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 Status Description 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 Name In Type Description id * path string
Request body application/json Field Type Description from * string Example: Shop <hallo@example.ch> to * string (email) dataobject localestring versionstring "draft" (default), "published" or a version number contentTemplateVersion Unsaved 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 * string Sanitized: path and control characters are removed. Executable and script files are refused. Example: rechnung.pdf attachments[].content * string (base64) attachments[].content_typestring Taken from the file extension if missing Example: application/pdf attachments[].content_idstring Makes the file an inline image; the HTML refers to it as src="cid:logo" Example: logo attachments[].dispositionenum: attachment | inline Default 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 Status Description 202 Queued EmailAccepted Response fields idstring Example: msg_8kq2m4bt statusenum: queued | suppressed | held send_atstring (date-time) held_reasonenum: bulk_review Only 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 Name In Type Description id * path string
Example curl "https://api.sendtide.ch/v1/templates/welcome/versions" \
-H "Authorization: Bearer sk_test_…" Responses Status Description 200 Versions Response fields dataarray<TemplateVersionInfo> data[].versioninteger data[].notestring data[].publishedboolean This is the version that mail is sent with data[].created_atstring (date-time) data[].contentTemplateVersion Only 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 Name In Type Description id * path string version * path string A number or "published"
Example curl "https://api.sendtide.ch/v1/templates/welcome/versions/3" \
-H "Authorization: Bearer sk_test_…" Responses Status Description 200 The version TemplateVersionInfo Response fields versioninteger notestring publishedboolean This is the version that mail is sent with created_atstring (date-time) contentTemplateVersion Only 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 Name In Type Description id * path string version * path string
Example curl -X POST "https://api.sendtide.ch/v1/templates/welcome/versions/3/restore" \
-H "Authorization: Bearer sk_test_…" Responses Status Description 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)