> Documentation index: https://docs.zernio.com/llms.txt. Every page is also Markdown: add .md to its URL.

# Connect

Connect a Slack account with the Zernio API, every step with code.

Slack installs the bot into a workspace, not a channel, so the flow ends with a channel choice:

1. Send the user to `authUrl`; they authorize the workspace on Slack's consent screen.
2. Zernio lists the workspace's channels and the user picks one.
3. `POST /v1/connect/slack` saves the channel as an account.

## Start OAuth

Call `GET /v1/connect/slack` with `profileId` on [List Slack channels](/connect/list-slack-channels).

With no `pendingDataToken` or `accountId`, it returns the `authUrl` and `state` that start OAuth, like `GET /v1/connect/{platform}` does for other platforms.

## List channels in headless mode

In headless mode (`headless=true`), the post-OAuth redirect carries a `pendingDataToken` and `connect_token`. List the channels yourself:

```bash
curl "https://zernio.com/api/v1/connect/slack?profileId=66a1f0c2a4b9d3e8f1a2b3c4&pendingDataToken=$PENDING_DATA_TOKEN" \
  -H "Authorization: Bearer $ZERNIO_API_KEY"
```

Response (`200`):

```json
{
  "team": { "id": "T0123456789", "name": "Example Co", "icon": "https://..." },
  "channels": [
    { "id": "C0123456789", "name": "marketing", "isPrivate": false, "isMember": true },
    { "id": "G0123456789", "name": "launch-room", "isPrivate": true, "isMember": false }
  ]
}
```

Channels are read live from Slack, public and private, archived excluded, up to 2,000. `isMember` says whether the bot is already in the channel.

## Save the channel

Finalize with [Connect Slack channel](/connect/connect-slack-channel):

```bash
curl -X POST https://zernio.com/api/v1/connect/slack \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "profileId": "66a1f0c2a4b9d3e8f1a2b3c4",
    "channelId": "C0123456789",
    "pendingDataToken": "'"$PENDING_DATA_TOKEN"'"
  }'
```

Response (`200`):

```json
{
  "message": "Slack channel connected successfully",
  "account": {
    "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
    "platform": "slack",
    "username": "marketing",
    "displayName": "marketing",
    "isActive": true,
    "channelId": "C0123456789",
    "teamId": "T0123456789",
    "teamName": "Example Co"
  }
}
```

`account.accountId` is the id every sample below uses. The channel is now an account in that profile, so it also shows up in:

```
GET /v1/accounts?profileId=66a1f0c2a4b9d3e8f1a2b3c4
```

## Connect another channel

Another channel from the same workspace needs no second OAuth:

1. Call `GET /v1/connect/slack` with `profileId` and `accountId` of an existing Slack account to list the channels.
2. `POST` with `accountId` instead of `pendingDataToken`.

The [connecting accounts guide](/guides/connecting-accounts) covers the flow and [scopes](/guides/connecting-accounts#scopes) in general.

## OAuth scopes

<Callout type="warn">
Workspaces connected before the inbox shipped must reconnect once. Existing bot tokens keep the scopes they were granted, so inbound messages fail with `missing_scope` until the workspace re-authorizes from the dashboard.
</Callout>