توثيق API — حضور EMM

REST فوق HTTPS بمصادقة مفتاح API. الإصدار 1.0.0 · openapi.json · خادم MCP · ملخص للنماذج

المصادقة

أنشئ مفتاحاً من صفحة المفاتيح (تسجيل الدخول مطلوب). أرسله في كل طلب:

Authorization: Bearer emm_booking_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# أو
X-API-Key: emm_booking_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • بلا مفتاح أو مفتاح غير صالح/ملغى → 401
  • مفتاح بلا صلاحية للعملية → 403
  • الصلاحيات: read للقوائم والقراءة، write لتسجيل البصمات والقيام والتعديل، admin للحذف وإعادة تعيين الرقم السري والاستيراد.

الحدود والصيغة

  • الحد: 60 طلباً/دقيقة لكل مفتاح؛ بعدها 429 مع ترويسة Retry-After بالثواني.
  • النجاح: {"ok":true,"data":…} · الخطأ: {"ok":false,"error":{"code":"…","message":"…"}}
  • القوائم: ?limit=N (من 1 إلى 200، الافتراضي 50) و?offset=N؛ النتيجة data.items وdata.total.
  • المبالغ نص بالريال بمنزلتين ("200.00")، العملة SAR، التواريخ ISO-8601 بتوقيت +03:00.
  • لا تُحصَّل مدفوعات عبر الـ API: الاشتراك يُدفع من داخل التطبيق عبر StreamPay. كشف الرواتب مرجعي للمراجعة وليس قيداً رسمياً.

نقاط الاتصال

GEThttps://staff.emm.sa/api/v1/me

الهوية والخطة والحدود / Identity, plan, quotas

يتحقق من المفتاح ويعيد المستخدم والخطة الحالية وحدود الموظفين والأجهزة. Checks a key; returns user, plan and quotas. · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/me" \
  -H "Authorization: Bearer $EMM_KEY"
{"plan":{"currency":"SAR","features":["حتى 10 موظفين","جهاز بصمة ZKTeco واحد","تسجيل حضور يدوي وصفحة تسجيل ذاتي برقم سري","حالة اليوم (حاضر · متأخر · غائب · راحة)","العربية الكاملة للجوال"],"id":"starter","limits":{"devices":1,"employees":10,"salary_periods":false},"name":"ابدأ","period":"month","price":"0.00"},"quotas":{"devices":{"limit":1,"used":1},"employees":{"limit":10,"used":3}},"service":"staff","user":{"email":"user@example.com"}}

GEThttps://staff.emm.sa/api/v1/plan

الخطة الحالية وكل الخطط / Current plan and catalogue

الخطة الحالية مع الاستهلاك وكل الخطط بأسعارها وحدودها. Current plan with usage plus every plan (SAR/month). · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/plan" \
  -H "Authorization: Bearer $EMM_KEY"

GEThttps://staff.emm.sa/api/v1/settings

قواعد الحضور والرواتب / Attendance & payroll rules

أسبوع العمل، الدوام، الساعات اليومية، يوم بداية الفترة، السماح بالتأخير، قواسم الخصم. Workweek, shift, daily hours, period start day, grace, deduction rules. · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/settings" \
  -H "Authorization: Bearer $EMM_KEY"
{"absent_ded_divisor":30,"currency":"SAR","daily_hours":8,"late_ded_per_min":"0.00","late_grace_min":15,"name":"شركة النور","period_start_day":26,"shift_end":"17:00","shift_start":"09:00","timezone":"Asia/Riyadh","workweek":[true,true,true,true,true,false,false]}

PUThttps://staff.emm.sa/api/v1/settings

تحديث القواعد / Update rules

تحديث جزئي: name, workweek[7] (0=الأحد), shift_start, shift_end (HH:MM), daily_hours, period_start_day (1–31), late_grace_min, absent_ded_divisor, late_ded_per_min. Partial update. · الصلاحية: write

curl -X PUT "https://staff.emm.sa/api/v1/settings" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"شركة النور","workweek":[true,true,true,true,true,false,false],"shift_start":"09:00","shift_end":"17:00","daily_hours":8,"period_start_day":26,"late_grace_min":15,"absent_ded_divisor":30}'
{"absent_ded_divisor":30,"currency":"SAR","daily_hours":8,"late_ded_per_min":"0.00","late_grace_min":15,"name":"شركة النور","period_start_day":26,"shift_end":"17:00","shift_start":"09:00","timezone":"Asia/Riyadh","workweek":[true,true,true,true,true,false,false]}

GEThttps://staff.emm.sa/api/v1/notifications

تفضيلات الإشعارات / Notification preferences

تفضيلات محفوظة (الإرسال غير مفعّل بعد). Saved preferences (delivery not enabled yet). · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/notifications" \
  -H "Authorization: Bearer $EMM_KEY"
{"absent_alert":true,"delivery_enabled":false,"device_offline":true,"email":"","period_ready":true,"phone":""}

PUThttps://staff.emm.sa/api/v1/notifications

حفظ تفضيلات الإشعارات / Save notification preferences

يحفظ ما يريد العميل إشعاره به عند تفعيل الإرسال. Saves what the customer wants to be notified about once delivery is enabled. · الصلاحية: write

curl -X PUT "https://staff.emm.sa/api/v1/notifications" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"absent_alert":true,"delivery_enabled":false,"device_offline":true,"email":"","period_ready":true,"phone":""}'
{"absent_alert":true,"delivery_enabled":false,"device_offline":true,"email":"","period_ready":true,"phone":""}

GEThttps://staff.emm.sa/api/v1/employees

الموظفون / Employees

قائمة الموظفين (فلتر active=1|0 و q للبحث بالاسم/الرمز/الرقم الوظيفي). Lists employees. · المعاملات: limit offset active q · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/employees?limit=50&offset=0&active=&q=" \
  -H "Authorization: Bearer $EMM_KEY"

POSThttps://staff.emm.sa/api/v1/employees

إضافة موظف / Add employee

يضيف موظفاً ضمن حد الخطة (409 quota_exceeded) ويصدر رقماً سرياً يُعاد مرة واحدة. Adds an employee within the plan quota; the PIN is returned once. · الصلاحية: write

curl -X POST "https://staff.emm.sa/api/v1/employees" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"أحمد سالم","job_title":"باريستا","emp_ref":"10xxxxxxx1","basic_salary":3000,"allowances":200,"zk_user_id":"1001","hire_date":"2026-01-01"}'
{"employee":{"active":true,"allowances":"200.00","basic_salary":"3000.00","code":"A1B2C3","emp_ref":"10xxxxxxx1","hire_date":"2026-01-01","id":1,"job_title":"باريستا","kiosk_url":"https://staff.emm.sa/in/A1B2C3","name":"أحمد سالم","zk_user_id":"1001"},"note":"الرقم السري يُعرض مرة واحدة","pin":"4821"}

GEThttps://staff.emm.sa/api/v1/employees/{id}

موظف / Employee

بيانات موظف واحد مع ملخص الفترة الحالية. One employee with the current-period summary. · المعاملات: id* · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/employees/{id}" \
  -H "Authorization: Bearer $EMM_KEY"
{"active":true,"allowances":"200.00","basic_salary":"3000.00","code":"A1B2C3","emp_ref":"10xxxxxxx1","hire_date":"2026-01-01","id":1,"job_title":"باريستا","kiosk_url":"https://staff.emm.sa/in/A1B2C3","name":"أحمد سالم","zk_user_id":"1001"}

PATCHhttps://staff.emm.sa/api/v1/employees/{id}

تعديل موظف / Update employee

تعديل الاسم، المسمى، الرقم الوظيفي، الراتب، البدلات، رقم جهاز البصمة، تاريخ التعيين، التفعيل. Partial update. · المعاملات: id* · الصلاحية: write

curl -X PATCH "https://staff.emm.sa/api/v1/employees/{id}" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"أحمد سالم","job_title":"باريستا","emp_ref":"10xxxxxxx1","basic_salary":3000,"allowances":200,"zk_user_id":"1001","hire_date":"2026-01-01"}'
{"active":true,"allowances":"200.00","basic_salary":"3000.00","code":"A1B2C3","emp_ref":"10xxxxxxx1","hire_date":"2026-01-01","id":1,"job_title":"باريستا","kiosk_url":"https://staff.emm.sa/in/A1B2C3","name":"أحمد سالم","zk_user_id":"1001"}

DELETEhttps://staff.emm.sa/api/v1/employees/{id}

حذف موظف / Delete employee

يحذف الموظف وبصماته وقيام أيامه. Deletes the employee with punches and day marks. · المعاملات: id* · الصلاحية: admin

curl -X DELETE "https://staff.emm.sa/api/v1/employees/{id}" \
  -H "Authorization: Bearer $EMM_KEY"
{"data":{"deleted":true},"ok":true}

POSThttps://staff.emm.sa/api/v1/employees/{id}/pin-reset

رقم سري جديد / Reset kiosk PIN

يصدر رقماً جديداً لصفحة التسجيل الذاتي ويُعاد مرة واحدة. Issues a new self check-in PIN (returned once). · المعاملات: id* · الصلاحية: admin

curl -X POST "https://staff.emm.sa/api/v1/employees/{id}/pin-reset" \
  -H "Authorization: Bearer $EMM_KEY"
{"employee_id":1,"kiosk_url":"https://staff.emm.sa/in/A1B2C3","note":"الرقم السري يُعرض مرة واحدة","pin":"4821"}

POSThttps://staff.emm.sa/api/v1/employees/import

استيراد موظفين من CSV / Import employees (CSV)

multipart/form-data بحقل csv (الأعمدة عربية أو إنجليزية كقالب /app/employees/import.csv). يُعاد added/skipped/failed/errors. Multipart CSV import. · الصلاحية: admin

curl -X POST "https://staff.emm.sa/api/v1/employees/import" \
  -H "Authorization: Bearer $EMM_KEY"
{"added":3,"errors":[],"failed":0,"skipped":1}

GEThttps://staff.emm.sa/api/v1/devices

أجهزة البصمة / Devices

الأجهزة مع حالتها (online|offline) وآخر مزامنة وآخر سجل. Devices with status, last poll and last record. · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/devices" \
  -H "Authorization: Bearer $EMM_KEY"

GEThttps://staff.emm.sa/api/v1/devices/{id}

جهاز / Device

جهاز واحد بحالته وأخطائه الأخيرة. One device. · المعاملات: id* · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/devices/{id}" \
  -H "Authorization: Bearer $EMM_KEY"
{"id":1,"ip":"192.168.1.50","last_ok":"2026-12-02T20:40:00+03:00","last_poll":"2026-12-02T20:40:00+03:00","last_record_at":"2026-12-02T17:02:11+03:00","name":"جهاز بصمة 1","platform":"ZK609","port":4370,"status":"online"}

GEThttps://staff.emm.sa/api/v1/punches

البصمات / Punches

بصمات في نطاق تاريخي (≤ 92 يوماً) مع فلتر employee_id. Punches in a date range with optional employee filter. · المعاملات: from to employee_id limit offset · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/punches?from=&to=&employee_id=&limit=50&offset=0" \
  -H "Authorization: Bearer $EMM_KEY"

POSThttps://staff.emm.sa/api/v1/punches

بصمة يدوية / Manual punch

يسجّل حضوراً/انصرافاً لموظف (نفس التحقق من الشاشة). Records a manual in/out punch (idempotent on same employee+time+direction). · الصلاحية: write

curl -X POST "https://staff.emm.sa/api/v1/punches" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"employee_id":1,"at":"2026-12-02T09:05","direction":"in"}'
{"at":"2026-12-02T09:05:00+03:00","created":true,"direction":"in","employee_id":1,"employee_name":"أحمد سالم","id":10,"source":"manual"}

DELETEhttps://staff.emm.sa/api/v1/punches/{id}

حذف بصمة / Delete punch

يحذف بصمة يدوية. Deletes a punch. · المعاملات: id* · الصلاحية: write

curl -X DELETE "https://staff.emm.sa/api/v1/punches/{id}" \
  -H "Authorization: Bearer $EMM_KEY"
{"data":{"deleted":true},"ok":true}

GEThttps://staff.emm.sa/api/v1/days/status

حالة اليوم لنطاق / Day status (range)

حالة كل موظف لكل يوم في نطاق (≤ 62 يوماً): present|late|absent|off|leave|pending|na. Per-employee per-day status. · المعاملات: from to employee_id limit offset · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/days/status?from=&to=&employee_id=&limit=50&offset=0" \
  -H "Authorization: Bearer $EMM_KEY"

POSThttps://staff.emm.sa/api/v1/days/{emp}/{day}/mark

قيام اليوم / Mark a day

يسجّل حالة يدوية (leave|absent|present|off) لموظف ويوم مع ملاحظة. Sets a manual day status. · المعاملات: emp* day* · الصلاحية: write

curl -X POST "https://staff.emm.sa/api/v1/days/{emp}/{day}/mark" \
  -H "Authorization: Bearer $EMM_KEY" \
  -H "Content-Type: application/json" \
  -d '{"status":"leave","note":"إجازة سنوية"}'
{"data":{"deleted":true},"ok":true}

GEThttps://staff.emm.sa/api/v1/periods

فترات الرواتب / Salary periods

آخر 12 فترة (الأحدث أولاً) مع مفتاح الفترة وحالة الإغلاق. Latest periods with key and closed flag. · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/periods" \
  -H "Authorization: Bearer $EMM_KEY"

GEThttps://staff.emm.sa/api/v1/reports/period

كشف فترة (JSON) / Period report (JSON)

كشف الرواتب لفترة (period=YYYY-MM-DD مفتاح الفترة؛ الافتراضي الحالية). يحتاج خطة تدعم الرواتب (403 plan_limit). Payroll rows + totals. · المعاملات: period · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/reports/period?period=" \
  -H "Authorization: Bearer $EMM_KEY"

GEThttps://staff.emm.sa/api/v1/reports/period.csv

كشف فترة (CSV مرجعي) / Period report (reference CSV)

كشف رواتب CSV بأعمدة مرجعية شبيهة بقيود التأمينات موسومة «مرجعي» — ليس قيداً رسمياً. Payroll CSV with GOSI-like reference columns. · المعاملات: period · الصلاحية: read

curl -X GET "https://staff.emm.sa/api/v1/reports/period.csv?period=" \
  -H "Authorization: Bearer $EMM_KEY"

MCP

نفس المفتاح، POST إلى https://staff.emm.sa/mcp (JSON-RPC 2.0, Streamable HTTP): initialize ← notifications/initialized ← tools/list ← tools/call. الأدوات: staff_capabilities, staff_pricing, staff_employees, staff_punches, staff_day_status, staff_period_report, staff_periods, staff_devices, staff_punch_create, staff_mark_day, staff_pin_reset. مثال كامل في دليل الوكلاء.