AfterAds REST API بيغطّي 4 surfaces رئيسية: Tracking، Studio، Loyalty، Services.

#Base URLs

EnvironmentBase URLالملاحظات
Productionhttps://afterads.com/apiالافتراضي
Staginghttps://staging.afterads.com/apiللاختبار
Localhttp://localhost:3000/apidevelopment فقط

#Authentication

#الـEndpoints الأساسية

EndpointMethodالوصف
/api/trackPOSTتسجيل event من ثيم سلة (HMAC-signed)
/api/studio/rewritePOSTAI rewrite لـproduct description (SSE)
/api/waitlistPOSTSubscribe an email to a waitlist
/api/ordersGETقائمة طلبات المستخدم الحالي
/api/servicesPOSTإنشاء service request
/api/services/:idGET, PATCHعرض / تحديث طلب
/api/auth/**Better Auth endpoints (sign-in/up/out)
/api/healthGETHealth check
/api/webhooks/moyasarPOSTMoyasar payment webhook

#Rate limits

#Error format

كل الـerrors بترجع JSON موحّد:

json
{
  "error": "rate_limited",
  "message": "تخطيت الحد اليومي للـrewrite",
  "retry_after_seconds": 3600
}

#أكواد الـHTTP

Codeالاستخدام
200نجاح + body
204نجاح بدون body (مثال: OPTIONS)
400invalid_request (Zod validation failed)
401unauthenticated أو invalid signature
403forbidden (مش admin، الخ)
404resource not found
409conflict (duplicate slug، الخ)
429rate_limited
500internal server error

#Versioning

#Idempotency

بعض endpoints تدعم Idempotency-Key header (16-char string). الاستخدام:

  • POST /api/orders — يفيد لو الـnetwork timeout-out
  • POST /api/services — نفس الفائدة

#SDK