دليل البدء السريع
1. أنشئ مفتاح الواجهة البرمجية
curl -X POST https://bus.shafi.cloud/api/api-keys \
-H "X-User-Email: owner@hotel.sa" \
-H "Content-Type: application/json" \
-d '{"hotel_id": 42, "scopes": ["read","write"]}'
احفظ api_key فوراً — لا يمكن استرجاعه لاحقاً.
2. اقرأ آخر التنبيهات
curl https://bus.shafi.cloud/api/v1/notifications \
-H "X-Api-Key: bus_…"
3. سجّل ويبهوك
curl -X POST https://bus.shafi.cloud/api/v1/webhooks \
-H "X-Api-Key: bus_…" \
-H "Content-Type: application/json" \
-d '{
"url": "https://your-server.com/bus-events",
"events": ["bus_departed", "payment_paid"]
}'
4. تحقّق من التوقيع عند استقبال الويبهوك
import hmac, hashlib
def verify(body: bytes, signature: str, secret: str) -> bool:
expected = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
return hmac.compare_digest(expected, signature)
5. سحب المفتاح
curl -X DELETE https://bus.shafi.cloud/api/api-keys/{api_key_id} \
-H "X-User-Email: owner@hotel.sa"