curl -X GET https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X POST https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"webhookUrl": "https://your-site.com/webhook"
}'
// Set webhook
const response = await fetch("https://api.livchat.ai/v1/webhook", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
webhookUrl: "https://your-site.com/webhook",
}),
});
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook",
"subscribe": ["Message", "ReadReceipt"]
}
}
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook"
}
}
Webhooks
Webhooks
Configure webhook for receiving events
GET
/
v1
/
webhook
curl -X GET https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X POST https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"webhookUrl": "https://your-site.com/webhook"
}'
// Set webhook
const response = await fetch("https://api.livchat.ai/v1/webhook", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
webhookUrl: "https://your-site.com/webhook",
}),
});
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook",
"subscribe": ["Message", "ReadReceipt"]
}
}
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook"
}
}
Configure a webhook URL to receive real-time events like incoming messages and read receipts.
Webhooks will include
Get Webhook Configuration
Retrieve current webhook configuration
Set Webhook Configuration
Configure or update webhook URL
Request Body (POST)
string
required
URL to receive webhook events (must be HTTPS)
Event Types
Subscribe to events when connecting the session:| Event | Description |
|---|---|
Message | Incoming and outgoing messages |
ReadReceipt | Message read confirmations |
HistorySync | Chat history synchronization |
ChatPresence | Online status and typing indicators |
Webhook Payload
Events are sent as POST requests to your webhook URL:{
"event": {
"info": {
"id": "3EB04A45DCA355D01DB68C",
"messageSource": {
"chat": "5511999999999@s.whatsapp.net",
"sender": "5511888888888@s.whatsapp.net",
"isFromMe": false,
"isGroup": false
},
"pushName": "John",
"timestamp": "2024-12-10T10:00:00Z"
},
"message": {
"conversation": "Hello!"
}
},
"type": "Message"
}
Securing Webhooks (HMAC)
Configure HMAC signing for webhook verification:# Configure HMAC key (min 32 characters)
curl -X POST https://api.livchat.ai/v1/session/hmac/config \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"hmacKey": "your_secret_key_minimum_32_characters"}'
x-hmac-signature header for verification.
curl -X GET https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY"
curl -X POST https://api.livchat.ai/v1/webhook \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"webhookUrl": "https://your-site.com/webhook"
}'
// Set webhook
const response = await fetch("https://api.livchat.ai/v1/webhook", {
method: "POST",
headers: {
Authorization: "Bearer YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
webhookUrl: "https://your-site.com/webhook",
}),
});
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook",
"subscribe": ["Message", "ReadReceipt"]
}
}
{
"success": true,
"code": 200,
"data": {
"webhook": "https://your-site.com/webhook"
}
}