Webhooks
When something happens in your account, livechat.ae sends an HTTPS POST with a JSON body to your server, signed with a secret only you and we know.
Set up
- Open Administration → API & webhooks and add your URL. It must be https and reachable from the internet.
- Choose the events you want.
- Copy the secret (
whsec_…): it is shown only once. You can create a new one at any time; the old one stops working immediately. - Press Test: we send a
pingevent and show the response of your server.
Essential includes 3 webhooks, Growth 10, Enterprise unlimited. Webhooks don't count towards your API quota.
Events
| Event | When | data |
|---|---|---|
chat.started | A visitor starts a chat | chat |
chat.visitor_message | The visitor writes (including the first message) | chat, message.text |
chat.agent_message | An agent, an AI agent or an automation writes to the visitor. Use it to send a push notification to the mobile app when visitor.online is false | chat, message (id, text, author, createdAt, attachment), visitor.online, push (platform, token: only when the chat runs in an app with the iOS SDK and the app registered the device) |
chat.closed | The chat is closed by an agent, the visitor or for inactivity | chat |
ticket.created | A ticket is created: from a chat, from an offline message, in the panel or with the API | ticket |
ticket.updated | Status, priority or assignee change | ticket |
ping | You press Test in the panel | message |
chat and ticket are the same objects returned by the REST API (without messages): fetch /chats/{id} or /tickets/{id} when you need the whole conversation.
Payload
POST /your/webhook HTTP/1.1
Content-Type: application/json
User-Agent: livechat.ae-webhooks/1.0
X-Livechat-Event: chat.closed
X-Livechat-Delivery: evt_5b1f0e9c2a7d4e0f9a3b6c8d1e2f3a4b
X-Livechat-Signature: t=1795096599,v1=6f1c…e93a
{
"id": "evt_5b1f0e9c2a7d4e0f9a3b6c8d1e2f3a4b",
"event": "chat.closed",
"createdAt": "2026-11-19T10:10:30Z",
"accountId": "7ff865a3-af91-…",
"data": {
"chat": {
"id": "c1f0b6a2-…", "status": "closed",
"visitor": { "name": "Sara", "email": "sara@example.com", "country": "AE", "language": "en" },
"agent": { "username": "anna@acme.com", "name": "Anna" },
"rating": "good", "tags": ["order"], "closedAt": "2026-11-19T10:10:30Z"
}
}
}
Headers
| Header | Meaning |
|---|---|
X-Livechat-Event | Event type, same as event in the body |
X-Livechat-Delivery | Unique id of the event, same as id; it doesn't change between retries |
X-Livechat-Signature | t= Unix time of the attempt, v1= hex HMAC-SHA256 signature |
Verify the signature
Compute HMAC-SHA256 of t + "." + raw body with your secret and compare it with v1 in constant time. Use the raw body exactly as received, before any JSON parsing. Reject requests whose t is more than 5 minutes old, to block replays.
const crypto = require('crypto');
const express = require('express');
const app = express();
app.post('/livechat-webhook', express.raw({ type: 'application/json' }), (req, res) => {
const header = req.get('X-Livechat-Signature') || '';
const parts = Object.fromEntries(header.split(',').map(p => p.split('=')));
const expected = crypto.createHmac('sha256', process.env.LIVECHAT_WEBHOOK_SECRET)
.update(parts.t + '.' + req.body)
.digest('hex');
const ok = parts.v1 && parts.v1.length === expected.length &&
crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected));
if (!ok || Math.abs(Date.now() / 1000 - Number(parts.t)) > 300) return res.sendStatus(400);
const event = JSON.parse(req.body);
res.sendStatus(200); // answer first…
handle(event); // …then do the work
});
<?php
$secret = getenv('LIVECHAT_WEBHOOK_SECRET');
$body = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_X_LIVECHAT_SIGNATURE'] ?? ''), $parts);
$expected = hash_hmac('sha256', ($parts['t'] ?? '') . '.' . $body, $secret);
if (!hash_equals($expected, $parts['v1'] ?? '') || abs(time() - (int) ($parts['t'] ?? 0)) > 300) {
http_response_code(400);
exit;
}
$event = json_decode($body, true);
http_response_code(200);
// handle $event['event'] and $event['data']
import hashlib, hmac, json, os, time
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["LIVECHAT_WEBHOOK_SECRET"].encode()
@app.post("/livechat-webhook")
def livechat_webhook():
body = request.get_data() # raw bytes
parts = dict(p.split("=", 1) for p in request.headers.get("X-Livechat-Signature", "").split(",") if "=" in p)
expected = hmac.new(SECRET, parts.get("t", "").encode() + b"." + body, hashlib.sha256).hexdigest()
if not hmac.compare_digest(expected, parts.get("v1", "")) or abs(time.time() - int(parts.get("t", 0))) > 300:
abort(400)
event = json.loads(body)
# handle event["event"] and event["data"]
return "", 200
Retries
Any 2xx response within 10 seconds counts as delivered. Anything else – another status, a timeout, a connection error – is retried with the same id:
| Attempt | After |
|---|---|
| 1 | immediately |
| 2 | 1 minute |
| 3 | 5 minutes |
| 4 | 30 minutes |
| 5 | 2 hours |
| 6 | 6 hours, then the delivery is marked as failed |
After 50 failed deliveries in a row the webhook is turned off automatically, and the panel tells you why; turn it back on once your server is fixed. The panel shows the last 20 deliveries of each webhook with their status. Deliveries are kept for 30 days.
Good practices
- Answer fast. Reply 2xx as soon as the signature checks out, then do the slow work in the background.
- Expect duplicates. A retry can arrive after you already processed the event: use
idto skip events you've seen. - Don't rely on order. Events can arrive out of order, especially after retries: compare timestamps such as
updatedAtorclosedAt. - Fetch for details. Use the REST API with the ids in the event when you need the full chat or ticket.