---
title: "Add a webhook"
method: POST
path: "/add-webhook"
tags: ["Chatbot Operations"]
---

# Add a webhook

`POST /add-webhook`

## Request

- Base URL: `https://api.chat-data.com/api/v2`
- URL: `https://api.chat-data.com/api/v2/add-webhook`
- Auth: HTTP bearer

Add a webhook endpoint that receives real-time events from the chatbot: `chat`, `live-chat-escalation`, `lead-submission`, `user-online` or `user-offline`. Your plan must include webhooks. A chatbot can have up to 5 webhook endpoints; adding an event to an existing `url` subscribes that endpoint to one more event.

The [Webhooks](/api-reference/webhooks) page documents every event's body and how to verify deliveries. A `chat` event triggered by a `/chat` request with `skipCache: true` carries `regenerate: true` (the field is absent otherwise). A `live-chat-escalation` matches its `chat` event by `conversation_id`; a `lead-submission` has no `conversation_id`, so pass its `lead.uuid` as `leadId` to [Get conversations](/api-reference/get-conversations).

## Request body

- AddWebhookReq
  - `chatbotId` string, required: The ID of the chatbot the webhook belongs to.
  - `url` string, required: The URL endpoint that the chatbot delivers events to.
  - `event` 'chat' | 'live-chat-escalation' | 'lead-submission' | 'user-online' | 'user-offline', required: The type of event the webhook subscribes to. See [Webhooks](/api-reference/webhooks) for the `chat`, `live-chat-escalation` and `lead-submission` bodies. `user-online` and `user-offline` fire when the user joins or leaves a live chat session and carry `chatbot_id`, `chatbot_name`, `conversation_id` and, when known, the user's `name`, `email`, `phone`, `source` and `user_uuid`. If a webhook with this `url` already exists, the event is added to its subscriptions.
  - `contentType` 'text/plain' | 'application/json': The `Content-Type` of the deliveries. Endpoints on `hook.make.com`, `hook.*.make.com`, `n8n.cloud` and `*.n8n.cloud` always receive `text/plain`. Re-adding an existing `url` updates its content type.

## Response `200`

Successful response.

- object
  - `status` 'success', required
  - `webhooks` WebhookPayload[]: The chatbot's webhooks after the change.
    - `endpoint` string, required: The URL endpoint that the chatbot delivers events to.
    - `events` string[], required: An array of events that the webhook subscribes to. See [Webhooks](/api-reference/webhooks) for the event bodies.
    - `secret` string, required: The secret used to sign deliveries. The `x-chat-data-hmac-sha256` header carries the Base64 HMAC-SHA256 of the raw request body, keyed with this secret.
    - `enable` boolean, required: Indicates whether the webhook is turned on.
    - `contentType` 'text/plain' | 'application/json': The `Content-Type` of the deliveries.

## Other responses

- `400`: The webhook could not be added. For example: the plan does not include webhooks, `event` is not a supported event, `url` is not a valid http(s) URL or points to a placeholder or Chat Data host, `contentType` is not supported, `chatbotId` is missing, or the chatbot already has 5 webhook endpoints.
- `401`: Authentication failed: the `Authorization` header is missing or not in the `Bearer <key>` format, the API key does not exist, its workspace is unavailable or has no owner, or the workspace's plan does not include API access. `message` says which.
- `403`: The API key cannot access the requested chatbot. A chatbot-scoped key used with another chatbot's ID gets `Access denied to this chatbot`. A workspace key gets `Chatbot <id> was not found in this API key's workspace. It may have been deleted or moved to another workspace.` when the chatbot does not exist or belongs to another workspace.
- `429`: The workspace sent more than 600 API requests in the last minute. Wait the number of seconds given in the `Retry-After` header (and in `message`) before retrying.

---

[API](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide.md) · [All operations](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/llms.txt) · [OpenAPI document](https://skmtc.dev/chat-data/apis/chat-data-api-schema-guide/revisions/72871007f7f0?raw)
