توثيق الـ API
REST API رسمي لـ iClinicOS. Base URL: https://api.iclinicos.com/v1. كل الطلبات والردود بصيغة JSON.
⚠️ هذه النسخة تجريبية للعرض — API العام قيد التطوير (Month 6-12).
المصادقة
استخدم Bearer token في هيدر Authorization.
Authorization: Bearer ck_live_1a2b3c4d5e6f7890abcdef
Content-Type: application/json
حد الاستخدام
- 100 طلب / دقيقة / مفتاح API.
- استجابة 429 مع هيدر Retry-After عند التجاوز.
- خطة Enterprise: حدود أعلى عند الطلب.
Patients
GET/patients
قائمة المرضى مع فلترة.
GET /v1/patients?q=ahmed&limit=20
200 OK
{
"data": [
{ "id": 42, "name_ar": "أحمد محمود", "name_en": "Ahmed Mahmoud", "phone": "+201000000001", "created_at": "2026-04-12T10:30:00Z" }
],
"meta": { "total": 184, "page": 1, "limit": 20 }
}
POST/patients
إنشاء مريض جديد.
POST /v1/patients
{ "name_ar": "منى عبدالله", "phone": "+201000000002", "birth_date": "1992-05-14" }
201 Created
{ "id": 185, "name_ar": "منى عبدالله", "phone": "+201000000002", "created_at": "2026-04-21T08:55:00Z" }
Appointments
GET/appointments
قائمة المواعيد.
GET /v1/appointments?from=2026-04-21&status=confirmed
200 OK
{ "data": [ { "id": 901, "patient_id": 42, "doctor_id": 3, "starts_at": "2026-04-21T14:00:00Z", "status": "confirmed" } ] }
POST/appointments
حجز موعد جديد.
POST /v1/appointments
{ "patient_id": 42, "doctor_id": 3, "starts_at": "2026-04-22T09:00:00Z", "duration_min": 30 }
201 Created
{ "id": 902, "status": "pending", "confirmation_link": "https://app.iclinicos.com/confirm/..." }
Prescriptions
POST/prescriptions
إنشاء وصفة.
POST /v1/prescriptions
{ "patient_id": 42, "appointment_id": 901, "items": [
{ "drug": "Amoxicillin 500mg", "dose": "1 tab", "freq": "TID", "duration_days": 7 }
] }
201 Created
{ "id": 7701, "status": "draft", "esign_url": "/v1/esign/7701" }
Invoices
GET/invoices/:id
فاتورة بالتفصيل.
GET /v1/invoices/333
200 OK
{ "id": 333, "patient_id": 42, "amount_egp": 1200, "vat_egp": 168, "status": "paid", "paid_at": "2026-04-20T16:20:00Z", "paymob_order_id": 509776520 }
Webhooks
استقبل أحداث الوقت الفعلي على URL عندك.
الأحداث المدعومة
appointment.booked·appointment.cancelled·appointment.completedpatient.created·patient.updatedinvoice.paid·invoice.refundedprescription.signed·prescription.dispensed
التحقق من التوقيع
// Node.js example
const crypto = require('crypto');
const sig = req.headers['x-icos-signature'];
const expected = crypto.createHmac('sha256', SECRET).update(req.rawBody).digest('hex');
if (sig !== expected) return res.status(401).send('Invalid signature');
الأخطاء
| Code | المعنى | الحل |
|---|---|---|
400 | طلب غير صحيح | تحقق من الحقول |
401 | غير مصادق | Bearer token |
403 | ممنوع | الصلاحيات |
404 | غير موجود | — |
409 | تعارض | حالة غير قابلة |
429 | تجاوز الحد | Retry-After |
500 | خطأ داخلي | مع X-Request-Id |
SDKs
مكتبات رسمية قادمة قريباً:
Node.js
قريباً
Python
قريباً
PHP
قريباً