> ## Documentation Index
> Fetch the complete documentation index at: https://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](/integrations/alerts/webhooks) and [alerting with Checkly](/communicate/alerts/overview/).
</Tip>

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](/integrations/alerts/webhooks#using-variables).

<CodeGroup>
  ```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,
  })
  ```
</CodeGroup>

<Note>
  If you need to reference existing alert channels that were created outside of your CLI project, use [`fromId()`](/constructs/alert-channel#using-fromid-to-reference-an-existing-channel).
</Note>

## Configuration

### Webhook Alert Channel Options

<ResponseField name="url" type="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'),
  })
  ```
</ResponseField>

<ResponseField name="method" type="string" required>
  The HTTP method, either `GET`, `POST`, `PUT`, `PATCH`, `HEAD` or `DELETE`.
</ResponseField>

<ResponseField name="name" type="string">
  Friendly name for the webhook channel.
</ResponseField>

<ResponseField name="template" type="string">
  The request body template, usually JSON. You can use [Handlebars-style template variables](/integrations/alerts/webhooks#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}}"
    }`
  })
  ```
</ResponseField>

<ResponseField name="headers" type="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' }],
  })
  ```
</ResponseField>

<ResponseField name="queryParameters" type="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' }],
  })
  ```
</ResponseField>

<ResponseField name="webhookSecret" type="string">
  Secret token that you can use to validate the authenticity of the webhook and its payload. [Learn more about webhook secrets.](/integrations/alerts/webhooks#webhook-secrets)
</ResponseField>

### General Alert Channel Options

These options are valid for all alert channels types.

<ResponseField name="sendRecovery" type="boolean">
  Whether to send notifications when checks recover from a [failed or degraded state](/communicate/alerts/overview/#alert-channels). Default value is `true`.
</ResponseField>

<ResponseField name="sendFailure" type="boolean">
  Whether to send notifications when checks [fail](/communicate/alerts/overview/#alert-channels). Default value is `true`.
</ResponseField>

<ResponseField name="sendDegraded" type="boolean">
  Whether to send notifications when checks [become degraded](/communicate/alerts/overview/#alert-channels). Default value is `false`.
</ResponseField>

<ResponseField name="sslExpiry" type="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.](/communicate/alerts/ssl-expiration/)
</ResponseField>

<ResponseField name="sslExpiryThreshold" type="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.](/communicate/alerts/ssl-expiration/)
</ResponseField>
