Got a website or app? Connect it to WhatsApp using Wavvy's API. Send order confirmations, payment receipts, delivery updates - all automatic.
This guide shows you exactly how. With code examples in Node.js, Python, and PHP.
Why Use WhatsApp API?
Customer places order on your website → API sends WhatsApp confirmation automatically. Payment received → API sends receipt. Order shipped → API sends tracking. All without you touching anything.
Real Example
Karachi online store integrated Wavvy API with their WooCommerce. Every order triggers automatic WhatsApp confirmation. 100% automated. Zero manual work.
Step 1: Get API Key
Log into Wavvy → API Management → Generate API Key. Copy it somewhere safe. This is your password for API access.
Step 2: Get Session ID
Go to Sessions page. Each WhatsApp number has a Session ID. Copy the ID of number you want to use for sending messages.
Step 3: Send Your First Message
Here's how to send a message using different languages:
Node.js Example
const axios = require('axios');
const sendMessage = async () => {
try {
const response = await axios.post('https://wavvy.site/api/send-message', {
sessionId: 'your-session-id',
to: '923001234567', // Pakistan format
message: 'Hello! Your order #1234 is confirmed.'
}, {
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
}
});
console.log('Message sent:', response.data);
} catch (error) {
console.error('Error:', error.response.data);
}
};
sendMessage();
Python Example
import requests
def send_message():
url = 'https://wavvy.site/api/send-message'
headers = {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
}
data = {
'sessionId': 'your-session-id',
'to': '923001234567',
'message': 'Hello! Your order #1234 is confirmed.'
}
response = requests.post(url, json=data, headers=headers)
print(response.json())
send_message()
PHP Example
<?php
$url = 'https://wavvy.site/api/send-message';
$data = array(
'sessionId' => 'your-session-id',
'to' => '923001234567',
'message' => 'Hello! Your order #1234 is confirmed.'
);
$options = array(
'http' => array(
'header' => "Content-type: application/json\r\n" .
"X-API-Key: your-api-key\r\n",
'method' => 'POST',
'content' => json_encode($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>
Send Message with Image
// Node.js
await axios.post('https://wavvy.site/api/send-message', {
sessionId: 'your-session-id',
to: '923001234567',
message: 'Check out our new product!',
mediaUrl: 'https://yoursite.com/product.jpg'
}, {
headers: {
'X-API-Key': 'your-api-key',
'Content-Type': 'application/json'
}
});
Send Bulk Messages
// Node.js
const contacts = [
{ number: '923001234567', name: 'Ahmed' },
{ number: '923007654321', name: 'Ali' }
];
for (const contact of contacts) {
await axios.post('https://wavvy.site/api/send-message', {
sessionId: 'your-session-id',
to: contact.number,
message: `Hi ${contact.name}! Your order is ready.`
}, {
headers: { 'X-API-Key': 'your-api-key' }
});
// Wait 3 seconds between messages (safe speed)
await new Promise(resolve => setTimeout(resolve, 3000));
}
WooCommerce Integration
Add this to your WordPress theme's functions.php:
add_action('woocommerce_order_status_processing', 'send_whatsapp_confirmation');
function send_whatsapp_confirmation($order_id) {
$order = wc_get_order($order_id);
$phone = $order->get_billing_phone();
$name = $order->get_billing_first_name();
// Remove leading zero, add 92
$phone = '92' . ltrim($phone, '0');
$message = "Hi $name! Your order #$order_id is confirmed. " .
"Total: Rs. " . $order->get_total() . ". " .
"We'll ship within 24 hours!";
$data = array(
'sessionId' => 'your-session-id',
'to' => $phone,
'message' => $message
);
wp_remote_post('https://wavvy.site/api/send-message', array(
'headers' => array(
'X-API-Key' => 'your-api-key',
'Content-Type' => 'application/json'
),
'body' => json_encode($data)
));
}
Shopify Integration
Use Shopify webhooks to trigger WhatsApp messages:
// Your webhook endpoint (Node.js/Express)
app.post('/shopify-webhook', async (req, res) => {
const order = req.body;
await axios.post('https://wavvy.site/api/send-message', {
sessionId: 'your-session-id',
to: '92' + order.customer.phone.replace(/^0+/, ''),
message: `Hi ${order.customer.first_name}! ` +
`Order #${order.order_number} confirmed. ` +
`Total: Rs. ${order.total_price}`
}, {
headers: { 'X-API-Key': 'your-api-key' }
});
res.sendStatus(200);
});
Error Handling
try {
const response = await axios.post(url, data, { headers });
if (response.data.success) {
console.log('Message sent successfully');
} else {
console.error('Failed:', response.data.error);
}
} catch (error) {
if (error.response) {
// API returned error
console.error('API Error:', error.response.data);
} else {
// Network error
console.error('Network Error:', error.message);
}
}
Rate Limits
API rate limits depend on your plan:
- Free Plan: 100 requests/hour
- Starter: 500 requests/hour
- Professional: 2,000 requests/hour
- Business: 10,000 requests/hour
Important
Keep your API key secret! Don't commit it to GitHub. Don't share it publicly. If leaked, regenerate immediately from Wavvy dashboard.
Phone Number Format
Always use international format without + sign:
- Correct: 923001234567
- Wrong: +923001234567
- Wrong: 03001234567
Testing
Test API with curl command:
curl -X POST https://wavvy.site/api/send-message \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"sessionId": "your-session-id",
"to": "923001234567",
"message": "Test message"
}'
Complete Documentation
Full API docs with all endpoints: wavvy.site/docs/api
API integration takes 10-15 minutes. Once set up, everything runs automatically. Your website talks to WhatsApp, customers get instant updates, you focus on growing business. Start with simple order confirmations, expand from there.