دليل واجهات البرمجة التطبيقية (API)

يمكنك استخدام الأكواد المجهزة أدناه لتطبيق الربط المباشر مع مختلف لغات البرمجة.

POST /messages/send_otp
Authentication & OTP

مثال إرسال OTP باستخدام مكتبة Axios في Node.js

const axios = require('axios');

const sendOtp = async () => {
  try {
    const response = await axios.post('https://your-domain.com/api/messages/send_otp', {
      to: '+966500000000',
      channel: 'whatsapp',
      type: 'otp',
      body: 'رمز التحقق الخاص بك هو: 1234'
    }, {
      headers: {
        'Authorization': 'Bearer YOUR_API_TOKEN',
        'Content-Type': 'application/json'
      }
    });
    console.log(response.data);
  } catch (error) {
    console.error(error.response ? error.response.data : error.message);
  }
};

sendOtp();