Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

4.7 KB
Raw Blame
---
title: "Certificate alerts in Slack"
sidebarTitle: "Slack"
description: "Send certificate alert notifications to a Slack channel."
---

import AlertApiFields from "/snippets/documentation/platform/pki/applications/alerting/alert-api-fields.mdx";
import StartAlert from "/snippets/documentation/platform/pki/applications/alerting/start-alert.mdx";

A Slack channel on a certificate [alert](/documentation/platform/pki/applications/alerting/overview) posts to a Slack channel through an [Incoming Webhook](https://api.slack.com/messaging/webhooks) whenever the alert fires.

<Info>
  Slack channels are available under Infisical's [Enterprise](https://infisical.com/pricing) plan. If you're self-hosting Infisical, contact [email protected] to purchase an enterprise license.
</Info>

## Prerequisites

- The Certificate Management **Admin** role to create an organization-wide alert, or the **Admin** [application role](/documentation/platform/pki/applications/overview#application-roles) to create an application alert
- A Slack workspace where you can create apps

## Step 1: Create a Slack incoming webhook

<Steps>
  <Step>
    Go to the [Slack API Apps page](https://api.slack.com/apps), select **Create New App**, then select **From scratch**.
  </Step>
  <Step>
    Name the app, for example `Infisical PKI Alerts`, pick your workspace, and select **Create App**.
  </Step>
  <Step>
    In the app settings, go to **Incoming Webhooks** and turn on **Activate Incoming Webhooks**.
  </Step>
  <Step>
    Select **Add New Webhook to Workspace**, pick the Slack channel for alerts, and select **Allow**.
  </Step>
  <Step>
    Copy the **Webhook URL**.

    <Note>
      Anyone with the webhook URL can post to your Slack channel, so store it like a secret.
    </Note>
  </Step>
</Steps>

## Step 2: Create the alert

<Tabs>
  <Tab title="Infisical UI">
    <StartAlert />

    On the **Channels** step, add the Slack channel:

    <Steps>
      <Step>
        Select **Add Channel** > **Slack** and paste the URL from [step 1](#step-1-create-a-slack-incoming-webhook) into **Webhook URL**. The URL must start with `https://hooks.slack.com`.
      </Step>
      <Step>
        Optionally, select **Send test** to send a test message to the Slack channel.
      </Step>
      <Step>
        Select **Continue**, check the **Review** step, and select **Create Alert**.
      </Step>
    </Steps>
  </Tab>
  <Tab title="API">
    Send a request to the create alert endpoint with an [access token](/api-reference/overview/authentication) and a `slack` channel, and set `webhookUrl` in the channel's `config` to the URL from [step 1](#step-1-create-a-slack-incoming-webhook).

    <AlertApiFields />

    <CodeGroup>
    ```bash Organization-wide
    curl --request POST \
      --url https://app.infisical.com/api/v1/alerts \
      --header 'Authorization: Bearer <access-token>' \
      --header 'Content-Type: application/json' \
      --data '{
        "name": "certificate-revocations",
        "resourceType": "cert-manager",
        "eventType": "cert-manager.certificate.revocation",
        "channels": [
          {
            "name": "pki-alerts",
            "channelType": "slack",
            "config": { "webhookUrl": "<slack-webhook-url>" }
          }
        ]
      }'
    ```

    ```bash Application
    curl --request POST \
      --url https://app.infisical.com/api/v1/alerts \
      --header 'Authorization: Bearer <access-token>' \
      --header 'Content-Type: application/json' \
      --data '{
        "name": "payments-api-expiring",
        "resourceType": "cert-manager.application",
        "resourceId": "<application-id>",
        "eventType": "cert-manager.application.certificate.expiry",
        "condition": { "alertBefore": "30d" },
        "channels": [
          {
            "name": "payments-alerts",
            "channelType": "slack",
            "config": { "webhookUrl": "<slack-webhook-url>" }
          }
        ]
      }'
    ```
    </CodeGroup>
  </Tab>
</Tabs>

<Check>
  Your alert is set up. Infisical posts to the Slack channel whenever the alert fires.
</Check>

## Message format

Each Slack message includes the alert's summary, up to two certificates, and a **View in Infisical** button. For an application alert, the button opens the application. For an organization-wide alert, it opens the **Inventory** page, or the **Signers** page for a signer certificate expiration alert. The message color shows the alert's severity:

| Color | Severity | When |
|-------|----------|------|
| Red | Critical or error | A certificate expires within 14 days |
| Amber | Warning | A certificate expires within 15 to 30 days, or a certificate was revoked |
| Blue | Info | A certificate expires in more than 30 days, or a certificate was issued or renewed |