> ## Documentation Index
> Fetch the complete documentation index at: https://www.checklyhq.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# WebhookAlertChannel Construct

> Learn how to configure webhook alert channels with the Checkly CLI.

> [!TIP]
>
> For general information about alerting, see our docs on [webhook alerts](https://www.checklyhq.com/docs/integrations/alerts/webhooks.md) and [alerting with Checkly](https://www.checklyhq.com/docs/communicate/alerts/overview.md).

Sends alert notifications as HTTP requests to any URL. This is the most flexible alert channel type, allowing integration with any service that accepts webhooks.

You can customize the payload with our [Handlebars-style variables and helpers](https://www.checklyhq.com/docs/integrations/alerts/webhooks.md#using-variables).

```ts Basic Example theme={null}
import { WebhookAlertChannel } from "checkly/constructs"

const webhookChannel = new WebhookAlertChannel("webhook-channel-1", {
  name: "Basic Webhook",
  method: "POST",
  url: new URL("https://api.example.com/webhooks/checkly"),
  template: JSON.stringify({
    message: "Check {{ALERT_TITLE}} is {{ALERT_TYPE}}",
    timestamp: "{{STARTED_AT}}",
  }),
})
```

```ts Advanced Example theme={null}
import { WebhookAlertChannel } from 'checkly/constructs'

const webhookChannel = new WebhookAlertChannel('webhook-channel-1', {
  name: 'Pushover webhook',
  method: 'POST',
  url: new URL('https://api.pushover.net/1/messages.json'),
  headers: [{ key: 'X-My-Header', value: 'myToken' }],
  queryParameters: [{ key: 'source', value: 'checkly' }],
  template: `{
    "token":"FILL_IN_YOUR_SECRET_TOKEN_FROM_PUSHOVER",
    "user":"FILL_IN_YOUR_USER_FROM_PUSHOVER",
    "title":"{{ALERT_TITLE}}",
    "html":1,
    "priority":2,
    "retry":30,
    "expire":10800,
    "message":"{{ALERT_TYPE}} {{STARTED_AT}} ({{RESPONSE_TIME}}ms) {{RESULT_LINK}}"
  }`,
  sendRecovery: true,
  sendFailure: true,
  sendDegraded: true,
  sslExpiry: true,
  sslExpiryThreshold: 30,
})
```

> [!NOTE]
>
> If you need to reference existing alert channels that were created outside of your CLI project, use [`fromId()`](https://www.checklyhq.com/docs/constructs/alert-channel#using-fromid-to-reference-an-existing-channel).

## Configuration

### Webhook Alert Channel Options

**url** `URL` *required*

Target URL for the webhook request.

```ts highlight={4} theme={null}
new WebhookAlertChannel('webhook-channel-1', {
  name: 'Pushover webhook',
  method: 'POST',
  url: new URL('https://api.pushover.net/1/messages.json'),
})
```

**method** `string` *required*

The HTTP method, either `GET`, `POST`, `PUT`, `PATCH`, `HEAD` or `DELETE`.

**name** `string`

Friendly name for the webhook channel.

**template** `string`

The request body template, usually JSON. You can use [Handlebars-style template variables](https://www.checklyhq.com/docs/integrations/alerts/webhooks.md#using-variables) to further customize the template.

```ts highlight={5-14} theme={null}
new WebhookAlertChannel('webhook-channel-1', {
  name: 'Pushover webhook',
  method: 'POST',
  url: new URL('https://api.pushover.net/1/messages.json'),
  template: `{
    "token":"FILL_IN_YOUR_SECRET_TOKEN_FROM_PUSHOVER",
    "user":"FILL_IN_YOUR_USER_FROM_PUSHOVER",
    "title":"{{ALERT_TITLE}}",
    "html":1,
    "priority":2,
    "retry":30,
    "expire":10800,
    "message":"{{ALERT_TYPE}} {{STARTED_AT}} ({{RESPONSE_TIME}}ms) {{RESULT_LINK}}"
  }`
})
```

**headers** `array`

An array of `{ key, value }` objects to define HTTP headers.

```ts highlight={5} theme={null}
new WebhookAlertChannel('webhook-channel-1', {
  name: 'Pushover webhook',
  method: 'POST',
  url: new URL('https://api.pushover.net/1/messages.json'),
  headers: [{ key: 'X-My-Header', value: '123' }],
})
```

**queryParameters** `array`

An array of `{ key, value }` objects to define query parameters.

```ts highlight={5} theme={null}
new WebhookAlertChannel('webhook-channel-1', {
  name: 'Pushover webhook',
  method: 'POST',
  url: new URL('https://api.pushover.net/1/messages.json'),
  queryParameters: [{ key: 'my-param', value: '123' }],
})
```

**webhookSecret** `string`

Secret token that you can use to validate the authenticity of the webhook and its payload. [Learn more about webhook secrets.](https://www.checklyhq.com/docs/integrations/alerts/webhooks.md#webhook-secrets)

### General Alert Channel Options

These options are valid for all alert channels types.

**sendRecovery** `boolean`

Whether to send notifications when checks recover from a [failed or degraded state](https://www.checklyhq.com/docs/communicate/alerts/overview.md#alert-channels). Default value is `true`.

**sendFailure** `boolean`

Whether to send notifications when checks [fail](https://www.checklyhq.com/docs/communicate/alerts/overview.md#alert-channels). Default value is `true`.

**sendDegraded** `boolean`

Whether to send notifications when checks [become degraded](https://www.checklyhq.com/docs/communicate/alerts/overview.md#alert-channels). Default value is `false`.

**sslExpiry** `boolean`

Whether to send notifications when a SSL/TLS certificate is about to expire. Default value is `false`.

```ts highlight={3} theme={null}
new EmailAlertChannel("email-channel-1", {
  address: "alerts@acme.com",
  sslExpiry: true,
  sslExpiryThreshold: 30, // Alert 30 days before expiry
})
```

[Learn more about SSL alerts.](https://www.checklyhq.com/docs/communicate/alerts/ssl-expiration.md)

**sslExpiryThreshold** `number`

Number of days before the SSL/TLS certificate expiry date to send notifications. Only relevant when `sslExpiry` is enabled. Default value is `30`.

```ts highlight={4} theme={null}
new EmailAlertChannel("email-channel-1", {
  address: "alerts@acme.com",
  sslExpiry: true,
  sslExpiryThreshold: 30, // Alert 30 days before expiry
})
```

[Learn more about SSL alerts.](https://www.checklyhq.com/docs/communicate/alerts/ssl-expiration.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.