Lexey
Use casesPricingDocs
Sign inGet started
Get started
  • Use cases
  • Pricing
  • Docs
  • Sign in
Webhook events
Basics
  • Getting started
  • The portal
Features
  • Working with Lexey
  • Knowledge base
  • Conversations
  • Customer chat
  • Skills & automations
  • Testing and releases
  • Quality assurance
  • AI safety
  • Billing & usage
Deployment
  • Embedding your chat
API
  • Customer Chat API
  • Management Chat API
  • Webhook events
  • API key management
  • Streaming guide
  • Agent integration
Help
  • FAQ
API/Webhook events

Webhook events

When you turn on the Send webhook on event skill, Lexey sends an HTTP POST to your URL each time a subscribed event happens. Requests follow the Standard Webhooks specification, so you can verify them with an existing library in most languages.

Event types

  • conversation.escalated — The support agent passed a conversation to your team (the customer was frustrated, the question was outside its knowledge, or a configured escalation rule matched).

Payload

Every payload is JSON with the same envelope:

1{
2 "id": "msg_2f1c0a9d1b7e4c55a3d0f1e2b3c4d5e6",
3 "type": "conversation.escalated",
4 "timestamp": "2026-10-03T04:30:00.000Z",
5 "test": false,
6 "data": {
7 "conversation": {
8 "id": "550e8400-e29b-41d4-a716-446655440000",
9 "status": "escalated",
10 "customerIdentifier": "user@example.com",
11 "createdAt": "2026-10-03T04:00:00.000Z",
12 "channel": "api",
13 "source": { "channel": "api", "label": "API · Mobile app", "apiKeyLabel": "Mobile app" }
14 },
15 "reason": "Customer requested a manager for a refund dispute",
16 "messages": [
17 { "role": "user", "content": "I need to speak to a manager about my refund.", "createdAt": "2026-10-03T04:00:10.000Z" },
18 { "role": "assistant", "content": "I've passed this to the team.", "createdAt": "2026-10-03T04:00:12.000Z" }
19 ],
20 "messagesTruncated": false
21 }
22}
  • id — The delivery's id. It is the same on every retry and replay, so use it to ignore duplicates.
  • type — The event type.
  • timestamp — When the event happened (UTC, ISO 8601), not when this request was sent.
  • test — true for test events sent from the Skills page.
  • data.conversation.channel — Where the customer chatted: hosted (hosted page or widget), portal (Preview) or api (Customer Chat API).
  • data.conversation.source — The same, as a label: Widget, Portal, or for the Customer Chat API API · and the label of the API key that started the conversation. apiKeyLabel is that label on its own, or null. No part of the key itself is ever sent.
  • data.messages — The conversation's latest 100 messages, oldest first. messagesTruncated is true when there were more.

Headers

HeaderValue
webhook-idThe delivery's id, the same as id in the body
webhook-timestampWhen this attempt was sent, in Unix seconds
webhook-signaturev1, followed by the signature; several space-separated signatures during a secret rotation
content-typeapplication/json
user-agentLexey-Webhooks/2.0 (+https://lexey.ai/docs/webhook-events)

Verifying signatures

Lexey creates a signing secret beginning whsec_ when you add your URL. An admin can copy it from Agent › Skills. The signature is a base64 HMAC-SHA256 of <webhook-id>.<webhook-timestamp>.<raw body>, keyed with the secret after whsec_ (base64-decoded).

Check that the timestamp is within five minutes of your clock, so a captured request can't be replayed later, and compare the signature in constant time. The standardwebhooks library does both:

1import { Webhook } from "standardwebhooks";
2 
3const wh = new Webhook(process.env.LEXEY_WEBHOOK_SECRET); // "whsec_..."
4 
5// Use the raw request body: re-serialised JSON won't match the signature.
6const event = wh.verify(rawBody, {
7 "webhook-id": req.headers["webhook-id"],
8 "webhook-timestamp": req.headers["webhook-timestamp"],
9 "webhook-signature": req.headers["webhook-signature"],
10}); // throws if the signature or timestamp is wrong

Without the library:

1import { createHmac, timingSafeEqual } from "node:crypto";
2 
3function verify(rawBody: string, headers: Record<string, string>, secret: string): boolean {
4 const id = headers["webhook-id"];
5 const timestamp = Number(headers["webhook-timestamp"]);
6 if (!id || Math.abs(Date.now() / 1000 - timestamp) > 300) return false;
7 const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
8 const expected = Buffer.from(
9 "v1," + createHmac("sha256", key).update(id + "." + timestamp + "." + rawBody).digest("base64"),
10 );
11 return headers["webhook-signature"].split(" ").some((candidate) => {
12 const actual = Buffer.from(candidate);
13 return actual.length === expected.length && timingSafeEqual(actual, expected);
14 });
15}

When an admin rotates the secret, Lexey signs with both the new and the old secret for 24 hours, so update your server during that window.

Responses, retries and replays

Return a 2xx status within 10 seconds. Do slow work after responding. Any other status, a timeout or a redirect counts as a failed attempt; redirects are not followed.

A failed delivery is retried about 1 minute, 5 minutes, 30 minutes, 2 hours, 5 hours, 10 hours, 14 hours, 24 hours and 24 hours later, ten attempts over about three and a half days. Admins can see every delivery and attempt on the Skills page, send a test event, and replay a delivery or everything that failed since a given time.

Webhooks are sent for real customer conversations and for Preview conversations with your live agent, so you can test your endpoint from the portal. They're never sent for shadow conversations, Preview against a draft or Test Lab runs. Webhooks aren't rate limited: every escalation is delivered or kept for replay.

Endpoints that keep failing

If every attempt has failed for five days, or your endpoint answers 410 Gone, Lexey turns the endpoint off and emails your admins. New events are kept while it is off. Once it's fixed, turn it back on from the Skills page and replay what it missed. Saving a new URL also turns it back on.

Requirements

  • Your URL must use https and resolve to a public address. Private, loopback and link-local addresses are refused.
  • Delivery history is kept for 30 days.
← Previous: Management Chat APINext: API key management →
On this pageEvent typesPayloadHeadersVerifying signaturesResponses, retries and replaysEndpoints that keep failingRequirements
Lexey

Lexey learns your business from your website and answers customers around the clock.

ProductFeaturesPricingUse casesCompareGuides
DocsGetting startedCustomer APIManagement API
AccountSign upSign in
© 2026 Lexey
TermsTerms of servicePrivacyPrivacy policy