لا تُحصَّل مدفوعات عبر الـ API: رسم التقديم يدفعه المتقدّم من النموذج العام عبر StreamPay، والتحقق من الدفع على الخادم.
نقاط الاتصال
GEThttps://form.emm.sa/api/v1/me
الهوية والخطة والحدود / Identity, plan, quotas
يتحقق من المفتاح ويعيد المستخدم والخطة الحالية وحدود النماذج والردود الشهرية. Checks a key; returns user, current plan and quotas. · الصلاحية: read
curl -X GET "https://form.emm.sa/api/v1/me" \
-H "Authorization: Bearer $EMM_KEY"
{"plan":{"api":true,"csv_export":false,"currency":"SAR","features":["نموذج واحد","100 رد شهرياً","بدون رسوم","11 نوع حقل مع التحقق","منطق شرطي (تخطي الأسئلة)","REST API وMCP وWebhooks (متاحة في كل الخطط)"],"id":"free","limits":{"forms":1,"monthly_responses":100},"name":"مجاني","paid_applications":false,"period":"month","price":"0.00"},"quotas":{"forms":{"limit":1,"used":0},"responses":{"limit":100,"month":"2026-12","used":4}},"service":"form","user":{"email":"user@example.com","org_name":"جهة"}}
GEThttps://form.emm.sa/api/v1/plan
الخطة الحالية وكل الخطط / Current plan and catalogue
الخطة الحالية مع الاستهلاك، وكل الخطط بأسعارها وحدودها. Current plan with usage plus every plan (SAR/month). · الصلاحية: read
curl -X GET "https://form.emm.sa/api/v1/plan" \
-H "Authorization: Bearer $EMM_KEY"
GEThttps://form.emm.sa/api/v1/forms
النماذج / Forms
قائمة نماذجك مع عدد الردود والمعلّقة. Lists your forms with response counts. · المعاملات: limitoffsetstatus · الصلاحية: read
curl -X GET "https://form.emm.sa/api/v1/forms?limit=50&offset=0&status=" \
-H "Authorization: Bearer $EMM_KEY"
POSThttps://form.emm.sa/api/v1/forms
إنشاء نموذج / Create form
ينشئ نموذجاً (ضمن حد الخطة) مع حقول اختيارية. Creates a form within the plan limit (409 quota_exceeded), optionally with its fields. · الصلاحية: write
curl -X POST "https://form.emm.sa/api/v1/forms" \
-H "Authorization: Bearer $EMM_KEY" \
-H "Content-Type: application/json" \
-d '{"title":"طلب منحة","slug":"grant","description":"نموذج تقديم على المنحة","fee":"0.00","max_submissions":200,"status":"open","fields":[{"type":"short","label":"الاسم الكامل","required":true},{"type":"national_id","label":"الهوية","required":true},{"type":"phone","label":"جوال","required":true},{"type":"select","label":"الفئة","options":["طالب","موظف"]},{"type":"file","label":"السيرة الذاتية","cond_index":3,"cond_value":"طالب"}]}'
تعديل جزئي (العنوان، الرابط، الرسم، التواريخ، الحد الأقصى، الحالة، اللون). fields عند إرسالها: عنصر بـ id يعدّل الحقل، وبلا id يضيفه (لا يحذف شيئاً). Partial update; fields sync (update by id, create without id). · المعاملات: id* · الصلاحية: write
قائمة عناوين الـWebhook المسجّلة (لكل نموذج أو لكل النماذج). Lists registered webhook endpoints. · المعاملات: limitoffset · الصلاحية: read
curl -X GET "https://form.emm.sa/api/v1/webhooks?limit=50&offset=0" \
-H "Authorization: Bearer $EMM_KEY"
POSThttps://form.emm.sa/api/v1/webhooks
تسجيل Webhook / Register webhook
يسجّل https URL مع سر HMAC (أو يولّده) لحدث submission.paid — form_id = 0 لكل نماذجك. Registers a URL + HMAC secret for paid submissions. · الصلاحية: write
v1 = hex(HMAC-SHA256(secret, t + "." + raw_body)). تحقق في ثابت الوقت وارفض إن كان t أقدم من 5 دقائق. 3 محاولات (0s · 5s · 30s)، 2xx = نجاح، السجل في GET /webhooks/{id}/deliveries.
# التحقق من التوقيع (أي لغة): HMAC-SHA256(secret, t + "." + raw_body) == v1
# Python:
import hmac, hashlib
def verify(secret, header, body):
parts = dict(p.split("=", 1) for p in header.split(","))
mac = hmac.new(secret.encode(), f"{parts['t']}.".encode() + body, hashlib.sha256).hexdigest()
return hmac.compare_digest(mac, parts["v1"])
MCP
نفس المفتاح، POST إلى https://form.emm.sa/mcp (JSON-RPC 2.0, Streamable HTTP): initialize ← notifications/initialized ← tools/list ← tools/call. الأدوات: form_capabilities, form_pricing, form_list, form_submissions, form_create, form_update, form_review. مثال كامل في دليل الوكلاء.