Learn more about Slack alerts in the Slack Alerts documentation.
Use Slack Alert Channels to send notifications to Slack channels when checks fail or recover. The examples below show how to configure Slack alerting for different scenarios.
import { SlackAlertChannel } from "checkly/constructs"

const slackChannel = new SlackAlertChannel("slack-channel-1", {
  url: new URL(
    "https://hooks.slack.com/services/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"
  ),
  channel: "#ops",
})

Configuration

Configure Slack-specific settings:
ParameterTypeRequiredDefaultDescription
urlURL-Slack webhook URL for incoming messages
channelstring-Target Slack channel (e.g., ‘#ops’, ‘@user’)

Slack Alert Channel Options

url
URL
required
Slack webhook URL for incoming messages. This is the endpoint where Checkly will send alert notifications.Usage:
new SlackAlertChannel("slack-channel", {
  url: new URL(
    "https://hooks.slack.com/services/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"
  ),
  channel: "#alerts",
})
Examples:
const slackChannel = new SlackAlertChannel("direct-slack", {
  url: new URL(
    "https://hooks.slack.com/services/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"
  ),
  channel: "#monitoring",
})
Use cases: Team notifications, webhook integration, secure credential storage, multi-team alerting.
channel
string
Target Slack channel or user for notifications. Can override the default channel configured in the webhook.Usage:
new SlackAlertChannel("channel-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#ops", // Send to #ops channel
})
Examples:
const channelSlack = new SlackAlertChannel("channel-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#monitoring-alerts", // Public channel
})
Use cases: Team-specific alerts, direct notifications, alert categorization, noise management.

General Alert Channel Options

sendRecovery
boolean
Whether to send notifications when checks recover from failure or degraded state.Usage:
new SlackAlertChannel("recovery-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#alerts",
  sendRecovery: true, // Send recovery notifications
})
Examples:
const opsSlack = new SlackAlertChannel("ops-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#ops",
  sendRecovery: true, // Get notified when issues are resolved
  sendFailure: true,
})
Use cases: Recovery confirmation, operational awareness, noise reduction.
sendFailure
boolean
Whether to send notifications when checks fail.Usage:
const slackAlert = new SlackAlertChannel("failure-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#alerts",
  sendFailure: true, // Send failure notifications
})
Examples:
const criticalSlack = new SlackAlertChannel("critical-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#critical-alerts",
  sendFailure: true, // Critical failures
  sendRecovery: true,
  sendDegraded: false, // No degraded alerts
})
Use cases: Incident response, failure monitoring, operational alerting.
sendDegraded
boolean
Whether to send notifications when API checks degrade (performance thresholds exceeded but not failed).Usage:
new SlackAlertChannel("performance-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#performance",
  sendDegraded: true, // Send degraded performance notifications
})
Examples:
const performanceSlack = new SlackAlertChannel("performance-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#performance",
  sendRecovery: true,
  sendFailure: true,
  sendDegraded: true, // Alert on degraded performance
})

new ApiCheck("performance-check", {
  name: "API Performance Check",
  maxResponseTime: 3000,
  degradedResponseTime: 1500, // Triggers degrade alerts
  alertChannels: [performanceSlack],
  request: {
    method: "GET",
    url: "https://api.example.com/slow-endpoint",
  },
})
Use cases: Performance monitoring, early warning systems, SLA tracking.
sslExpiry
boolean
Whether to send notifications for SSL certificate expiry warnings.Usage:
new SlackAlertChannel("security-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#security",
  sslExpiry: true,
  sslExpiryThreshold: 30, // Alert 30 days before expiry
})
Examples:
const securitySlack = new SlackAlertChannel("security-slack", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#security",
  sendRecovery: false,
  sendFailure: true,
  sslExpiry: true,
  sslExpiryThreshold: 7, // Alert 7 days before expiry
})

new ApiCheck("ssl-cert-check", {
  name: "SSL Certificate Check",
  alertChannels: [securitySlack],
  request: {
    method: "GET",
    url: "https://secure.example.com",
  },
})
Use cases: Certificate management, security compliance, proactive maintenance.
sslExpiryThreshold
number
Number of days before SSL certificate expiry to send notifications. Only relevant when sslExpiry is enabled.Usage:
new SlackAlertChannel('ssl-monitoring', {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: '#devops',
  sslExpiry: true,
  sslExpiryThreshold: 30 // Alert 30 days before expiry
})
Examples:
// Alert close to expiry for urgent action
new SlackAlertChannel("ssl-urgent", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#security",
  sslExpiry: true,
  sslExpiryThreshold: 7, // 7 days notice
})
Use cases: Certificate renewal planning, compliance management, operational scheduling.

Examples

    import { SlackAlertChannel, ApiCheck } from "checkly/constructs"

    const teamSlack = new SlackAlertChannel("team-slack", {
      url: new URL("https://hooks.slack.com/services/YOUR/WEBHOOK/URL"),
      channel: "#dev-team",
    })

    new ApiCheck("api-health-check", {
      name: "API Health Check",
      alertChannels: [teamSlack],
      request: {
        method: "GET",
        url: "https://api.acme.com/health",
      },
    })

Setting Up Slack Webhooks

Find more information on how to set up a new Slack webhook in the Slack alert channel documentation.

Environment Variables

Store your Slack webhook URL securely using environment variables:
const slackChannel = new SlackAlertChannel("slack-channel", {
  url: new URL(process.env.SLACK_WEBHOOK_URL!),
  channel: "#monitoring",
})
# .env
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/YOUR/WEBHOOK/URL
Webhook Security: Keep your Slack webhook URLs secure. Anyone with access to the URL can send messages to your Slack channels.
Channel Override: The channel parameter can override the default channel configured in your Slack webhook. Use #channel-name for channels or @username for direct messages.