# Delete a webhook

`POST https://api.chat-data.com/api/v2/delete-webhook`

Canonical: https://www.chat-data.com/api-reference/delete-webhook

## Authentication

Send an API key as a Bearer token: `Authorization: Bearer $CHAT_DATA_API_KEY`. Workspace keys reach every chatbot in the workspace; chatbot-scoped keys reach only their chatbot. Keep keys on the server.

## Description

Delete the webhook registered with the given URL, together with all of its event subscriptions. The response lists the chatbot's remaining webhooks. If no webhook matches `url`, nothing is deleted and the response is still 200 with the unchanged list.

## Request body (`application/json`)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| chatbotId | string | yes | The ID of the chatbot the webhook belongs to. |
| url | string | yes | The URL endpoint that the chatbot delivers events to. |

## Example request

```bash
curl 'https://api.chat-data.com/api/v2/delete-webhook' \
  -H "Authorization: Bearer $CHAT_DATA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "chatbotId": "6650f1c2a9e4b83d2c7a1f05",
  "url": "https://example.com/webhooks/chat-data"
}'
```

## Example response (200)

```json
{
  "status": "success",
  "webhooks": [
    {
      "endpoint": "https://example.com/webhooks/chat-data",
      "events": [
        "chat"
      ],
      "secret": "4f9a2c7e1b8d3f6a0c5e9b2d7a1f4c8e3b6d9f2a5c8e1b4d7f0a3c6e9b2d5f8a",
      "enable": true,
      "contentType": "text/plain"
    }
  ]
}
```

## Responses

| Status | Description |
| --- | --- |
| 200 | Successful response. |
| 400 | `url` is missing or not a valid URL (`Please provide a valid url.`), `chatbotId` is missing, or an unexpected error occurred while saving. |
| 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. |
