📡 API Documentation

استخدم API لإرسال الرسائل النصية من أي تطبيق

🔐 المصادقة (Authentication)

جميع الطلبات تتطلب Basic Auth باستخدام بيانات الدخول من التطبيق:

Authorization: Basic base64(username:password)

أو إرسالها مباشرة مع cURL: -u "username:password"

💡 في الموقع حقك (sms.zerovape.store) البيانات مضبوطة مسبقاً عبر متغيرات البيئة.

📤 إرسال رسالة

إرسال رسالة نصية عبر Cloud Server:

POST https://api.sms-gate.app/3rdparty/v1/messages

رأس الطلب (Headers)

Content-Type: application/json
Authorization: Basic base64(username:password)

جسم الطلب (Body)

الحقل النوع إجباري الوصف
phoneNumbers array نعم قائمة الأرقام (مثال: ["+966590042734"])
textMessage.text string نعم نص الرسالة
simNumber int لا رقم الشريحة (1 أو 2). يحذف للشريحة الافتراضية

مثال cURL

curl -X POST https://api.sms-gate.app/3rdparty/v1/messages \
  -u "username:password" \
  -H "Content-Type: application/json" \
  -d '{
    "phoneNumbers": ["+966590042734"],
    "textMessage": {
      "text": "مرحبا من API"
    },
    "simNumber": 1
  }'

مثال PHP (cURL)

<?php
$ch = curl_init('https://api.sms-gate.app/3rdparty/v1/messages');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
    CURLOPT_USERPWD => 'username:password',
    CURLOPT_POST => true,
    CURLOPT_POSTFIELDS => json_encode([
        'phoneNumbers' => ['+966590042734'],
        'textMessage'  => ['text' => 'مرحبا من API'],
        'simNumber'    => 1,
    ]),
    CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
]);
$res = curl_exec($ch);
curl_close($ch);
echo $res;

مثال PHP (file_get_contents)

<?php
$data = json_encode([
    'phoneNumbers' => ['+966590042734'],
    'textMessage'  => ['text' => 'مرحبا'],
    'simNumber'    => 1,
]);
$opt = [
    'http' => [
        'method'  => 'POST',
        'header'  => "Authorization: Basic " . base64_encode('username:password') . "\r\nContent-Type: application/json\r\n",
        'content' => $data,
    ]
];
echo file_get_contents('https://api.sms-gate.app/3rdparty/v1/messages', false, stream_context_create($opt));

مثال JavaScript (Fetch)

const res = await fetch('https://api.sms-gate.app/3rdparty/v1/messages', {
    method: 'POST',
    headers: {
        'Authorization': 'Basic ' + btoa('username:password'),
        'Content-Type': 'application/json',
    },
    body: JSON.stringify({
        phoneNumbers: ['+966590042734'],
        textMessage: { text: 'مرحبا' },
        simNumber: 1,
    }),
});
const data = await res.json();
console.log(data);

الرد (Response)

{
  "id": "abc123...",
  "deviceId": "5xsIyDR15ZjLD6aSwq6Nd",
  "state": "Pending",
  "recipients": [
    { "phoneNumber": "+966590042734", "state": "Pending" }
  ],
  "textMessage": { "text": "مرحبا" }
}

📊 جلب حالة الرسائل

GET https://api.sms-gate.app/3rdparty/v1/messages

مثال

curl -u "username:password" \
  "https://api.sms-gate.app/3rdparty/v1/messages?limit=10"

🪝 تسجيل Webhook

POST https://api.sms-gate.app/3rdparty/v1/webhooks
الحقل الوصف
id معرف فريد للـ webhook
url رابط الاستقبال (HTTPS)
event نوع الحدث

الأحداث المتاحة

الحدثالمعنى
sms:received📩 وصول رسالة للجهاز
sms:sent📤 إرسال رسالة
sms:delivered✅ وصول الرسالة للمستلم
sms:failed❌ فشل الإرسال

مثال

curl -X POST https://api.sms-gate.app/3rdparty/v1/webhooks \
  -u "username:password" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "wh-main",
    "url": "https://your-site.com/webhook.php",
    "event": "sms:received"
  }'

📋 عرض الـ Webhooks المسجلة

GET https://api.sms-gate.app/3rdparty/v1/webhooks
curl -u "username:password" "https://api.sms-gate.app/3rdparty/v1/webhooks"

🗑️ حذف Webhook

DELETE https://api.sms-gate.app/3rdparty/v1/webhooks/{id}
curl -X DELETE -u "username:password" \
  "https://api.sms-gate.app/3rdparty/v1/webhooks/wh-main"