Docs الوثائق Authentication / المصادقة

Authentication المصادقة

The Watsal API allows you to access your data and perform actions programmatically. Requests are authenticated using API Keys, which manage access permissions and identify your application. تمكّنك واجهة وتسال من الوصول إلى بياناتك وتنفيذ الإجراءات برمجياً. تتم المصادقة على الطلبات باستخدام مفاتيح API التي تدير صلاحيات الوصول وتعرّف تطبيقك.

Managing Your Keys إدارة مفاتيحك

You can view, create, and revoke API keys in the Developer Settings section of your dashboard. يمكنك عرض مفاتيح الـ API وإنشاؤها وإلغاؤها من قسم إعدادات المطور في لوحة التحكم.

Bearer Authentication مصادقة Bearer

We use the standard Bearer Authentication scheme. You must include your API key in the Authorization header of each request. نستخدم مخطط مصادقة Bearer القياسي. يجب أن تتضمن مفتاح الـ API في ترويسة Authorization لكل طلب.

Header Format تنسيق الترويسة
Authorization: Bearer YOUR_API_KEY

Example Request طلب كمثال

Here is how you might include the header using cURL: هكذا يمكنك إضافة الترويسة باستخدام cURL:

curl -X GET https://api.watsal.com/v1/profile \
  -H "Authorization: Bearer watsal_live_abc123..."

Security Best Practices أفضل ممارسات الأمان

Your API keys carry powerful privileges and can result in charges or data access. Keep them secure by following these guidelines: تحمل مفاتيح الـ API صلاحيات قوية وقد تؤدي إلى رسوم أو وصول للبيانات. احفظها بأمان عبر اتباع الإرشادات التالية:

  • Never expose keys in client-side code لا تعرض المفاتيح في كود الواجهة الأمامية Do not include API keys in JavaScript files (e.g., Vue/React apps) served to browsers. Use the API only from your secure backend servers. لا تضع مفاتيح الـ API في ملفات جافاسكريبت (مثل تطبيقات Vue/React) التي تُرسل للمتصفح. استخدم الواجهة فقط من خوادمك الخلفية الآمنة.
  • Use Environment Variables استخدم المتغيرات البيئية Store API keys in environment variables (e.g., .env file) rather than hardcoding them in your application source code. خزن مفاتيح الـ API في متغيرات بيئية (مثل ملف ‎.env‎) بدلاً من كتابتها داخل الكود مباشرة.
  • Rotate Keys Regularly قم بتدوير المفاتيح بانتظام For improved security, rotate (revoke and re-generate) your API keys periodically, or immediately if you suspect a leak. لتحسين الأمان، قم بإلغاء وإعادة إنشاء مفاتيح الـ API بشكل دوري أو فورًا عند الاشتباه في تسرب.