# Channel webhooks

`crm.channelWebhooks` — `/v1/channels/:channelId/webhooks`

Where a channel's message traffic is delivered.

These carry conversation events — `incoming`, `sent`, `delivered`, `read`,
`failed` — plus the account-level notices Meta sends about templates, the phone
number and the WABA. Several webhooks may watch the same channel, and each gets
its own copy.

Distinct from [`crm.webhooks`](../audience/webhooks.md), which carries contact
changes from the audience module.

| Action | Route | Scope |
| --- | --- | --- |
| [`list`](#list) | `GET /v1/channels/:channelId/webhooks` | `channels:read` |
| [`get`](#get) | `GET /v1/channels/:channelId/webhooks/:id` | `channels:read` |
| [`create`](#create) | `POST /v1/channels/:channelId/webhooks` | `channels:write` |
| [`update`](#update) | `PATCH /v1/channels/:channelId/webhooks/:id` | `channels:write` |
| [`delete`](#delete) | `DELETE /v1/channels/:channelId/webhooks/:id` | `channels:write` |

**Permissions** — `CRM.CHANNEL.WEBHOOK`: `LIST`, `READ`, `CREATE`, `UPDATE`,
`DELETE`. The two channel props that read and re-point the provider-side
callback (`webhook_status`, `webhook_listener_update`) belong to this feature
too, not to the channel: re-pointing a listener diverts every inbound message on
that channel.

## The webhook object

```ts
interface ChannelWebhook {
  id: string;
  channelId: string;
  title: string;
  active: boolean;
  events: ChannelWebhookEvent[];
  url: string;
  meta?: {
    source: 'PANEL' | 'API';
    createdBy?: string;
    createdIp?: string;
    updatedBy?: string;
    updatedIp?: string;
  };
  createdAt: string;
  updatedAt: string;
}
```

`meta` is an **audit trail**: who created or last changed the webhook and from
where. It is filled in by the service from the caller's identity and IP, and is
never accepted on a write. Webhooks created through this SDK are recorded with
`source: 'API'`.

### Events

| Event | Fires on |
| --- | --- |
| `incoming` | A message from the customer. |
| `sent` | A message accepted for delivery. |
| `delivered` | Delivery confirmed. |
| `read` | The customer read it. |
| `failed` | Delivery failed. |
| `deleted` | A message was deleted. |
| `template` | A template's status changed at Meta. |
| `account` | A WABA-level notice. |
| `phone_number` | A phone-number-level notice. |
| `calls` | A call event. |

Exported as `CHANNEL_WEBHOOK_EVENTS` if you need the list at runtime.

---

## list

```ts
crm.channelWebhooks.list(channelId: string, query?: Partial<ListChannelWebhooksQuery>): Promise<Paginated<ChannelWebhook>>
```

`GET /v1/channels/:channelId/webhooks` · `channels:read` · **200**

| Field | Type | Default | Notes |
| --- | --- | --- | --- |
| `page` | number | `1` | 1-based. |
| `rows` | number | `25` | 1–100. |
| `search` | string | — | 1–120 chars. Matches the **title and URL**. |
| `active` | boolean | — | Quick filter: enabled/disabled. |
| `event` | `ChannelWebhookEvent` | — | Quick filter: webhooks subscribed to this one event. |

```ts
const live = await crm.channelWebhooks.list(channelId, { active: true, event: 'incoming' });
```

---

## get

```ts
crm.channelWebhooks.get(channelId: string, id: string): Promise<ChannelWebhook>
```

`GET /v1/channels/:channelId/webhooks/:id` · `channels:read` · **200**

---

## create

```ts
crm.channelWebhooks.create(channelId: string, input: CreateChannelWebhookInput): Promise<ChannelWebhook>
```

`POST /v1/channels/:channelId/webhooks` · `channels:write` · **201**

### Body

| Field | Type | Required | Default | Notes |
| --- | --- | --- | --- | --- |
| `url` | string | yes | — | Valid absolute URL, up to 2048 chars. |
| `events` | `ChannelWebhookEvent[]` | yes | — | At least one. |
| `title` | string | no | `'CRM Channel Webhook'` | 1–120 chars. |
| `active` | boolean | no | `true` | |

```ts
await crm.channelWebhooks.create(channelId, {
  title: 'Inbox bridge',
  url: 'https://inbox.example.com/hooks/whatsapp',
  events: ['incoming', 'sent', 'delivered', 'read', 'failed'],
});
```

---

## update

```ts
crm.channelWebhooks.update(channelId: string, id: string, input: UpdateChannelWebhookInput): Promise<ChannelWebhook>
```

`PATCH /v1/channels/:channelId/webhooks/:id` · `channels:write` · **200**

Same fields as `create`, all optional; at least one is required.

`events` **replaces** the subscription list rather than adding to it. Pause
delivery with `{ active: false }` rather than deleting, so the configuration
comes back.

---

## delete

```ts
crm.channelWebhooks.delete(channelId: string, id: string): Promise<void>
```

`DELETE /v1/channels/:channelId/webhooks/:id` · `channels:write` · **204**

Delivery stops immediately.
