# Webhooks

> Get signed LemuTickets events at your endpoint: subscribing, the event list, payloads, verifying signatures and retries

URL: https://docs.lemuai.com/tickets-api/webhooks

Webhooks tell your system when something happens in LemuTickets, such as a new ticket, a status change or a customer reply, so you don't have to poll. LemuTickets sends an HTTPS `POST` with a JSON body to your URL for every event you subscribe to.

## Subscribe

Either in the app:

1. Open **Settings → API keys and webhooks** and select the **Webhooks** tab.
2. Click **Add webhook**.
3. Enter the **Endpoint URL**, an optional **Description**, the **Events** to send (use `area.*` for every event of that kind, for example `ticket.*`), and optionally the **Projects** to send events for. Empty means all projects.
4. Copy the signing secret. It is shown only once.

Or with the API: [Create a webhook](https://docs.lemuai.com/tickets-api/webhook-subscriptions/create).

The URL must be public. Private, local and internal addresses are refused.

On the same tab you can see each webhook's **Deliveries** with the response your endpoint gave, **Send again** a delivery, **Send test event**, and **Rotate secret**. The old secret stops working as soon as you rotate it.

## Events

| Event | When |
|---|---|
| `ticket.created` | A ticket was created |
| `ticket.updated` | Fields on a ticket changed |
| `ticket.transitioned` | A ticket moved to another status |
| `ticket.assigned` | The assignee or team changed |
| `ticket.resolved` | A ticket reached a resolved status |
| `ticket.reopened` | A resolved or closed ticket was reopened |
| `ticket.closed` | A ticket was closed |
| `ticket.deleted` | A ticket was deleted |
| `ticket.merged` | A ticket was merged into another |
| `ticket.escalated` | A ticket was escalated |
| `ticket.linked` | A link between tickets was added |
| `ticket.major_incident` | A ticket was flagged or unflagged as a major incident |
| `comment.created` | A reply or internal note was added |
| `comment.delivery_updated` | A reply's delivery status changed (for example, the email or WhatsApp message was delivered or failed) |
| `sla.warning` | An SLA target is close to breach |
| `sla.breached` | An SLA target was breached |
| `csat.submitted` | A requester rated a ticket |
| `approval.requested` | An approval was requested |
| `approval.decided` | An approval was approved or rejected |
| `worklog.created` | Time was logged on a ticket |
| `requester.created` | A requester was created |
| `requester.updated` | A requester was updated |
| `account.updated` | An account was created or updated |
| `assignment.unassigned` | A ticket stayed unassigned longer than the project allows |
| `asset.created` | An asset was created |
| `asset.updated` | An asset changed |
| `problem.created` | A problem record was created |
| `problem.updated` | A problem record changed |
| `change.created` | A change request was created |
| `change.updated` | A change request changed status or was voted on |
| `visit.updated` | A field visit was scheduled or changed |
| `visit.reminder` | A field visit is due tomorrow |
| `ai.triaged` | The AI classified a new ticket |
| `autopilot.action_proposed` | Autopilot proposed an action (inside its review window) |
| `autopilot.action_done` | Autopilot carried out an action |
| `lemu.issue_suggested` | Lemu AI found an issue in a conversation and it is waiting for review |
| `webhook.disabled` | A webhook subscription was turned off after repeated failures |

`GET /v1/events/catalog` returns the same list as `{"data": [{"type", "description"}]}`.

Patterns use `*` as a wildcard: `ticket.*` matches every ticket event, `*` matches everything. Each pattern must match at least one event.

When a webhook is limited to some projects, it only gets events that belong to a ticket in those projects. Events that are not about a ticket (requesters, accounts, `webhook.disabled`) are only sent to webhooks without a project filter.

## Payload

Every delivery has the same envelope:
```json
{
  "id": "evt_48213",
  "type": "ticket.transitioned",
  "created_at": "2026-11-25T09:30:02.114210+00:00",
  "org_id": "5e7a9c1b-3d2f-4a6e-8b0c-2d4f6a8c0e1b",
  "data": {
    "actor": {
      "type": "user",
      "id": "0e2a4c6b-8d1f-4a3e-9b5c-7d9f1a3c5e7b",
      "name": "Arjun Mehta"
    },
    "ticket": {
      "id": "2f9c7e1a-5b3d-4c8e-9a6f-1d0e2b4c6a8f",
      "key": "SUP-1042",
      "title": "Refund not received for order 58213",
      "status": { "id": "6e1f2a3b-8c4d-4f5e-a6b7-c8d9e0f1a2b3", "name": "In progress", "category": "open", "color": "blue" },
      "status_category": "open",
      "priority": "p2",
      "external_id": "ERP-CMP-58213",
      "version": 4
    },
    "changes": {},
    "details": {
      "from": "Open",
      "to": "In progress",
      "from_category": "open",
      "to_category": "open",
      "transition": "Start work"
    }
  }
}
```

| Field | Description |
|---|---|
| `id` | The event id. It stays the same on every retry and redelivery, so use it to ignore events you have already handled. |
| `type` | The event name from the list above. |
| `created_at` | When the event was queued. |
| `org_id` | Your organization's id. |
| `data.actor` | Who caused it: `type` is `user`, `api_key`, `integration`, `requester`, `automation`, `ai` or `system`, with `id` and `name`. |
| `data.ticket` | For ticket and comment events: the whole ticket as it is when the event is sent. See [the ticket object](https://docs.lemuai.com/tickets-api/tickets/overview). Shortened above. |
| `data.changes` | For `ticket.updated`: each changed field as `[old, new]`, for example `{"priority": ["p3", "p1"]}`. Empty for other events. |
| `data.comment` | For `comment.*` events: the comment, in the same shape as [List comments](https://docs.lemuai.com/tickets-api/tickets/list-comments). |
| `data.details` | Event-specific details, for example the `from` and `to` status of a transition, or the `minutes` of a worklog. |

Events that are not about a ticket put their fields directly in `data`, for example `{"actor": {"type": "system"}, "requester_id": "8b4d6f2a-..."}` for `requester.created`. Fetch the full object with the API if you need it.

**Note:** `comment.created` is sent for internal notes too. Check `data.comment.visibility` (`public` or `internal`) before showing a comment to a customer.

## Headers

| Header | Value |
|---|---|
| `Content-Type` | `application/json` |
| `User-Agent` | `LemuTickets-Webhooks/1.0` |
| `X-LemuTickets-Event` | The event type, for example `ticket.created` |
| `X-LemuTickets-Delivery` | The delivery id. A manual **Send again** gets a new one |
| `X-LemuTickets-Signature` | `t=<unix time>,v1=<signature>` (see below) |

## Verify the signature

Check every delivery before you trust it. The signature is an HMAC-SHA256, in hex, of the timestamp, a dot, and the raw request body, using your webhook's signing secret (`whsec_...`) as the key:
```
v1 = hex(HMAC_SHA256(secret, "<t>.<raw body>"))
```

1. Read `t` and `v1` from the `X-LemuTickets-Signature` header.
2. Compute the HMAC over the **raw** body bytes as received. Parsing and re-encoding the JSON changes the bytes and breaks the check.
3. Compare with `v1` in constant time.
4. Reject the delivery if `t` is more than 5 minutes from your clock, to stop replays.

**Node.js**

```js
import crypto from "node:crypto";
import express from "express";

const app = express();
const SECRET = process.env.LEMU_TICKETS_WEBHOOK_SECRET; // whsec_...

app.post("/lemutickets/webhook", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("X-LemuTickets-Signature") || "";
  const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
  const t = Number(parts.t);
  const expected = crypto
    .createHmac("sha256", SECRET)
    .update(`${parts.t}.`)
    .update(req.body)
    .digest("hex");
  const ok =
    parts.v1 &&
    parts.v1.length === expected.length &&
    crypto.timingSafeEqual(Buffer.from(parts.v1), Buffer.from(expected)) &&
    Math.abs(Date.now() / 1000 - t) <= 300;
  if (!ok) return res.status(400).send("bad signature");

  const event = JSON.parse(req.body.toString("utf8"));
  // Handle the event, then answer quickly with a 2xx
  res.sendStatus(204);
});
```

**Python**

```python
import hashlib
import hmac
import os
import time

from flask import Flask, abort, request

app = Flask(__name__)
SECRET = os.environ["LEMU_TICKETS_WEBHOOK_SECRET"]  # whsec_...


@app.post("/lemutickets/webhook")
def lemutickets_webhook():
    header = request.headers.get("X-LemuTickets-Signature", "")
    parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
    t, sig = parts.get("t", ""), parts.get("v1", "")
    body = request.get_data()  # raw bytes
    expected = hmac.new(SECRET.encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
    if not t.isdigit() or not hmac.compare_digest(sig, expected):
        abort(400)
    if abs(time.time() - int(t)) > 300:
        abort(400)

    event = request.get_json()
    # Handle the event, then answer quickly with a 2xx
    return "", 204
```

## Responding and retries

- Answer with any `2xx` status within 10 seconds. Do slow work after you answer, for example in a queue.
- Redirects are not followed, and any other status, a timeout or a connection error counts as a failure.
- Failed deliveries are retried with growing gaps (30 seconds, 1 minute, 2 minutes, 4 minutes and so on, up to 1 hour between tries) for 24 hours. After that the delivery is marked failed. You can still send it again from **Deliveries**.
- Deliveries go out within about 10 seconds of the event, several at a time, so they can arrive out of order. Use `created_at` and the ticket's `version` to tell which is newer.
- After 50 failed attempts in a row, the webhook is turned off, its pending deliveries are marked failed, and a `webhook.disabled` event is sent to any other webhook subscribed to it. Fix your endpoint, then turn **Send events** back on in the webhook's settings. That resets the failure count.

## Test your endpoint

**Send test event** on the webhook (or `POST /v1/webhooks/{webhook_id}/ping`) sends a signed `webhook.ping` event straight away:
```json
{
  "id": "ping_Xk2pQ9aB",
  "type": "webhook.ping",
  "created_at": "2026-11-25T09:31:10.004512+00:00",
  "org_id": "5e7a9c1b-3d2f-4a6e-8b0c-2d4f6a8c0e1b",
  "data": {
    "webhook_id": "f2a4c6e8-0b1d-4f3a-8c5e-a7c9e1b3d5f7",
    "message": "Webhook is reachable"
  }
}
```
