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

# Connect Slack to Scrubbe for Incident Alerts

> Authorize Scrubbe to post incident notifications to a Slack channel and configure which events — new incidents and resolutions — trigger Slack messages.

The Slack integration lets Scrubbe post real-time incident notifications to any channel in your workspace. Once connected, Scrubbe sends a message when an incident is created and another when it is resolved — based on the notification settings in your IMS configuration. You need the `ENGINEER` role or higher to complete this setup.

## Connect your Slack workspace

<Steps>
  <Step title="Initiate the OAuth flow">
    Send an authenticated `POST` request to the Slack connect endpoint. Scrubbe responds with an OAuth authorization URL.

    ```http theme={null}
    POST /api/v1/integrations/slack/connect
    Authorization: Bearer <your-access-token>
    ```

    **Response:**

    ```json theme={null}
    {
      "success": true,
      "message": "Slack OAuth URL generated",
      "data": {
        "url": "https://slack.com/oauth/v2/authorize?client_id=..."
      }
    }
    ```
  </Step>

  <Step title="Authorize in Slack">
    Open the `url` returned in the previous step in your browser. Slack will ask you to choose a workspace and grant Scrubbe permission to post messages. After you click **Allow**, Slack redirects your browser to the Scrubbe callback URL automatically.
  </Step>

  <Step title="Scrubbe completes the connection">
    Scrubbe handles the callback at:

    ```
    GET /api/v1/integrations/slack/oauth/callback
    ```

    You do not need to call this endpoint yourself — Slack redirects to it as part of the OAuth handshake. Once the callback completes, your Slack workspace is connected and the integration is stored against your account.
  </Step>

  <Step title="Configure notification settings">
    Update your IMS configuration to control which events trigger Slack messages and which channel Scrubbe posts to.

    ```http theme={null}
    PUT /api/v1/ims/config
    Authorization: Bearer <your-access-token>
    Content-Type: application/json

    {
      "slackChannel": "#incidents",
      "notifyOnCreate": true,
      "notifyOnResolve": true
    }
    ```

    | Field             | Type    | Description                                                        |
    | ----------------- | ------- | ------------------------------------------------------------------ |
    | `slackChannel`    | string  | The Slack channel name (with `#`) or channel ID to post alerts to. |
    | `notifyOnCreate`  | boolean | Send a Slack message when a new incident is created.               |
    | `notifyOnResolve` | boolean | Send a Slack message when an incident is resolved.                 |
  </Step>
</Steps>

## Verify the connection

After completing the OAuth flow, retrieve your integrations to confirm Slack appears as connected:

```http theme={null}
GET /api/v1/integrations/{userId}
Authorization: Bearer <your-access-token>
```

Look for an entry with `"provider": "SLACK"` and `"connected": true` in the response.

## Receive Slack events

If you want Scrubbe to receive events from Slack (such as slash commands or interactive messages), configure your Slack app to send event payloads to the Scrubbe webhook endpoint:

```
POST /api/v1/integrations/slack/webhook
```

This endpoint accepts raw JSON from Slack and does not require an `Authorization` header — Slack sends its own verification token in the payload instead. Scrubbe validates the token automatically.

<Note>
  You can also initiate the OAuth flow with `GET /api/v1/integrations/slack/connect` if you prefer to open the authorization URL directly from a browser rather than from an API call.
</Note>

<Warning>
  The `slackChannel` value must match a channel that the Scrubbe Slack app has been invited to. If Scrubbe does not have access to the channel, notifications will silently fail. Run `/invite @Scrubbe` inside the channel after completing the OAuth flow.
</Warning>
