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

# Slack Notifications with Zexa: Workspace Setup Guide

> Integrate Zexa with Slack to send notifications and alerts to your team's Slack workspace channels using the REST API or dashboard.

Use Zexa's Slack integration to send automated notifications directly into your Slack workspace — ideal for operational alerts, customer event notifications, and internal status updates. Once connected, you can route any Zexa message to a Slack channel or direct message using the same unified API you use for every other channel.

## Setup

Connect your Slack workspace to Zexa in four steps:

<Steps>
  <Step title="Open Slack settings in Zexa">
    Log in to the [Zexa dashboard](https://app.zexa.ao) and navigate to **Channels > Slack**.
  </Step>

  <Step title="Connect your workspace">
    Click **Connect Slack**. You'll be redirected to Slack's OAuth authorisation page. Review the permissions requested and click **Allow** to authorise the Zexa app in your workspace.
  </Step>

  <Step title="Select a default channel">
    After authorisation, select the Slack channel where notifications should be sent by default. You can override this on a per-message basis using the `to` field in the API.
  </Step>

  <Step title="Copy your Slack channel ID">
    Once the connection is confirmed, Zexa will display the channel ID for your default channel. Copy and store this ID — you'll use it as the `to` value when sending messages via the API.
  </Step>
</Steps>

## Send a Slack message via API

Send a `POST` request to `/messages` with `"channel": "slack"` to post a message to your connected Slack workspace.

<CodeGroup>
  ```bash curl theme={null}
  curl --request POST \
    --url https://api.zexa.ao/v1/messages \
    --header 'Authorization: Bearer <api_key>' \
    --header 'Content-Type: application/json' \
    --data '{
      "channel": "slack",
      "to": "C0123456789",
      "from": "zexa-bot",
      "body": "Alert: Server response time exceeded 2s."
    }'
  ```

  ```python python theme={null}
  import requests

  url = "https://api.zexa.ao/v1/messages"

  payload = {
      "channel": "slack",
      "to": "C0123456789",
      "from": "zexa-bot",
      "body": "Alert: Server response time exceeded 2s."
  }

  headers = {
      "Authorization": "Bearer <api_key>",
      "Content-Type": "application/json"
  }

  response = requests.post(url, json=payload, headers=headers)
  print(response.json())
  ```
</CodeGroup>

A successful request returns a `201` response with the message object:

```json theme={null}
{
  "id": "msg_sl6670",
  "status": "queued",
  "channel": "slack",
  "to": "C0123456789",
  "created_at": "2026-06-24T10:20:00Z"
}
```

## Channel vs direct message

The `to` field accepts two types of Slack destination IDs:

| Destination     | ID prefix | Example       | Use case                            |
| --------------- | --------- | ------------- | ----------------------------------- |
| Public channel  | `C`       | `C0123456789` | Team-wide alerts and announcements  |
| Private channel | `C`       | `C9876543210` | Internal team notifications         |
| Direct message  | `U`       | `U0ABC123DEF` | Personal alerts for a specific user |

Use a channel ID (starting with `C`) to post to a channel, or a user ID (starting with `U`) to send a direct message to an individual workspace member.

<Tip>
  Find a channel's ID in Slack by right-clicking the channel name in the sidebar and selecting **Copy link**. The ID is the alphanumeric string at the end of the URL (e.g., `C0123456789`).
</Tip>

<Note>
  The Zexa Slack app must be invited to any private channel before it can post there. In Slack, open the private channel and run `/invite @Zexa` to grant access.
</Note>

## Next steps

<CardGroup cols={2}>
  <Card title="Webhooks" icon="webhook" href="/api/webhooks">
    Configure webhooks to trigger Zexa messages — including Slack notifications — from external events.
  </Card>

  <Card title="Campaigns" icon="bullhorn" href="/messaging/campaigns">
    Schedule and send bulk notifications across Slack and other channels simultaneously.
  </Card>
</CardGroup>
