Docs الوثائق API Reference / مرجع API

API Reference مرجع واجهة برمجة التطبيقات

Complete reference documentation for the Watsal API. All endpoints are relative to the Base URL: https://api.watsal.com. توثيق مرجعي كامل لواجهة وتسال. جميع نقاط النهاية تعتمد على رابط الأساس: https://api.watsal.com.

Messages & Verification الرسائل والتحقق

Manage OTP verifications and retrieval. إدارة إرسال واستقبال أكواد التحقق.

POST /v1/verify/send
Send OTP code إرسال رمز تحقق
Details تفاصيل

Generates and sends a numeric One-Time Password (OTP) to the specified phone number via WhatsApp. يُنشئ ويرسل رمز تحقق رقمي لمرة واحدة (OTP) إلى رقم الهاتف المحدد عبر واتساب.

Body Parameters معاملات الطلب

Param المعامل Type النوع Description الوصف
phone *string E.164 formatted phone (e.g. +2010...) رقم هاتف بصيغة E.164 (مثل ‎+2010…‎)
lengthint Code length (4-8 digits). Default: 6 طول الرمز (4-8 أرقام). الافتراضي: 6
brand_namestring Your app name to appear in msg template. اسم تطبيقك ليظهر في قالب الرسالة.
curl -X POST https://api.watsal.com/v1/verify/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+201012345678",
    "length": 6,
    "brand_name": "Watsal App"
  }'
await axios.post('https://api.watsal.com/v1/verify/send', {
  phone: '+201012345678',
  length: 6,
  brand_name: 'Watsal App'
}, {
  headers: { 'Authorization': 'Bearer YOUR_API_KEY' }
});
Http::withToken('YOUR_API_KEY')->post('https://api.watsal.com/v1/verify/send', [
    'phone' => '+201012345678',
    'length' => 6,
    'brand_name' => 'Watsal App'
]);
Response الاستجابة
{
  "success": true,
  "data": {
    "request_id": "req_550e8400-e29b-41d4",
    "status": "sent",
    "expires_in": 300
  }
}
POST /v1/verify/check
Sync verify code التحقق من الرمز
Details تفاصيل

Validates the code provided by the user against the request ID. يتحقق من الرمز الذي أدخله المستخدم مقابل رقم الطلب.

Body Parameters معاملات الطلب

Param المعامل Type النوع Description الوصف
request_id *string ID returned from send endpoint. المعرف المرتجع من نقطة الإرسال.
code *string The 4-8 digit code user entered. الرمز المكوّن من 4-8 أرقام الذي أدخله المستخدم.
curl -X POST https://api.watsal.com/v1/verify/check \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_id": "req_550e8400-e29b-41d4",
    "code": "123456"
  }'
Response الاستجابة
{
  "success": true,
  "data": {
    "verified": true,
    "timestamp": "2023-10-01T12:00:00Z"
  }
}
GET /v1/messages/{id}
Retrieve message status استرجاع حالة الرسالة
Details تفاصيل

Check the current delivery status of any message sent via the API. تحقق من حالة التسليم لأي رسالة تم إرسالها عبر الواجهة.

Path Parameters معاملات المسار

Param المعامل Type النوع Description الوصف
id *string Message ID (req_...) معرف الرسالة (req_...)
curl -X GET https://api.watsal.com/v1/messages/req_550e8400 \
  -H "Authorization: Bearer YOUR_API_KEY"
Response الاستجابة
{
  "success": true,
  "data": {
    "id": "req_550e8400",
    "status": "delivered",
    "timestamp": "2023-10-01T12:05:00Z"
  }
}

Notifications الإشعارات

Send transactional alerts and updates. إرسال إشعارات وتنبيهات المعاملات.

POST /v1/notifications/send
Send notification إرسال إشعار
Details تفاصيل

Sends a template-based notification to a user. يرسل إشعارًا مبنيًا على قالب للمستخدم.

Body Parameters معاملات الطلب

Param المعامل Type النوع Description الوصف
phone *string E.164 phone number. رقم هاتف بصيغة E.164.
template *string Slug of the template (e.g. order_update). الاسم المميز للقالب (مثل order_update).
variablesobject Key-value pair for defaults params. كائن يحوي متغيرات القالب.
curl -X POST https://api.watsal.com/v1/notifications/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "+201012345678",
    "template": "order_confirmed",
    "variables": {
        "order_id": "123",
        "name": "Ahmed"
    }
  }'
Response الاستجابة
{
  "success": true,
  "data": {
    "request_id": "req_8812a",
    "status": "queued"
  }
}