API reference

Hosted templates

Draft, render, test, version, publish, and send reusable content.

GET/templates
API key

List hosted templates

List hosted templates

Query parameterslifecyclequery
Request
curl https://sendhq.cc/api/v1/templates \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 Response
{
  "data": [],
  "count": 0
}
POST/templates
API key

Create a hosted template

Create a hosted template

Request
curl https://sendhq.cc/api/v1/templates \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Account welcome","key":"account-welcome","starter":"welcome"}'
201 Response
{
  "template": {
    "id": "tmpl_…",
    "key": "account-welcome"
  }
}
GET/templates/:id
API key

Retrieve drafts, releases, and usage

Retrieve drafts, releases, and usage

Request
curl https://sendhq.cc/api/v1/templates/id_value \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 Response
{
  "template": {
    "id": "tmpl_…"
  },
  "versions": [],
  "draft": null,
  "activeVersion": null,
  "usage": []
}
PUT/templates/:id/draft
API key

Autosave a template draft

Autosave a template draft

Request
curl https://sendhq.cc/api/v1/templates/id_value/draft \
  -X PUT \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"revision":1,"name":"Account welcome","subjectTemplate":"Welcome, {{first_name}}","htmlTemplate":"<h1>Welcome, {{first_name}}</h1>","textTemplate":"Welcome, {{first_name}}","variables":[{"key":"first_name","type":"string","required":true}],"sampleData":{"first_name":"Asha"}}'
200 Response
{
  "draft": {
    "id": "tmplv_…",
    "revision": 2
  }
}
POST/templates/:id/draft
API key

Create a new draft from the published release

Create a new draft from the published release

Request
curl https://sendhq.cc/api/v1/templates/id_value/draft \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
201 Response
{
  "draft": {
    "id": "tmplv_…",
    "revision": 1
  }
}
POST/templates/:id/render
API key

Render exact server output

Render exact server output

Request
curl https://sendhq.cc/api/v1/templates/id_value/render \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"data":{"first_name":"Asha"}}'
200 Response
{
  "subject": "Welcome, Asha",
  "html": "<h1>Welcome, Asha</h1>",
  "text": "Welcome, Asha",
  "findings": []
}
POST/templates/:id/test
API key

Send a test snapshot

Send a test snapshot

Request
curl https://sendhq.cc/api/v1/templates/id_value/test \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to":["owner@example.com"],"from":"hello@example.com","data":{"first_name":"Asha"}}'
201 Response
{
  "id": "em_…",
  "isTest": true
}
POST/templates/:id/publish
API key

Publish an immutable template release

Publish an immutable template release

Request
curl https://sendhq.cc/api/v1/templates/id_value/publish \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
201 Response
{
  "version": {
    "id": "tmplv_…",
    "state": "published"
  }
}
POST/templates/:id/archive
API key

Archive a template

Archive a template

Request
curl https://sendhq.cc/api/v1/templates/id_value/archive \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 Response
{
  "template": {
    "id": "tmpl_…",
    "lifecycle": "archived"
  }
}
POST/templates/:id/restore
API key

Restore an archived template

Restore an archived template

Request
curl https://sendhq.cc/api/v1/templates/id_value/restore \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 Response
{
  "template": {
    "id": "tmpl_…",
    "lifecycle": "active"
  }
}