Webhooks
Get a signed HTTPS call the moment something happens, so your system can react straight away.
A webhook is an address on your server. When an event happens, such as a customer reply, Flowleb sends the details there straight away. No need to keep asking the API.
Step 1 · Make an address that accepts POST
It must be a public https address, like https://yourapp.com/flowleb/webhook. The code samples in step 3 are complete, working handlers.
Step 2 · Add the webhook
-
Open Webhooks and click New webhook
Developer Webhooks
-
Fill in the form
Your URL, the events you want, and a signing secret: a long random string only you and Flowleb know.
-
Click Test fire
Flowleb sends a test call. Your server should answer with
200.
New webhook
1Endpoint URLhttps://yourapp.com/flowleb/webhook 2Eventsmessage_receivedmessage_deliveredmessage_failed 3Signing secret••••••••••••••••- Your public HTTPS address.
- Pick the events you want, or all of them.
- A long random secret. You'll use it to check the signature.
- Send a test call to make sure your server answers.
Simplified drawing of the dashboard page.
Prefer code? Create it through the API:
/api/v1/webhooks
Leave out events (or send ["*"]) to receive everything.
curl -X POST https://flowleb.com/api/v1/webhooks \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "CRM sync",
"url": "https://yourapp.com/flowleb/webhook",
"events": ["message_received", "message_delivered", "message_failed"],
"secret": "a-long-random-string-only-you-know"
}'
What Flowleb sends
POST https://yourapp.com/flowleb/webhook
Content-Type: application/json
X-Flowleb-Signature: 5d41402abc4b2a76b9719d911017c592…
{
"id": "0b8f6a52-6c1e-4b8a-9d55-0f3c5e2a7b91",
"event": "message_received",
"eventType": "message_received",
"created": "2026-11-18T10:45:03+05:30",
"timestamp": 1763442903,
"data": {
"message_id": 48231,
"conversation_id": 5530,
"from_number": "919876543210",
"body": "Is my order on the way?",
"media_type": null,
"provider": "waba",
…
}
}
- id
- Unique per delivery. Save it and skip ids you have already handled.
- event
- Which event this is.
eventTypeis the same value. - created · timestamp
- When it happened.
- data
- The details. Fields depend on the event.
Step 3 · Check the signature
When you set a secret, every delivery has an X-Flowleb-Signature header: an HMAC-SHA256 of the request body made with your secret, written as hex. Make the same code yourself and compare. If they don't match, reject the call. It didn't come from Flowleb.
import express from 'express';
import crypto from 'node:crypto';
const app = express();
// Keep the RAW body: the signature is made from the exact bytes we send.
app.post('/flowleb/webhook', express.raw({ type: 'application/json' }), (req, res) => {
const expected = crypto
.createHmac('sha256', process.env.FLOWLEB_WEBHOOK_SECRET)
.update(req.body) // Buffer, before JSON.parse
.digest('hex');
const got = req.get('X-Flowleb-Signature') || '';
const ok = got.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(got), Buffer.from(expected));
if (!ok) return res.sendStatus(401);
const event = JSON.parse(req.body);
res.sendStatus(200); // answer first…
queue.add(event); // …then do the slow work
});
import hmac, hashlib, os
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["FLOWLEB_WEBHOOK_SECRET"].encode()
@app.post("/flowleb/webhook")
def flowleb_webhook():
raw = request.get_data() # raw bytes, before parsing
expected = hmac.new(SECRET, raw, hashlib.sha256).hexdigest()
got = request.headers.get("X-Flowleb-Signature", "")
if not hmac.compare_digest(expected, got):
abort(401)
event = request.get_json()
handle_later(event) # e.g. push to a job queue
return "", 200
<?php
$raw = file_get_contents('php://input'); // raw body, before json_decode
$expected = hash_hmac('sha256', $raw, getenv('FLOWLEB_WEBHOOK_SECRET'));
$signature = $_SERVER['HTTP_X_FLOWLEB_SIGNATURE'] ?? '';
if (! hash_equals($expected, $signature)) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
http_response_code(200);
// …then save $event and process it in the background
Events
| Event | Fires when |
|---|---|
| message_received | A customer message arrives |
| message_sent · message_delivered · message_read · message_failed | One of your messages changes status |
| broadcast_created · broadcast_status_updated | A broadcast is created or changes status |
| broadcast_message_status_updated | One person's message in a broadcast changes status |
| campaign_created · campaign_status_updated | A campaign is created or changes status |
| campaign_contact_status_updated | One person's message in a campaign changes status |
| campaign_contact_replied · campaign_contact_clicked | Someone replies to a campaign or clicks its link |
| contact_opt_in · contact_updated | A contact opts in or is changed |
| device_status_updated | A connected number goes online or offline |
| * | Every event |
Delivery rules
- Answer within 10 seconds
- Slower than that counts as a failure. Reply
200first, then do slow work in the background. - Retries
- Up to 3 tries in total when your server is unreachable, times out, or answers
429or5xx. - No retry on other 4xx
- Answering
400,401or404means "rejected", so Flowleb doesn't try again. - Same event twice
- Can happen after a retry. Skip any
idyou have already handled. - Failing hooks
- After 3 failures in a row the webhook is marked Failing on the Webhooks page, with the last error, so you can fix it.