المصادقة والصلاحيات
كل عميل API تبع شركة واحدة وليه مجموعة Scopes. بنعرف الشركة من الـ credential نفسه، وعمرنا ما بناخدها من جسم الطلب.
API Key
X-Api-Key: sgk_live_xxxxxxxx
# أو
Authorization: Bearer sgk_live_xxxxxxxx
OAuth2 Client Credentials
curl -X POST https://api.crmgateway.brainstorming-solutions.com/oauth/token \
-u "cli_xxxx:sgs_live_xxxx" \
-d grant_type=client_credentials \
-d scope="posts:write comments:read"
{ "access_token": "eyJ...", "token_type": "Bearer", "expires_in": 3600, "scope": "posts:write comments:read" }
Scopes
accounts:read | قراءة الحسابات |
posts:read | قراءة المنشورات |
posts:write | النشر والإلغاء |
comments:read | قراءة التعليقات |
comments:write | الرد والإخفاء والحذف |
messages:read | قراءة الرسائل الخاصة |
messages:write | الرد على الرسائل الخاصة |
orders:read | قراءة الطلبات |
orders:write | تحديث حالة الطلبات |
crm:read | قراءة العملاء والجهات |
crm:write | إضافة وتعديل العملاء والجهات |
operations:read | قراءة العمليات |
uploads:write | رفع الملفات |
sandbox:write | أدوات التجربة |
تدوير المفاتيح
لما تعمل rotate للمفتاح، القديم بيفضل شغال فترة تقدر تظبطها (api.key_rotation_grace_hours)، علشان تنقل نظامك من غير ما يقف.
حدود الطلبات
كل رد فيه X-RateLimit-Limit و X-RateLimit-Remaining و X-RateLimit-Reset. لو عدّيت الحد هيرجعلك 429 ومعاه Retry-After.