WSync Developer API
The WSync REST API gives you programmatic control to send real-time WhatsApp text messages, order alerts, verification OTPs, and dynamic billing receipts directly through your connected WhatsApp number.
Authentication
Every request requires an active API key generated in your WSync dashboard. Pass your key via the X-API-Key request header or as a standard Bearer token.
X-API-Key: wsc_live_9f83a8f4c71b02de874e502c
Never expose your secret API keys in client-side code (browser JavaScript or mobile apps). Always execute calls to WSync from your secure backend server.
Automatic Phone Number Normalization
WSync automatically standardizes Pakistani and international numbers to E.164 without symbols:
03001234567→ automatically normalized to923001234567+92 300 1234567→ stripped of spaces and symbols to923001234567+14155552671→ normalized to international14155552671
Send WhatsApp Message
Dispatches a message immediately via your connected WhatsApp socket daemon. If your session is temporarily offline, the message is queued in your priority buffer and dispatched upon socket reconnect.
Request Body Parameters (JSON)
| Field | Type | Status | Description |
|---|---|---|---|
phone |
string | Required | Recipient phone number (e.g. "03001234567" or "923001234567"). |
message |
string | Required | Message text content. Supports WhatsApp markdown (*bold*, _italic_, ~strike~). |
clientName |
string | Optional | Customer or recipient name for audit logging and search in dashboard. |
referenceId |
string | Optional | Internal order number, invoice ID, or ticket number (e.g. "INV-9402"). |
Implementation Code Samples
curl -X POST https://app.wsync.net/api/v1/messages/send \
-H "Content-Type: application/json" \
-H "X-API-Key: wsc_live_your_api_key_here" \
-d '{
"phone": "03001234567",
"message": "Hello Ahmed! Your order #1084 has been confirmed and packed. Track here: https://track.store.com/1084",
"clientName": "Ahmed Khan",
"referenceId": "ORD-1084"
}'
<?php
$apiKey = 'wsc_live_your_api_key_here';
$apiUrl = 'https://app.wsync.net/api/v1/messages/send';
$payload = [
'phone' => '03001234567',
'message' => 'Hello Ahmed! Your order #1084 is confirmed.',
'clientName' => 'Ahmed Khan',
'referenceId' => 'ORD-1084'
];
$ch = curl_init($apiUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
'X-API-Key: ' . $apiKey
],
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_TIMEOUT => 10
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$result = json_decode($response, true);
if ($httpCode === 200 && $result['success']) {
echo "Message sent with ID: " . $result['messageId'];
} else {
echo "Error: " . ($result['error'] ?? 'Unknown error');
}
?>
const sendMessage = async () => {
const response = await fetch('https://app.wsync.net/api/v1/messages/send', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'wsc_live_your_api_key_here',
},
body: JSON.stringify({
phone: '03001234567',
message: 'Hello Ahmed! Your invoice #INV-941 is ready for payment.',
clientName: 'Ahmed Khan',
referenceId: 'INV-941',
}),
});
const data = await response.json();
console.log(data);
};
sendMessage();
import requests
url = "https://app.wsync.net/api/v1/messages/send"
headers = {
"Content-Type": "application/json",
"X-API-Key": "wsc_live_your_api_key_here"
}
payload = {
"phone": "03001234567",
"message": "Hello Ahmed! Your order has been dispatched.",
"clientName": "Ahmed Khan",
"referenceId": "ORD-1084"
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print("Response:", data)
Success Response (200 OK)
{
"success": true,
"messageId": "msg_9024f28e-1f03-455b-8d76-1a84f3e1b092",
"status": "sent",
"recipient": "923001234567",
"whatsappConnected": true,
"note": "Message sent immediately via WhatsApp socket",
"quotaRemaining": 4981
}
Dynamic Template Variables
When designing automated templates in your WSync portal for Shopify or WHMCS, use any of these variables:
| Variable | Context | Example Replacement |
|---|---|---|
{{customer_name}} |
Shopify / WHMCS / API | Hamza Tariq |
{{order_number}} |
Shopify Order | #1084 |
{{total_price}} |
Shopify / WHMCS | PKR 4,850.00 |
{{invoice_id}} |
WHMCS Invoicing | INV-7840 |
{{due_date}} |
WHMCS Billing | 25th October 2026 |
{{payment_url}} |
WHMCS Direct Link | https://portal.host.com/viewinvoice.php?id=7840 |
{{brand_name}} |
Global Store Setting | Silk Avenue Apparel |
HTTP Response Status Codes
| Code | Status | Reason & Resolution |
|---|---|---|
| 200 | OK | Message sent or added to queue successfully. |
| 400 | Bad Request | Missing phone or message field, or phone format is invalid. |
| 401 | Unauthorized | API key is missing, invalid, or revoked. |
| 403 | Forbidden | Subscription is expired or pending payment. |
| 429 | Quota Exceeded | Monthly message tier limit reached. Upgrade plan in dashboard. |