Riferimento API

Template ospitati

Crea bozze, renderizza, testa, versiona, pubblica e invia contenuti riutilizzabili.

GET/templates
Chiave API

Elenca i template ospitati

Elenca i template ospitati

Parametri di querylifecyclequery
Richiesta
curl https://sendhq.cc/api/v1/templates \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
Risposta 200
{
  "data": [],
  "count": 0
}
POST/templates
Chiave API

Crea un template ospitato

Crea un template ospitato

Richiesta
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"}'
Risposta 201
{
  "template": {
    "id": "tmpl_…",
    "key": "account-welcome"
  }
}
GET/templates/:id
Chiave API

Recupera bozze, release e utilizzo

Recupera bozze, release e utilizzo

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

Salva automaticamente la bozza di un template

Salva automaticamente la bozza di un template

Richiesta
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"}}'
Risposta 200
{
  "draft": {
    "id": "tmplv_…",
    "revision": 2
  }
}
POST/templates/:id/draft
Chiave API

Crea una nuova bozza dalla release pubblicata

Crea una nuova bozza dalla release pubblicata

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

Renderizza l'output esatto del server

Renderizza l'output esatto del server

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

Invia uno snapshot di test

Invia uno snapshot di test

Richiesta
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"}}'
Risposta 201
{
  "id": "em_…",
  "isTest": true
}
POST/templates/:id/publish
Chiave API

Pubblica una release immutabile del template

Pubblica una release immutabile del template

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

Archivia un template

Archivia un template

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

Ripristina un template archiviato

Ripristina un template archiviato

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