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 .
Basic Example
Advanced Example
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}}" ,
}),
})
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 ,
})
If you need to reference existing alert channels that were created outside of your CLI project, use fromId() .
Configuration
Webhook Alert Channel Options
Target URL for the webhook request. new WebhookAlertChannel ( 'webhook-channel-1' , {
name: 'Pushover webhook' ,
method: 'POST' ,
url: new URL ( 'https://api.pushover.net/1/messages.json' ),
})
The HTTP method, either GET, POST, PUT, PATCH, HEAD or DELETE.
Friendly name for the webhook channel.
The request body template, usually JSON. You can use Handlebars-style template variables to further customize the template. 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}}"
}`
})
An array of { key, value } objects to define HTTP headers. 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' }],
})
An array of { key, value } objects to define query parameters. 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' }],
})
General Alert Channel Options
These options are valid for all alert channels types.
Whether to send notifications when checks fail . Default value is true.
Whether to send notifications when checks become degraded . Default value is false.
Whether to send notifications when a SSL/TLS certificate is about to expire. Default value is false. new EmailAlertChannel ( "email-channel-1" , {
address: "alerts@acme.com" ,
sslExpiry: true ,
sslExpiryThreshold: 30 , // Alert 30 days before expiry
})
Learn more about SSL alerts.
Number of days before the SSL/TLS certificate expiry date to send notifications. Only relevant when sslExpiry is enabled. Default value is 30. new EmailAlertChannel ( "email-channel-1" , {
address: "alerts@acme.com" ,
sslExpiry: true ,
sslExpiryThreshold: 30 , // Alert 30 days before expiry
})
Learn more about SSL alerts.