استقبل أحداث الحضور والانصراف والإجازات في نظامك الخارجي فور حدوثها.
• API Key: لسحب البيانات من نجمة الرواد (Pull) — يُستخدم في رأس Authorization: Bearer nr_...
• Webhook: لدفع الأحداث من نجمة الرواد لنظامك (Push) — POST بصيغة JSON إلى الرابط الذي تحدده
• كل الطلبات موقّعة بـ HMAC-SHA256 للتحقق من مصدرها
Content-Type: application/json
X-Najmat-Event: attendance.check_in
X-Najmat-Signature: <hmac_sha256_hex_of_body>{
"event": "attendance.check_in",
"timestamp": "2026-07-19T08:15:32.000Z",
"data": {
"employee_id": "EMP-001",
"employee_name": "محمد أحمد",
"user_id": "uuid...",
"check_in_time": "2026-07-19T08:15:32.000Z",
"location": { "lat": 24.71, "lng": 46.68 },
"is_late": false,
"late_minutes": 0
}
}attendance.check_inattendance.check_outattendance.break_startattendance.break_endattendance.absentleave.requestedleave.approvedleave.rejectedemployee.createdemployee.updatedimport { createHmac, timingSafeEqual } from 'crypto';
app.post('/webhook', (req, res) => {
const signature = req.headers['x-najmat-signature'];
const body = JSON.stringify(req.body);
const expected = createHmac('sha256', process.env.NAJMAT_WEBHOOK_SECRET)
.update(body).digest('hex');
const a = Buffer.from(signature);
const b = Buffer.from(expected);
if (a.length !== b.length || !timingSafeEqual(a, b)) {
return res.status(401).send('Invalid signature');
}
// معالجة الحدث
console.log('Event:', req.body.event, req.body.data);
res.send('ok');
});$signature = $_SERVER['HTTP_X_NAJMAT_SIGNATURE'];
$body = file_get_contents('php://input');
$expected = hash_hmac('sha256', $body, getenv('NAJMAT_WEBHOOK_SECRET'));
if (!hash_equals($expected, $signature)) {
http_response_code(401); exit;
}
$payload = json_decode($body, true);event.id لتفادي المعالجة المكررة (idempotency)timestampأنشئ مفتاحاً من لوحة الإدارة → إدارة API Keys (يظهر المفتاح مرة واحدة عند الإنشاء)، ثم أرسله في كل طلب:
Authorization: Bearer nr_YOUR_KEY
# أو
x-api-key: nr_YOUR_KEYhttps://najmat-alrwoad.lovable.app/api/public/v1جميع الطلبات مُعزَلة تلقائياً لشركتك حسب المفتاح — لا تحتاج تمرير company_id.
قائمة الموظفين. Query: limit (اختياري، حتى 1000).
curl https://najmat-alrwoad.lovable.app/api/public/v1/employees \
-H "Authorization: Bearer nr_YOUR_KEY"سجلات الحضور. Query: from, to (ISO)، user_id، limit (حتى 5000).
curl "https://najmat-alrwoad.lovable.app/api/public/v1/attendance?from=2026-07-01&to=2026-07-31" \
-H "Authorization: Bearer nr_YOUR_KEY"الإجازات. Query: status (approved/pending/rejected)، from, to.
curl "https://najmat-alrwoad.lovable.app/api/public/v1/leaves?status=approved" \
-H "Authorization: Bearer nr_YOUR_KEY"ملخّص شهري جاهز للنشر في الحسابات: أيام الحضور، إجمالي دقائق التأخير، أيام الإجازات — لكل موظف. Query: year, month.
curl "https://najmat-alrwoad.lovable.app/api/public/v1/summary?year=2026&month=7" \
-H "Authorization: Bearer nr_YOUR_KEY"200 نجاح401 مفتاح ناقص/غير صالح/منتهي/مسحوب500 خطأ داخليexpires_at للمفاتيح المؤقتة