Setup
Panel → “API and webhooks”: enter your server address, choose events and switch sending on. “Send test” delivers a test event. The last 20 deliveries with response codes are shown there too.
Events
conversation.started— the customer sent the first message;message.visitor— a customer message;message.operator— an agent reply;contact.updated— the customer left or updated contacts;deal.created— a deal was created;conversation.closed— a conversation was closed via the API.
Request format
POST with JSON. Headers: X-Sana-Event, X-Sana-Timestamp, X-Sana-Signature.
{"event": "message.visitor", "id": "9f2c41d07a1b3e55", "created_at": "2026-11-29T08:15:03+00:00",
"data": {"conversation": {"id": 812, "channel": "web", "contact": {"name": "Anna", "email": "anna@example.com", "phone": ""}},
"message": {"id": 51230, "sender": "visitor", "text": "Hello! Do you deliver to Shymkent?"}}}Verifying the signature
The signature is HMAC-SHA256 of “timestamp + dot + request body” with the secret from the panel. Reject requests older than 5 minutes.
<?php
$body = file_get_contents('php://input');
$ts = $_SERVER['HTTP_X_SANA_TIMESTAMP'] ?? '';
$sig = $_SERVER['HTTP_X_SANA_SIGNATURE'] ?? '';
$ok = abs(time() - (int) $ts) < 300
&& hash_equals('sha256=' . hash_hmac('sha256', $ts . '.' . $body, 'YOUR_SECRET'), $sig);
if (!$ok) { http_response_code(401); exit; }
$event = json_decode($body, true);
http_response_code(200);// Node.js (Express)
const crypto = require('crypto');
app.post('/hook', express.raw({ type: 'application/json' }), (req, res) => {
const ts = req.get('X-Sana-Timestamp');
const sig = 'sha256=' + crypto.createHmac('sha256', process.env.SANA_SECRET).update(ts + '.' + req.body).digest('hex');
if (sig !== req.get('X-Sana-Signature')) return res.sendStatus(401);
res.sendStatus(200);
});Your server’s response
Answer with a 2xx code within 4 seconds; do long work in the background. The address must be public (http or https).