بوابة المطورين (API Reference)

انسخ الأكواد التالية وعدّلها لتناسب تطبيقك. استبدل `YOUR_API_KEY` بالمفتاح الخاص بك.

1. إرسال رمز التحقق (Send OTP)

POST http://veriq.clickiraq.com//v1/otp/send
curl -X POST 'http://veriq.clickiraq.com//v1/otp/send' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "phone": "+9647701234567",
  "channel": "sms"
}'

2. التحقق من الرمز (Verify OTP)

POST http://veriq.clickiraq.com//v1/otp/verify
curl -X POST 'http://veriq.clickiraq.com//v1/otp/verify' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "verification_id": "VERIFICATION_ID_FROM_SEND_STEP",
  "code": "123456"
}'

3. تفعيل المصادقة الثنائية (2FA)

توفر هذه القناة أعلى مستوى أمان بتكلفة منخفضة (500 دينار لكل تفعيل). لا يتم إرسال رسالة SMS، بل يتم توليد مفتاح سري يعمل مع تطبيقات مثل Google Authenticator.

POST http://veriq.clickiraq.com//v1/otp/send

الطلب (Request):

curl -X POST 'http://veriq.clickiraq.com//v1/otp/send' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "phone": "+9647701234567",
  "channel": "authenticator"
}'

الرد (Response):

سيقوم النظام بتوليد مفتاح سري (Secret) ورابط (otpauth_uri). يجب على المبرمج تحويل الرابط إلى QR Code ليقوم المستخدم بمسحه بتطبيق المصادقة.

{
  "success": true,
  "verification_id": "ver_xxxxxxxxx",
  "status": "sent",
  "expires_in": 600,
  "secret": "JBSWY3DPEHPK3PXP",
  "otpauth_uri": "otpauth://totp/VeriQ:+9647701234567?secret=JBSWY3DPEHPK3PXP&issuer=VeriQ",
  "message": "Scan this QR code with Google Authenticator"
}

التحقق من الرمز (Verify OTP):

بعد أن يولد تطبيق المصادقة رمزاً من 6 أرقام، يرسله المبرمج للنظام للتحقق منه بنفس مسار التحقق العادي.

curl -X POST 'http://veriq.clickiraq.com//v1/otp/verify' \
  -H 'x-api-key: YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "verification_id": "VERIFICATION_ID_FROM_SEND_STEP",
  "code": "123456"
}'

4. التحقق من توقيع الويبهوك (HMAC)

كل إشعار ويبهوك يُرسل مع توقيع رقمي في الـ Header باسم X-VeriQ-Signature تحقق منه في خادمك للتأكد أن الإشعار جاء من VeriQ وليس من مهاجم.

المفتاح السري متاح في: الإعدادات ← إعدادات الويبهوك ← مفتاح التوقيع

التحقق في بايثون:

import hmac, hashlib
from flask import request

@app.route('/webhook', methods=['POST'])
def webhook():
    secret = "ضع_المفتاح_السري_هنا"
    body = request.get_data()  # الجسم الخام
    received_sig = request.headers.get('X-VeriQ-Signature', '')
    expected_sig = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
    if not hmac.compare_digest(received_sig, expected_sig):
        return 'Invalid signature', 403
    # ✅ التوقيع صحيح — عالج الإشعار
    return 'OK', 200

التحقق في PHP:

$secret = 'ضع_المفتاح_السري_هنا';
 $body = file_get_contents('php://input');
 $received = $_SERVER['HTTP_X_VERIQ_SIGNATURE'] ?? '';
 $expected = hash_hmac('sha256', $body, $secret);
if (!hash_equals($expected, $received)) {
    http_response_code(403);
    exit('Invalid signature');
}
// ✅ التوقيع صحيح — عالج الإشعار