API-referentie

Gehoste templates

Herbruikbare inhoud opstellen, renderen, testen, versioneren, publiceren en verzenden.

GET/templates
API-sleutel

Gehoste templates opvragen

Gehoste templates opvragen

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

Een gehoste template aanmaken

Een gehoste template aanmaken

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-respons
{
  "template": {
    "id": "tmpl_…",
    "key": "account-welcome"
  }
}
GET/templates/:id
API-sleutel

Concepten, releases en gebruik ophalen

Concepten, releases en gebruik ophalen

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

Een templateconcept automatisch opslaan

Een templateconcept automatisch opslaan

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-respons
{
  "draft": {
    "id": "tmplv_…",
    "revision": 2
  }
}
POST/templates/:id/draft
API-sleutel

Een nieuw concept maken op basis van de gepubliceerde release

Een nieuw concept maken op basis van de gepubliceerde release

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

De exacte serveruitvoer renderen

De exacte serveruitvoer renderen

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-respons
{
  "subject": "Welcome, Asha",
  "html": "<h1>Welcome, Asha</h1>",
  "text": "Welcome, Asha",
  "findings": []
}
POST/templates/:id/test
API-sleutel

Een testsnapshot verzenden

Een testsnapshot verzenden

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-respons
{
  "id": "em_…",
  "isTest": true
}
POST/templates/:id/publish
API-sleutel

Een onveranderlijke templaterelease publiceren

Een onveranderlijke templaterelease publiceren

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

Een template archiveren

Een template archiveren

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

Een gearchiveerde template herstellen

Een gearchiveerde template herstellen

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