API guide
Webhooks
Receive events from LexoConnect in real time, verify their signatures, and handle retries, duplicates and replays.
How webhooks work#
When something happens in a company (a call rings, a message arrives, an agent saves an outcome), LexoConnect sends an HTTP POST to every webhook endpoint of that company that subscribed to the event. Deliveries are signed per the Standard Webhooks specification, retried when your server fails, and logged for 30 days.
Manage endpoints in Admin → Developer → Webhooks, or with the API (scope webhooks):
curl -X POST "$LEXO_URL/api/v1/webhooks/endpoints" \
-H "Authorization: Bearer $LEXO_API_KEY" -H "Content-Type: application/json" \
-d '{"url": "https://api.example.com/lexo/webhooks", "description": "Production CRM sync", "events": ["call.ended", "call.dispositioned", "message.received"]}'The create answer is {"endpoint": {...}, "secret": "whsec_..."}. events: ["*"] subscribes to every event, including ones added later. The URL must be public HTTPS. PATCH /webhooks/endpoints/{id} changes the URL, events or active; POST .../rotate-secret issues a new signing secret.
Events#
GET /webhooks/events returns the same list at run time.
| Event | When it is sent |
|---|---|
call.ringing | A call started ringing (inbound or outbound) |
call.answered | A call was answered and connected |
call.ended | A call ended; data is the call record |
call.transferred | A call was transferred (blind, attended, REFER or API) |
call.dispositioned | An agent saved the outcome of a call: disposition, note, follow-up, record, lead and campaign |
recording.ready | A call recording finished and can be downloaded |
voicemail.created | A caller left a voicemail |
message.received | An inbound SMS, WhatsApp, email or chat message arrived |
message.status | The delivery status of an outbound message changed |
contact.created | A CRM record was created (any object; data.object names it) |
contact.updated | A CRM record was updated |
campaign.lead.completed | A dialer campaign lead reached a final state |
rvm.delivered | A ringless voicemail or voicemail drop was left in the mailbox |
rvm.failed | A ringless voicemail or voicemail drop could not be delivered |
agent.state | A contact center agent changed state |
ai.call.ended | An AI agent call ended; data has the transcript, summary, outcome, tool calls and cost |
webhook.test is sent by the Send test event button and POST /webhooks/endpoints/{id}/test. New event types may be added at any time; ignore types you do not handle.
The payload#
Every delivery has the same envelope:
{
"type": "message.received",
"timestamp": "2026-11-13T10:06:00Z",
"tenantId": "9c8b7a6d-5e4f-4a3b-2c1d-0e9f8a7b6c5d",
"data": {
"conversationId": "1f2e3d4c-5b6a-4798-8a9b-0c1d2e3f4a5b",
"channel": "sms",
"channelAccountId": "2a3b4c5d-6e7f-4809-1a2b-3c4d5e6f7a8b",
"from": "+12125550123",
"message": { "id": "3b4c5d6e-7f80-4912-a3b4-c5d6e7f8a9b0", "direction": "inbound", "body": "Can you call me back?", "status": "delivered", "createdAt": "2026-11-13T10:06:00Z" }
}
}A few other data shapes:
{ "type": "call.ringing", "data": { "callUuid": "3f0c1d8e-…", "direction": "inbound", "from": "+12125550123", "to": "+14155550100", "userId": "0b7e5d1c-…", "at": "2026-11-13T10:00:01Z" } }call.ended carries the full call record (the same fields as GET /calls/{id}) plus callUuid. The API reference has an example for every event.
Verify the signature#
Each delivery carries three headers:
| Header | Value |
|---|---|
webhook-id | a unique message id (msg_…), the same on every retry of this message |
webhook-timestamp | unix seconds when this attempt was signed |
webhook-signature | v1,<base64 HMAC-SHA256>, possibly several separated by spaces (during a secret rotation) |
The signed content is webhook-id + "." + webhook-timestamp + "." + raw body, and the HMAC key is the base64-decoded part of the secret after whsec_. Always verify against the raw request body (before any JSON parsing), compare in constant time, and reject timestamps more than 5 minutes from your clock.
// Node.js / Express
import crypto from "node:crypto";
import express from "express";
const SECRET = process.env.LEXO_WEBHOOK_SECRET; // "whsec_..."
function verify(headers, rawBody) {
const id = headers["webhook-id"], ts = headers["webhook-timestamp"], sigs = headers["webhook-signature"];
if (!id || !ts || !sigs) return false;
if (Math.abs(Date.now() / 1000 - Number(ts)) > 300) return false;
const key = Buffer.from(SECRET.slice("whsec_".length), "base64");
const expected = "v1," + crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64");
return sigs.split(" ").some((s) => s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected)));
}
const app = express();
app.post("/lexo/webhooks", express.raw({ type: "application/json" }), (req, res) => {
if (!verify(req.headers, req.body.toString("utf8"))) return res.sendStatus(401);
const event = JSON.parse(req.body);
res.sendStatus(204); // answer fast, then work
handle(event).catch(console.error);
});
app.listen(3000);Any Standard Webhooks library also works (for example standardwebhooks for Node.js and Python, or svix libraries): pass it the whsec_… secret.
Retries, duplicates and order#
- Answer with any 2xx within 15 seconds. Do the real work after answering (put the event on a queue).
- Any other answer, a timeout or a connection error is retried 9 times with exponential back-off: after 10 s, 30 s, 90 s, 4.5 min, 13.5 min, 40.5 min, about 2 h, 6 h and 12 h.
- A message can arrive more than once. Deduplicate on `webhook-id`; it stays the same across retries and replays.
- Events are not guaranteed to arrive in order (a retried
call.answeredcan come aftercall.ended). Use thetimestampand the object's own state when order matters. - LexoConnect sends deliveries with the
User-Agent: LexoConnect-Webhooks/1.0header.
Delivery log and replay#
GET /webhooks/deliveries lists deliveries of the last 30 days (filter by endpointId, status, event), and GET /webhooks/deliveries/{id} shows the payload, every attempt, the status code and the start of your server's answer. After fixing a bug on your side, send a failed message again with POST /webhooks/deliveries/{id}/replay: same webhook-id, new timestamp and signature. The same log is in the app under Admin → Developer → Webhooks.