APIリファレンス

ホスト型テンプレート

再利用可能なコンテンツの下書き作成、レンダリング、テスト、バージョン管理、公開、送信を行います。

GET/templates
APIキー

ホスト型テンプレートを一覧表示する

ホスト型テンプレートを一覧表示する

クエリパラメータlifecyclequery
リクエスト
curl https://sendhq.cc/api/v1/templates \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 レスポンス
{
  "data": [],
  "count": 0
}
POST/templates
APIキー

ホスト型テンプレートを作成する

ホスト型テンプレートを作成する

リクエスト
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 レスポンス
{
  "template": {
    "id": "tmpl_…",
    "key": "account-welcome"
  }
}
GET/templates/:id
APIキー

下書き、リリース、使用状況を取得する

下書き、リリース、使用状況を取得する

リクエスト
curl https://sendhq.cc/api/v1/templates/id_value \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 レスポンス
{
  "template": {
    "id": "tmpl_…"
  },
  "versions": [],
  "draft": null,
  "activeVersion": null,
  "usage": []
}
PUT/templates/:id/draft
APIキー

テンプレートの下書きを自動保存する

テンプレートの下書きを自動保存する

リクエスト
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 レスポンス
{
  "draft": {
    "id": "tmplv_…",
    "revision": 2
  }
}
POST/templates/:id/draft
APIキー

公開済みリリースから新しい下書きを作成する

公開済みリリースから新しい下書きを作成する

リクエスト
curl https://sendhq.cc/api/v1/templates/id_value/draft \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
201 レスポンス
{
  "draft": {
    "id": "tmplv_…",
    "revision": 1
  }
}
POST/templates/:id/render
APIキー

サーバーの出力をそのままレンダリングする

サーバーの出力をそのままレンダリングする

リクエスト
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 レスポンス
{
  "subject": "Welcome, Asha",
  "html": "<h1>Welcome, Asha</h1>",
  "text": "Welcome, Asha",
  "findings": []
}
POST/templates/:id/test
APIキー

テスト用スナップショットを送信する

テスト用スナップショットを送信する

リクエスト
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 レスポンス
{
  "id": "em_…",
  "isTest": true
}
POST/templates/:id/publish
APIキー

変更不可のテンプレートリリースを公開する

変更不可のテンプレートリリースを公開する

リクエスト
curl https://sendhq.cc/api/v1/templates/id_value/publish \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
201 レスポンス
{
  "version": {
    "id": "tmplv_…",
    "state": "published"
  }
}
POST/templates/:id/archive
APIキー

テンプレートをアーカイブする

テンプレートをアーカイブする

リクエスト
curl https://sendhq.cc/api/v1/templates/id_value/archive \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 レスポンス
{
  "template": {
    "id": "tmpl_…",
    "lifecycle": "archived"
  }
}
POST/templates/:id/restore
APIキー

アーカイブしたテンプレートを復元する

アーカイブしたテンプレートを復元する

リクエスト
curl https://sendhq.cc/api/v1/templates/id_value/restore \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
200 レスポンス
{
  "template": {
    "id": "tmpl_…",
    "lifecycle": "active"
  }
}