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

# Certificate alerts in Slack

> Send certificate alert notifications to a Slack channel.

A Slack channel on a certificate [alert](https://infisical.com/docs/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.

> [!NOTE]
>
> Slack channels are available under Infisical's [Enterprise](https://infisical.com/pricing) plan. If you're self-hosting Infisical, contact [sales@infisical.com](mailto:sales@infisical.com) to purchase an enterprise license.

## Prerequisites

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

## Step 1: Create a Slack incoming webhook

**Step 1**

Go to the [Slack API Apps page](https://api.slack.com/apps), select **Create New App**, then select **From scratch**.

**Step 2**

Name the app, for example `Infisical PKI Alerts`, pick your workspace, and select **Create App**.

**Step 3**

In the app settings, go to **Incoming Webhooks** and turn on **Activate Incoming Webhooks**.

**Step 4**

Select **Add New Webhook to Workspace**, pick the Slack channel for alerts, and select **Allow**.

**Step 5**

Copy the **Webhook URL**.

> [!NOTE]
>
> Anyone with the webhook URL can post to your Slack channel, so store it like a secret.

## Step 2: Create the alert

> [tab] Infisical UI
>
> **Step 1**
>
> Open the alert form:
>
> * For an organization-wide alert, go to **Certificate Manager** > **Settings**, select the **Alerts** tab, then select **Create Alert**
> * For an application alert, go to **Certificate Manager** > **Applications** and select your application, then select the **Settings** tab and select **Create Alert** in the **Alerts** section
>
> **Step 2**
>
> Select the **Alert Type**, then enter an **Alert Name** and an optional **Description**. An application can have one alert for each event, so to notify more places about the same event, add more channels to that alert.
>
> **Step 3**
>
> For an expiration alert, enter **Alert Before** as a number and a unit. For example: `30d` or `2w`, up to 365 days.
>
> > [!NOTE]
> >
> > To get a reminder every day, turn on **Repeat daily until expiry**. Otherwise, the alert repeats on a [schedule based on **Alert Before**](https://infisical.com/docs/documentation/platform/pki/applications/alerting/overview#how-often-expiration-alerts-repeat).
>
> Select **Continue**.
>
> **Step 4**
>
> For an organization-wide alert, on the **Filters** step, optionally select **Add Filter** to [narrow the certificates the alert covers](https://infisical.com/docs/documentation/platform/pki/applications/alerting/overview#filter-an-organization-wide-alert), then select **Continue**. Application alerts and signer certificate expiration alerts skip this step.
>
> > [!TIP]
> >
> > To add this channel to an existing alert instead, edit the alert and go to its **Channels** step.
>
> On the **Channels** step, add the Slack channel:
>
> **Step 1**
>
> 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 2**
>
> Optionally, select **Send test** to send a test message to the Slack channel.
>
> **Step 3**
>
> Select **Continue**, check the **Review** step, and select **Create Alert**.

> [tab] API
>
> Send a request to the create alert endpoint with an [access token](https://infisical.com/docs/api-reference/overview/authentication.md) 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).
>
> Set `resourceType` and `resourceId` to the certificates the alert covers:
>
> | Alert | `resourceType` | `resourceId` |
> | - | - | - |
> | Organization-wide | `cert-manager` | Leave out |
> | Application | `cert-manager.application` | The application's ID, from [the list applications endpoint](https://infisical.com/docs/api-reference/endpoints/pki/applications/configuration/list.md) |
> | Signer certificate expiration | `cert-manager.signer` | Leave out |
>
> Set `eventType` to the event the alert watches:
>
> | Event | Organization-wide alert | Application alert |
> | - | - | - |
> | Expiration | `cert-manager.certificate.expiry` | `cert-manager.application.certificate.expiry` |
> | Issuance | `cert-manager.certificate.issuance` | `cert-manager.application.certificate.issuance` |
> | Renewal | `cert-manager.certificate.renewal` | `cert-manager.application.certificate.renewal` |
> | Revocation | `cert-manager.certificate.revocation` | `cert-manager.application.certificate.revocation` |
> | Signer certificate expiration | `cert-manager.signer.certificate.expiry` | Not available |
>
> Set `condition` to the same settings as the **Alert Before** field, the **Repeat daily until expiry** toggle, and the **Filters** step in Infisical:
>
> | Field | Applies to | Value |
> | - | - | - |
> | `alertBefore` | Expiration alerts (required) | A number and a unit, such as `30d` or `2w`, up to 365 days |
> | `dailyReminder` | Expiration alerts | `true` to [repeat the alert every day](https://infisical.com/docs/documentation/platform/pki/applications/alerting/overview#how-often-expiration-alerts-repeat) until the certificate expires |
> | `applicationIds` | Organization-wide alerts | Up to 100 application IDs |
> | `profileIds` | Organization-wide alerts | Up to 100 certificate profile IDs |
> | `sources` | Organization-wide alerts | Any of `issued` (**Managed** in Infisical), `imported`, and `discovered` |
> | `signerIds` | Signer certificate expiration alerts | Up to 100 signer IDs |
>
> For issuance, renewal, and revocation alerts on an application, leave out `condition`.
>
> ```bash Organization-wide theme={"dark"}
> 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 theme={"dark"}
> 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>" }
>       }
>     ]
>   }'
> ```

> [!TIP]
>
> Your alert is set up. Infisical posts to the Slack channel whenever the alert fires.

## 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 |


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