مرجع 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"
  }
}