Apps Connection Guide
Complete guide to connecting your e-commerce apps with WhatAPI — from intro to live connection with code examples.
Apps Connection Guide
This guide covers everything you need to connect your e-commerce platform or custom application to WhatAPI for automated WhatsApp notifications.
1. Overview
WhatAPI acts as a bridge between your store/application and WhatsApp. When an event happens (new order, payment received, shipment), WhatAPI receives the data via webhook and sends a formatted WhatsApp message to your customer.
Flow:
Your App/Store → Webhook → WhatAPI Gateway → WhatsApp API → Customer's Phone
What You Need
- A WhatAPI account with WhatsApp connected
- Access to your app's webhook settings or REST API
- Your WhatAPI User ID (found in Dashboard → Settings)
2. Connection Methods
Method A: Direct Platform Integration (No Code)
Supported platforms connect in one click:
Method B: REST API (For Developers)
Use the WhatAPI REST API to send messages programmatically.
Endpoint:
POST https://whatsapi.pk/api/v1/messages/send
Headers:
{
"Content-Type": "application/json",
"x-api-key": "YOUR_API_KEY"
}Request Body:
{
"phone": "+923001234567",
"message": "Hello {customer_name}, your order #{order_number} has been confirmed!",
"type": "text"
}cURL Example:
curl -X POST "https://whatsapi.pk/api/v1/messages/send" \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-key-here" \
-d '{
"phone": "+923001234567",
"message": "Your order #1001 has been shipped! Track here: https://track.example.com/1001",
"type": "text"
}'JavaScript (Node.js) Example:
const axios = require("axios");
async function sendWhatsAppMessage(phone, message) {
const response = await axios.post(
"https://whatsapi.pk/api/v1/messages/send",
{ phone, message, type: "text" },
{
headers: {
"Content-Type": "application/json",
"x-api-key": process.env.WHATAPI_API_KEY,
},
}
);
return response.data;
}
// Usage
sendWhatsAppMessage("+923001234567", "Your order #1001 is confirmed! 🎉")
.then(console.log)
.catch(console.error);Python Example:
import requests
API_KEY = "your-api-key-here"
URL = "https://whatsapi.pk/api/v1/messages/send"
headers = {
"Content-Type": "application/json",
"x-api-key": API_KEY,
}
payload = {
"phone": "+923001234567",
"message": "Your order #1001 is confirmed! 🎉",
"type": "text",
}
response = requests.post(URL, json=payload, headers=headers)
print(response.json())3. Webhook Integration
For real-time notifications, configure webhooks in your app to send events to WhatAPI.
Webhook URL
https://whatsapi.pk/api/shopify/webhook?uid=YOUR_USER_ID
Replace `YOUR_USER_ID` with your actual user ID from the dashboard.
Supported Events
orders/createNew order placedOrder confirmation messageorders/paidPayment receivedPayment receipt notificationfulfillments/createOrder shippedShipping update with trackingorders/cancelledOrder cancelledCancellation noticerefunds/createRefund processedRefund confirmationWebhook Payload Format
WhatAPI expects JSON payloads. Here's a minimal example:
{
"id": 12345,
"name": "#1001",
"total_price": "2499.00",
"currency": "PKR",
"financial_status": "paid",
"customer": {
"first_name": "Ahmed",
"phone": "+923001234567"
},
"line_items": [
{
"title": "Premium Leather Wallet",
"quantity": 1
}
],
"shipping_address": {
"city": "Islamabad",
"address1": "Street 12, Sector F-11"
}
}4. Template Variables
When a webhook is received, you can use dynamic variables in your WhatsApp message templates:
Customer Variables
{customer_name}customer.first_nameAhmed{customer_phone}customer.phone+923001234567{customer_address}shipping_address.address1Street 12, Sector F-11Order Variables
{order_number}name#1001{order_total}total_price2499.00{currency}currencyPKR{payment_method}gatewayCash on Delivery{items_list}line_itemsPremium Leather Wallet x1{items_count}line_items.length2Shipping Variables
{shipping_city}shipping_address.cityIslamabad{tracking_number}fulfillments[0].tracking_numberTRK-98765{tracking_url}fulfillments[0].tracking_urlhttps://track.com/987655. Testing Your Connection
Test via Dashboard
- Go to **Connect Store** and select your platform.
- Click **Test Webhook** in the connection panel.
- Check your WhatsApp for the test message.
Test via cURL
curl -X POST "https://whatsapi.pk/api/shopify/webhook?uid=YOUR_USER_ID" \
-H "Content-Type: application/json" \
-H "x-shopify-topic: orders/create" \
-d '{
"id": 9999,
"name": "#TEST-001",
"total_price": "1500.00",
"currency": "PKR",
"customer": {
"first_name": "Test",
"phone": "+923001234567"
},
"line_items": [{"title": "Test Product", "quantity": 1}]
}'Verify Logs
In your dashboard, go to **Bulk Sender** or check the message logs to see delivery status.
6. Troubleshooting
7. Next Steps
Once connected:
- Customize Templates — Go to Templates to edit WhatsApp message formatting.
- Test Broadcasts — Use Bulk Sender to test message delivery.
- Monitor Analytics — Check the Dashboard for delivery rates and campaign stats.
- Explore API — Use our REST API for custom integrations.
