Developer API
Calling API for developers
Use the same WhatsApp API key (sghwa_...) as for messages. Base URL: https://www.smsgatewayhub.com/cpaas/whatsapp/calls.ashx
| Request | What it does |
GET ?action=logs | Call log with filters: from, to (yyyy-MM-dd), number, direction (user_initiated or business_initiated), status, page |
POST ?action=request-permission | Sends a call permission request to a customer (to, optional body, ref) inside the 24-hour window |
GET ?action=permission&to= | Whether a customer allows your calls, until when, and the request and call limits left |
GET / POST ?action=settings | Calling on or off, call icon, call-back permission prompt and business hours, with WhatsApp's own field names |
POST ?action=webhook | {"callEvents": true} sends call events to your WhatsApp webhook, signed like message events |
Placing or answering the call itself is not offered through the REST API: the voice stream needs a browser or a SIP server. Answer in the panel inbox, or connect your PBX over SIP.
Ask a customer for call permission
curl -X POST "https://www.smsgatewayhub.com/cpaas/whatsapp/calls.ashx?action=request-permission" \
-H "Authorization: Bearer sghwa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "9198XXXXXXXX",
"body": "Can we call you on WhatsApp about your order 1042?",
"ref": "order-1042"
}'
Set business hours (India time)
curl -X POST "https://www.smsgatewayhub.com/cpaas/whatsapp/calls.ashx?action=settings" \
-H "Authorization: Bearer sghwa_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"status": "ENABLED",
"call_hours": {
"status": "ENABLED",
"timezone_id": "Asia/Kolkata",
"weekly_operating_hours": [
{"day_of_week": "MONDAY", "open_time": "0930", "close_time": "1830"}
]
}
}'
Webhook events: call.connect, call.status, call.terminate and call.permission_reply.