API reference

เทมเพลตแบบโฮสต์

ร่าง เรนเดอร์ ทดสอบ กำหนดเวอร์ชัน เผยแพร่ และส่งเนื้อหาที่นำกลับมาใช้ซ้ำได้

GET/templates
API key

แสดงรายการเทมเพลตแบบโฮสต์

แสดงรายการเทมเพลตแบบโฮสต์

พารามิเตอร์คิวรีlifecyclequery
คำขอ
curl https://sendhq.cc/api/v1/templates \
  -X GET \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
การตอบกลับ 200
{
  "data": [],
  "count": 0
}
POST/templates
API key

สร้างเทมเพลตแบบโฮสต์

สร้างเทมเพลตแบบโฮสต์

คำขอ
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 key

ดึงฉบับร่าง รุ่นที่เผยแพร่ และการใช้งาน

ดึงฉบับร่าง รุ่นที่เผยแพร่ และการใช้งาน

คำขอ
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 key

บันทึกฉบับร่างของเทมเพลตอัตโนมัติ

บันทึกฉบับร่างของเทมเพลตอัตโนมัติ

คำขอ
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 key

สร้างฉบับร่างใหม่จากรุ่นที่เผยแพร่

สร้างฉบับร่างใหม่จากรุ่นที่เผยแพร่

คำขอ
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 key

เรนเดอร์ผลลัพธ์จริงจากเซิร์ฟเวอร์

เรนเดอร์ผลลัพธ์จริงจากเซิร์ฟเวอร์

คำขอ
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 key

ส่งสแนปชอตทดสอบ

ส่งสแนปชอตทดสอบ

คำขอ
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 key

เผยแพร่รุ่นเทมเพลตที่แก้ไขไม่ได้

เผยแพร่รุ่นเทมเพลตที่แก้ไขไม่ได้

คำขอ
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 key

เก็บถาวรเทมเพลต

เก็บถาวรเทมเพลต

คำขอ
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 key

กู้คืนเทมเพลตที่เก็บถาวร

กู้คืนเทมเพลตที่เก็บถาวร

คำขอ
curl https://sendhq.cc/api/v1/templates/id_value/restore \
  -X POST \
  -H "Authorization: Bearer $SENDHQ_API_KEY"
การตอบกลับ 200
{
  "template": {
    "id": "tmpl_…",
    "lifecycle": "active"
  }
}