AfterAds REST API بيغطّي 4 surfaces رئيسية: Tracking، Studio، Loyalty، Services.
#Base URLs
| Environment | Base URL | الملاحظات |
|---|---|---|
| Production | https://afterads.com/api | الافتراضي |
| Staging | https://staging.afterads.com/api | للاختبار |
| Local | http://localhost:3000/api | development فقط |
#Authentication
#الـEndpoints الأساسية
| Endpoint | Method | الوصف |
|---|---|---|
/api/track | POST | تسجيل event من ثيم سلة (HMAC-signed) |
/api/studio/rewrite | POST | AI rewrite لـproduct description (SSE) |
/api/waitlist | POST | Subscribe an email to a waitlist |
/api/orders | GET | قائمة طلبات المستخدم الحالي |
/api/services | POST | إنشاء service request |
/api/services/:id | GET, PATCH | عرض / تحديث طلب |
/api/auth/* | * | Better Auth endpoints (sign-in/up/out) |
/api/health | GET | Health check |
/api/webhooks/moyasar | POST | Moyasar payment webhook |
#Rate limits
#Error format
كل الـerrors بترجع JSON موحّد:
{
"error": "rate_limited",
"message": "تخطيت الحد اليومي للـrewrite",
"retry_after_seconds": 3600
}#أكواد الـHTTP
| Code | الاستخدام |
|---|---|
| 200 | نجاح + body |
| 204 | نجاح بدون body (مثال: OPTIONS) |
| 400 | invalid_request (Zod validation failed) |
| 401 | unauthenticated أو invalid signature |
| 403 | forbidden (مش admin، الخ) |
| 404 | resource not found |
| 409 | conflict (duplicate slug، الخ) |
| 429 | rate_limited |
| 500 | internal server error |
#Versioning
#Idempotency
بعض endpoints تدعم Idempotency-Key header (16-char string). الاستخدام:
POST /api/orders— يفيد لو الـnetwork timeout-outPOST /api/services— نفس الفائدة