API

توثيق واجهة البرمجة API — madarmsg

تقدم منصة madarmsg واجهة HTTP API بسيطة لإرسال رسائل الواتساب وقراءة حالة الأجهزة وتلقي الـ Webhooks. تتطلب جميع الطلبات تضمين مفتاح الـ API الخاص بجهازك.

{{!-- ─── Authentication ─── --}}

Authentication

Every request requires your device API key. Create a device in the panel and copy the key from the device details page. You can pass the key using either the Authorization header or the X-API-Key header.

HeaderTypeDescription
Authorization string Bearer YOUR_API_KEY β€” 40-character hex key from the device page
X-API-Key string Alternative: pass the key directly YOUR_API_KEY
Authorization: Bearer YOUR_API_KEY
# or
X-API-Key: YOUR_API_KEY
{{!-- ─── Send Text ─── --}}

POSTSend Text Message

Send a plain text message to a WhatsApp number (international format) or a group.

POST /api/send-message
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "phone": "9665XXXXXXXX",
  "message": "Hello from madarmsg",
  "isGroup": false
}
ParameterRequiredDescription
phoneYesRecipient phone in international format (e.g. 9665XXXXXXXX) or group JID when isGroup is true
messageYesText body of the message
isGroupNoSet true when sending to a group (appends @g.us if needed)

βœ… Success Response: {"success": true, "type": "text", "messageId": "XXXXXXXXXXX", "phoneNumber": "9665XXXXXXXX"}

{{!-- ─── Send Image via URL ─── --}}

POSTSend Image β€” via Public URL

Send an image by providing a publicly accessible URL. The server will download the image and forward it to WhatsApp. Use Content-Type: application/json.

POST /api/send-media
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "phone": "9665XXXXXXXX",
  "url": "https://example.com/photo.jpg",
  "caption": "Check this photo!",
  "isGroup": false
}
ParameterRequiredDescription
phoneYesRecipient phone in international format or group JID
urlYesPublicly accessible image URL (https). Supports JPG, PNG, GIF, WEBP. Max 64 MB
captionNoOptional text caption shown below the image
isGroupNoSet true to send to a WhatsApp group

βœ… Success Response: {"success": true, "type": "image", "messageId": "XXXXXXXXXXX", "phoneNumber": "9665XXXXXXXX"}

{{!-- ─── Send Image via File Upload ─── --}}

POSTSend Image β€” via File Upload (from Disk)

Upload an image directly from your local disk or server. Use Content-Type: multipart/form-data and attach the file in the file field.

POST /api/send-media
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-data

phone=9665XXXXXXXX
caption=Check this photo!
file=<binary image file>
Field (Form)RequiredDescription
phoneYesRecipient phone in international format or group JID
fileYesThe image file binary. Supported: JPG, PNG, GIF, WEBP. Max 64 MB
captionNoOptional text caption shown below the image
isGroupNoSet true to send to a WhatsApp group

βœ… Success Response: {"success": true, "type": "image", "messageId": "XXXXXXXXXXX", "phoneNumber": "9665XXXXXXXX"}

πŸ’‘ Python example:

import requests

resp = requests.post(
    "https://your-panel.com/api/send-media",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    data={"phone": "9665XXXXXXXX", "caption": "My photo"},
    files={"file": open("/path/to/photo.jpg", "rb")}
)
print(resp.json())

πŸ’‘ PHP (Guzzle) example:

$client = new GuzzleHttp\Client();
$response = $client->post('https://your-panel.com/api/send-media', [
    'headers' => ['Authorization' => 'Bearer YOUR_API_KEY'],
    'multipart' => [
        ['name' => 'phone',   'contents' => '9665XXXXXXXX'],
        ['name' => 'caption', 'contents' => 'My photo'],
        ['name' => 'file',    'contents' => fopen('/path/to/photo.jpg', 'r'),
                              'filename'  => 'photo.jpg'],
    ]
]);
{{!-- ─── Send Document via URL ─── --}}

POSTSend Document β€” via Public URL

Send any document (PDF, Word, Excel, ZIP…) by providing a publicly accessible URL. Use Content-Type: application/json.

POST /api/send-document
Authorization: Bearer YOUR_API_KEY
Content-Type: application/json

{
  "phone": "9665XXXXXXXX",
  "url": "https://example.com/invoice.pdf",
  "fileName": "invoice.pdf",
  "caption": "Your invoice is attached",
  "isGroup": false
}
ParameterRequiredDescription
phoneYesRecipient phone in international format or group JID
urlYesPublicly accessible file URL (https). Supports PDF, DOCX, XLSX, ZIP, etc. Max 64 MB
fileNameNoDisplay name shown in WhatsApp (e.g. invoice.pdf). If omitted, extracted from URL
captionNoOptional text caption shown with the document
isGroupNoSet true to send to a WhatsApp group

βœ… Success Response: {"success": true, "type": "document", "messageId": "XXXXXXXXXXX", "phoneNumber": "9665XXXXXXXX"}

{{!-- ─── Send Document via File Upload ─── --}}

POSTSend Document β€” via File Upload (from Disk)

Upload any document directly from your local disk or server. Use Content-Type: multipart/form-data and attach the file in the file field.

POST /api/send-document
Authorization: Bearer YOUR_API_KEY
Content-Type: multipart/form-data

phone=9665XXXXXXXX
fileName=invoice.pdf
caption=Your invoice is attached
file=<binary document file>
Field (Form)RequiredDescription
phoneYesRecipient phone in international format or group JID
fileYesThe document file binary. Supports PDF, DOCX, XLSX, ZIP, and more. Max 64 MB
fileNameNoDisplay name shown in WhatsApp (e.g. invoice.pdf). Defaults to original filename
captionNoOptional text caption shown with the document
isGroupNoSet true to send to a WhatsApp group

βœ… Success Response: {"success": true, "type": "document", "messageId": "XXXXXXXXXXX", "phoneNumber": "9665XXXXXXXX"}

πŸ’‘ Python example:

import requests

resp = requests.post(
    "https://your-panel.com/api/send-document",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    data={"phone": "9665XXXXXXXX", "fileName": "report.pdf", "caption": "Monthly report"},
    files={"file": open("/path/to/report.pdf", "rb")}
)
print(resp.json())

πŸ’‘ PHP (Guzzle) example:

$client = new GuzzleHttp\Client();
$response = $client->post('https://your-panel.com/api/send-document', [
    'headers' => ['Authorization' => 'Bearer YOUR_API_KEY'],
    'multipart' => [
        ['name' => 'phone',    'contents' => '9665XXXXXXXX'],
        ['name' => 'fileName', 'contents' => 'invoice.pdf'],
        ['name' => 'caption',  'contents' => 'Your invoice'],
        ['name' => 'file',     'contents' => fopen('/path/to/invoice.pdf', 'r'),
                               'filename'  => 'invoice.pdf'],
    ]
]);
{{!-- ─── Device Info ─── --}}

GETDevice Info

Returns connection status, linked WhatsApp phone, and remaining message quota for your device.

GET /api/device/info
Authorization: Bearer YOUR_API_KEY
{
  "success": true,
  "device_id": "...",
  "label": "My Device",
  "connection_status": "connected",
  "messages_remaining": 450
}
{{!-- ─── Webhooks ─── --}}

Webhooks

Configure a webhook URL on your device to receive inbound WhatsApp messages (text, image, document, video, audio, location, groups). madarmsg will POST the following JSON payload to your URL on every incoming message.

POST https://your-server.com/webhook
Content-Type: application/json

{
  "event": "message.received",
  "deviceId": "your-device-id",
  "timestamp": "2026-07-14T12:00:00.000Z",
  "isGroup": false,
  "groupId": null,
  "message": {
    "id": "wa-message-id",
    "from": "9665XXXXXXXX",
    "from_jid": "9665XXXXXXXX@s.whatsapp.net",
    "from_name": "Customer",
    "type": "text",
    "text": "Customer reply",
    "isGroup": false,
    "groupId": null
  }
}
FieldDescription
deviceIdSource device id that received the message
isGrouptrue when the message is from a group
groupIdGroup JID (...@g.us) when isGroup is true; otherwise null
message.fromSender phone (in groups: the participant, not the group)
message.typetext, image, document, video, audio, location, …
message.textBody text or caption when available

Need a live API key?

Register, create a device, then copy the API key from the device details page.

Register