WhatsApp v2 - Messages
Public API v2 WhatsApp surface under /api/v2/whatsapp/*. List sender_id values, then send text / media / templates / reactions. Full URL = base + path. For outbound delivery use POST /api/v2/whatsapp/
GET List Senders
Returns every active WhatsApp sender in the workspace (Cloud API + Scan Device). Copy a sender_id before sending.
GET https://api.greenbubble.io/api/v2/whatsapp/senders
cURL
curl -X GET 'https://api.greenbubble.io/api/v2/whatsapp/senders' \
-H 'x-api-key: YOUR_API_KEY'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/senders', {
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/api/v2/whatsapp/senders"
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/api/v2/whatsapp/senders');
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;
POST Send Text
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"text","text":{"body":"Hello from Greenbubble"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "text",
"text": {
"body": "Hello from Greenbubble"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "text",
"text": {
"body": "Hello from Greenbubble"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"text","text":{"body":"Hello from Greenbubble"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Image (public URL)
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"image","image":{"url":"https://example.com/photo.jpg","caption":"Product photo"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "image",
"image": {
"url": "https://example.com/photo.jpg",
"caption": "Product photo"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "image",
"image": {
"url": "https://example.com/photo.jpg",
"caption": "Product photo"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"image","image":{"url":"https://example.com/photo.jpg","caption":"Product photo"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Video (public URL)
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"video","video":{"url":"https://example.com/clip.mp4","caption":"Watch this"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "video",
"video": {
"url": "https://example.com/clip.mp4",
"caption": "Watch this"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "video",
"video": {
"url": "https://example.com/clip.mp4",
"caption": "Watch this"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"video","video":{"url":"https://example.com/clip.mp4","caption":"Watch this"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Audio (public URL)
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"audio","audio":{"url":"https://example.com/voice.mp3"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "audio",
"audio": {
"url": "https://example.com/voice.mp3"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "audio",
"audio": {
"url": "https://example.com/voice.mp3"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"audio","audio":{"url":"https://example.com/voice.mp3"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Document (public URL)
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"document","document":{"url":"https://example.com/invoice.pdf","filename":"invoice.pdf","caption":"Your invoice"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "document",
"document": {
"url": "https://example.com/invoice.pdf",
"filename": "invoice.pdf",
"caption": "Your invoice"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "document",
"document": {
"url": "https://example.com/invoice.pdf",
"filename": "invoice.pdf",
"caption": "Your invoice"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"document","document":{"url":"https://example.com/invoice.pdf","filename":"invoice.pdf","caption":"Your invoice"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Location
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"location","location":{"latitude":28.6139,"longitude":77.209,"name":"New Delhi","address":"New Delhi, India"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "location",
"location": {
"latitude": 28.6139,
"longitude": 77.209,
"name": "New Delhi",
"address": "New Delhi, India"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "location",
"location": {
"latitude": 28.6139,
"longitude": 77.209,
"name": "New Delhi",
"address": "New Delhi, India"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"location","location":{"latitude":28.6139,"longitude":77.209,"name":"New Delhi","address":"New Delhi, India"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Template (Cloud API)
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"template","template":{"template_id":"YOUR_TEMPLATE_ID","language_code":"en_US","body_variables":["John","ORD-1001"],"header_media":{"type":"image","url":"https://example.com/banner.jpg"}}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "template",
"template": {
"template_id": "YOUR_TEMPLATE_ID",
"language_code": "en_US",
"body_variables": [
"John",
"ORD-1001"
],
"header_media": {
"type": "image",
"url": "https://example.com/banner.jpg"
}
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "template",
"template": {
"template_id": "YOUR_TEMPLATE_ID",
"language_code": "en_US",
"body_variables": [
"John",
"ORD-1001"
],
"header_media": {
"type": "image",
"url": "https://example.com/banner.jpg"
}
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"template","template":{"template_id":"YOUR_TEMPLATE_ID","language_code":"en_US","body_variables":["John","ORD-1001"],"header_media":{"type":"image","url":"https://example.com/banner.jpg"}}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Send Reaction
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"reaction","reaction":{"message_id":"wamid.XXXXXXXXXXXX","emoji":"👍"}}}'
JavaScript
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: {
'x-api-key': 'YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "reaction",
"reaction": {
"message_id": "wamid.XXXXXXXXXXXX",
"emoji": "👍"
}
}
})
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = {
"x-api-key": "YOUR_API_KEY",
"Content-Type": "application/json",
}
payload = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": {
"type": "reaction",
"reaction": {
"message_id": "wamid.XXXXXXXXXXXX",
"emoji": "👍"
}
}
}
response = requests.post(url, headers=headers, json=payload)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
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, '{"sender_id":"wa_snd_YOUR_SENDER_ID","to":"919876543210","message":{"type":"reaction","reaction":{"message_id":"wamid.XXXXXXXXXXXX","emoji":"👍"}}}');
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;
POST Upload Media (multipart/form-data)
Upload a local file when it is not at a public URL. Field names: sender_id, to, message (JSON string), and file (binary).
POST https://api.greenbubble.io/api/v2/whatsapp/messages
cURL
curl -X POST 'https://api.greenbubble.io/api/v2/whatsapp/messages' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: multipart/form-data' \
-F 'sender_id=wa_snd_YOUR_SENDER_ID' \
-F 'to=919876543210' \
-F 'message={"type":"document","document":{"filename":"invoice.pdf"}}' \
-F 'file=@/path/to/file'
JavaScript
const formData = new FormData();
formData.append('sender_id', 'wa_snd_YOUR_SENDER_ID');
formData.append('to', '919876543210');
formData.append('message', '{"type":"document","document":{"filename":"invoice.pdf"}}');
// formData.append('file', fileInput.files[0]);
const res = await fetch('https://api.greenbubble.io/api/v2/whatsapp/messages', {
method: 'POST',
headers: { 'x-api-key': 'YOUR_API_KEY' },
body: formData,
});
const data = await res.json();
console.log(data);
Python
import requests
url = "https://api.greenbubble.io/api/v2/whatsapp/messages"
headers = { "x-api-key": "YOUR_API_KEY" }
files = { "file": open("/path/to/file", "rb") }
data = {
"sender_id": "wa_snd_YOUR_SENDER_ID",
"to": "919876543210",
"message": "{\"type\":\"document\",\"document\":{\"filename\":\"invoice.pdf\"}}",
}
response = requests.post(url, headers=headers, files=files, data=data)
print(response.status_code)
print(response.json())
PHP
$ch = curl_init('https://api.greenbubble.io/api/v2/whatsapp/messages');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['x-api-key: YOUR_API_KEY']);
$postFields = [
'sender_id' => 'wa_snd_YOUR_SENDER_ID',
'to' => '919876543210',
'message' => '{"type":"document","document":{"filename":"invoice.pdf"}}',
];
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $httpCode . "\n" . $response;