Webhooks
Inbound webhooks. WhatsApp webhook is POST /webhook/whatsapp with Meta x-hub-signature-256 verification; GET is used for Meta verification challenge.
1
GET WhatsApp Webhook Verification (GET)
GET https://api.greenbubble.io/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=123
cURL
curl -X GET 'https://api.greenbubble.io/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=123' \
-H 'x-api-key: YOUR_API_KEY'
JavaScript
const res = await fetch('https://api.greenbubble.io/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=123', {
method: 'GET',
headers: { 'x-api-key': 'YOUR_API_KEY' }
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=123"
headers = { "x-api-key": "YOUR_API_KEY" }
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/webhook/whatsapp?hub.mode=subscribe&hub.verify_token=YOUR_VERIFY_TOKEN&hub.challenge=123');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['x-api-key: YOUR_API_KEY']);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
2
POST WhatsApp Webhook (POST - incoming message)
POST https://api.greenbubble.io/webhook/whatsapp
cURL
curl -X POST 'https://api.greenbubble.io/webhook/whatsapp' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"object":"whatsapp_business_account","entry":[{"id":"WABA_ID","changes":[{"field":"messages","value":{"messaging_product":"whatsapp","metadata":{"display_phone_number":"+919876543210","phone_number_id":"PHONE_NUMBER_ID"},"contacts":[{"profile":{"name":"John"},"wa_id":"919876543210"}],"messages":[{"from":"919876543210","id":"wamid.XXXX","timestamp":"1700000000","type":"text","text":{"body":"Hi"}}]}}]}]}'
JavaScript
const res = await fetch('https://api.greenbubble.io/webhook/whatsapp', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"object": "whatsapp_business_account",
"entry": [
{
"id": "WABA_ID",
"changes": [
{
"field": "messages",
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "+919876543210",
"phone_number_id": "PHONE_NUMBER_ID"
},
"contacts": [
{
"profile": {
"name": "John"
},
"wa_id": "919876543210"
}
],
"messages": [
{
"from": "919876543210",
"id": "wamid.XXXX",
"timestamp": "1700000000",
"type": "text",
"text": {
"body": "Hi"
}
}
]
}
}
]
}
]
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/webhook/whatsapp"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"object": "whatsapp_business_account",
"entry": [
{
"id": "WABA_ID",
"changes": [
{
"field": "messages",
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "+919876543210",
"phone_number_id": "PHONE_NUMBER_ID"
},
"contacts": [
{
"profile": {
"name": "John"
},
"wa_id": "919876543210"
}
],
"messages": [
{
"from": "919876543210",
"id": "wamid.XXXX",
"timestamp": "1700000000",
"type": "text",
"text": {
"body": "Hi"
}
}
]
}
}
]
}
]
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/webhook/whatsapp');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-api-key: YOUR_API_KEY',
'Content-Type: application/json',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"object":"whatsapp_business_account","entry":[{"id":"WABA_ID","changes":[{"field":"messages","value":{"messaging_product":"whatsapp","metadata":{"display_phone_number":"+919876543210","phone_number_id":"PHONE_NUMBER_ID"},"contacts":[{"profile":{"name":"John"},"wa_id":"919876543210"}],"messages":[{"from":"919876543210","id":"wamid.XXXX","timestamp":"1700000000","type":"text","text":{"body":"Hi"}}]}}]}]}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;