Send messages
Text, photos, documents, voice notes and locations, on WhatsApp and other channels.
/api/v1/messages
Sends one message to one person.
Fields
| Field | Needed? | What it is |
|---|---|---|
| to | Yes | Who gets it. WhatsApp: phone with country code, digits only. |
| type | No | text (default), image, video, document, audio or location |
| text | For text | The message, up to 4,096 characters. For media, it becomes the caption. |
| media | For media | The file itself (multipart upload, up to 16 MB) |
| media_url | For media | Or a public link to the file; Flowleb downloads it |
| latitude · longitude | For location | The place to share |
| device_id | No | Which of your WhatsApp numbers sends it. Default: your main number. |
| channel | No | whatsapp (default), instagram, facebook or telegram |
| connection_id | No | Other channels only: which Page, account or bot sends it |
Text
curl -X POST https://flowleb.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"type": "text",
"text": "Hi Maya, your order #2045 has shipped!"
}'
const res = await fetch('https://flowleb.com/api/v1/messages', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.FLOWLEB_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
to: '919876543210',
type: 'text',
text: 'Hi Maya, your order #2045 has shipped!',
}),
});
const { data, error } = await res.json();
if (!res.ok) throw new Error(`${error?.code}: ${error?.message}`);
console.log('Message id', data.id, 'status', data.status);
import os, requests
res = requests.post(
"https://flowleb.com/api/v1/messages",
headers={"Authorization": "Bearer " + os.environ["FLOWLEB_API_KEY"]},
json={
"to": "919876543210",
"type": "text",
"text": "Hi Maya, your order #2045 has shipped!",
},
)
body = res.json()
if not res.ok:
raise RuntimeError(body)
print("Message id", body["data"]["id"], "status", body["data"]["status"])
<?php
$ch = curl_init('https://flowleb.com/api/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('FLOWLEB_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'to' => '919876543210',
'type' => 'text',
'text' => 'Hi Maya, your order #2045 has shipped!',
]),
]);
$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 300) {
throw new RuntimeException($body['error']['message'] ?? 'Send failed');
}
echo 'Message id ' . $body['data']['id'];
Photos, videos, documents and audio
There are two ways. Pick whichever is easier for you.
curl -X POST https://flowleb.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"type": "image",
"media_url": "https://yourshop.com/images/order-2045.jpg",
"text": "Your parcel is packed and ready 📦"
}'
curl -X POST https://flowleb.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-F to=919876543210 \
-F type=document \
-F text="Invoice for order #2045" \
-F media=@invoice-2045.pdf
import { readFile } from 'node:fs/promises';
const form = new FormData();
form.append('to', '919876543210');
form.append('type', 'document');
form.append('text', 'Invoice for order #2045');
form.append('media', new Blob([await readFile('invoice-2045.pdf')]), 'invoice-2045.pdf');
// Don't set Content-Type yourself: fetch adds the multipart boundary.
const res = await fetch('https://flowleb.com/api/v1/messages', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.FLOWLEB_API_KEY}` },
body: form,
});
import os, requests
with open("invoice-2045.pdf", "rb") as f:
res = requests.post(
"https://flowleb.com/api/v1/messages",
headers={"Authorization": "Bearer " + os.environ["FLOWLEB_API_KEY"]},
data={"to": "919876543210", "type": "document", "text": "Invoice for order #2045"},
files={"media": f},
)
print(res.json())
<?php
$ch = curl_init('https://flowleb.com/api/v1/messages');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('FLOWLEB_API_KEY')],
CURLOPT_POSTFIELDS => [
'to' => '919876543210',
'type' => 'document',
'text' => 'Invoice for order #2045',
'media' => new CURLFile('invoice-2045.pdf', 'application/pdf'),
],
]);
print_r(json_decode(curl_exec($ch), true));
Location
curl -X POST https://flowleb.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"to": "919876543210",
"type": "location",
"latitude": 19.0760,
"longitude": 72.8777
}'
Choose which number sends
If you have more than one WhatsApp number connected, list them and pass the one you want as device_id.
/api/v1/devices
Lists your connected WhatsApp numbers.
curl https://flowleb.com/api/v1/devices \
-H "Authorization: Bearer YOUR_API_KEY"
{
"data": [
{ "id": 57, "name": "Shop phone", "phone": "919800000001",
"engine": "unofficial", "status": "connected", "active": true,
"last_seen_at": "2026-11-18T09:58:12+05:30" },
{ "id": "cfg_20", "name": "Maya's Store", "phone": "919800000002",
"engine": "whatsapp_cloud", "status": "connected", "active": true,
"last_seen_at": "2026-11-02T14:11:40+05:30" }
],
"meta": { "count": 2 }
}
{
"to": "919876543210",
"device_id": "cfg_20",
"type": "text",
"text": "Sent from our official number"
}
- unofficial
- A number linked by scanning a QR code.
- whatsapp_cloud
- A number on the official WhatsApp Business API (Meta). The 24-hour window and template rules apply.
- twilio
- A number connected through Twilio.
Instagram, Messenger and Telegram
Set channel and use that platform's id for the person in to: Instagram user id, Messenger page-scoped id (PSID), or Telegram chat id.
curl -X POST https://flowleb.com/api/v1/messages \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"channel": "instagram",
"to": "1784140000000000",
"text": "Thanks for your message! Your order ships tomorrow."
}'
Know what happened to it
The response tells you the status straight away (sent, or failed with a reason). After that, the status moves on to delivered and read.
- Check one message
GET /messages/{id}- Get told automatically
- Subscribe to
message_delivered,message_readandmessage_failedwebhooks - Why it failed
failure_reason(readable text) anderror_code(Meta's code) are filled in on failed messages