---
title: Webhooks
description: Get a signed HTTP request on your server when a conversation starts, gets a message, is handed off or resolved, is rated, or a lead form is sent.
section: Inbox and operations
order: 6
---

A webhook sends a JSON `POST` to your URL each time something happens in a conversation. Use it to sync conversations to a CRM, post hand-offs to Slack, or trigger your own automation.

Webhooks are under **Settings → Webhooks** and available on every plan. Only admins can manage them.

## Events

| Event | Sent when |
|---|---|
| `conversation.created` | A customer starts a conversation |
| `message.created` | Any new message: from the customer, the AI, a teammate, or the system |
| `conversation.handed_off` | The AI passes a conversation to your team |
| `conversation.resolved` | A conversation is resolved by a teammate, by [auto-close](/docs/business-hours), or because of abuse |
| `csat.submitted` | A customer [rates](/docs/csat) a resolved conversation |
| `lead.created` | A customer sends a [lead form](/docs/lead-forms) in the chat |

## Adding a webhook

1. Go to **Settings → Webhooks**.
2. Enter your endpoint URL. It must start with `https://`.
3. Pick the events to receive. All six are selected by default.
4. Click **Add webhook**.

A workspace can have up to 10 webhooks. For each one you can turn it on or off, **Send test**, or delete it. The list shows the result of the last delivery.

## The request

```http
POST /your/endpoint HTTP/1.1
Content-Type: application/json
PandaDesk-Event: conversation.handed_off
PandaDesk-Delivery: 7f0c1e2a-…            (unique per delivery)
PandaDesk-Signature: t=1792915200,v1=5d41402abc4b2a76b9719d911017c592…
```

Every body has the same envelope:

```json
{
  "id": "3b1f…",                       
  "type": "conversation.handed_off",
  "created_at": "2026-10-25T09:31:02.114Z",
  "workspace_id": "a51c…",
  "data": {
    "conversation": {
      "id": "58e74e6b-b2bb-4588-87cc-72aba0043210",
      "status": "open",
      "subject": "Can I get a refund?",
      "created_at": "2026-10-25T09:30:12.000Z",
      "contact": { "name": "Pat", "email": "pat@example.com", "user_id": "user_42", "verified": true }
    },
    "summary": "The customer wants a refund for an order placed two weeks ago…"
  }
}
```

`id` identifies the event. `conversation.status` is one of `ai`, `open`, `pending`, `snoozed` or `closed` (resolved). `contact.verified` is `true` only for visitors identified with [signed identity](/docs/signed-identity).

Each event adds its own fields to `data`:

| Event | Extra fields in `data` |
|---|---|
| `conversation.created` | none |
| `message.created` | `message`: `{ id, role, body, created_at, sources? }`. `role` is `visitor`, `ai`, `agent` (a teammate) or `system`. `sources` lists the titles the AI cited. |
| `conversation.handed_off` | `summary`: the AI-written summary for your team (may be `null`) |
| `conversation.resolved` | `by`: `team`, `auto_close` or `abuse` |
| `csat.submitted` | `rating` (1–5), `comment` (or `null`) |
| `lead.created` | `form`: `{ id, name }`; `values`: the answers by field key (`name`, `email`, `phone`, `company`, `message`, or a custom field's key); `fields`: `[{ key, label, kind }]` for the answered fields; `contact_id` |

A `message.created` example:

```json
{
  "id": "c2d9…",
  "type": "message.created",
  "created_at": "2026-10-25T09:30:15.402Z",
  "workspace_id": "a51c…",
  "data": {
    "conversation": { "id": "58e7…", "status": "ai", "subject": "How do I export my data?", "created_at": "…", "contact": { "name": null, "email": null, "user_id": null, "verified": false } },
    "message": { "id": "5dcc…", "role": "ai", "body": "Go to **Settings → Data** and choose **Export**…", "created_at": "…", "sources": ["Export your data"] }
  }
}
```

## Verifying the signature

Check every request before trusting it. `PandaDesk-Signature` is `t=<unix seconds>,v1=<hex>`. The hex is HMAC-SHA256, keyed with your workspace's **signing secret**, of the timestamp, a dot, and the **raw request body**. Verify against the raw bytes, before parsing the JSON, and reject old timestamps.

Node.js (Express):

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

const app = express();

app.post("/pandadesk/events", express.raw({ type: "application/json" }), (req, res) => {
  const header = req.get("PandaDesk-Signature") ?? "";
  const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
  const expected = crypto.createHmac("sha256", process.env.PANDADESK_SIGNING_SECRET)
    .update(`${t}.${req.body}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
  if (!fresh || !v1 || v1.length !== expected.length || !crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))) {
    return res.sendStatus(400);
  }
  const event = JSON.parse(req.body);
  // … handle event.type
  res.sendStatus(200);
});
```

Python (Flask):

```python
import hmac, hashlib, json, os, time
from flask import Flask, request, abort

app = Flask(__name__)

@app.post("/pandadesk/events")
def pandadesk_events():
    parts = dict(p.split("=", 1) for p in request.headers.get("PandaDesk-Signature", "").split(","))
    t, v1 = parts.get("t", "0"), parts.get("v1", "")
    body = request.get_data()  # raw bytes
    expected = hmac.new(os.environ["PANDADESK_SIGNING_SECRET"].encode(), f"{t}.".encode() + body, hashlib.sha256).hexdigest()
    if abs(time.time() - int(t)) > 300 or not hmac.compare_digest(v1, expected):
        abort(400)
    event = json.loads(body)
    # … handle event["type"]
    return "", 200
```

### The signing secret

It's shown at the bottom of **Settings → Webhooks** (admins only), where you can copy or **Rotate** it. A coding agent gets it with `get_signing_secret`.

> **Note:** The same secret also signs requests from [lookups](/docs/lookups). Rotating it takes effect immediately for both, so update your servers right after.

## Delivery and retries

- Answer with any `2xx` status within 10 seconds for a delivery to count. Redirects aren't followed.
- A failed delivery (timeout, connection error, or a non-2xx status) is retried up to 6 attempts in total. The waits roughly double each time, starting at about 15 seconds, so all attempts finish within about 10 minutes.
- URLs that resolve to a private or internal address are refused and not retried.
- Deliveries can arrive more than once and out of order. Use the event `id` to ignore duplicates, and `created_at` to order them.

**Send test** posts a sample event right away, with `"type": "test"` and a short message in `data`. It shows the result next to the webhook.

## With your coding agent

`list_webhooks`, `add_webhook` (sends a test event unless `send_test` is false) and `delete_webhook`. These are admin tools, on every plan. CLI: `npx pandadesk add_webhook --url https://example.com/hooks --events '["conversation.handed_off"]'`.
