# Connect an agent to a Slack workspace

```http
POST /projects/{project_reference}/channels
```

Connect a Slack agent. Requires project.channels.write.

## Parameters

| Name                | In   | Required | Description                                                |
| ------------------- | ---- | -------- | ---------------------------------------------------------- |
| `project_reference` | path | Yes      | Project slug, UUID, or domain that identifies the project. |

## Request body

| Field                       | Type         | Required | Description                                                                                                                                                                                                                                                               |
| --------------------------- | ------------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `platform`                  | string       | Yes      | Messaging platform: slack                                                                                                                                                                                                                                                 |
| `agent_id`                  | string       | Yes      | Agent ID from listChannelAgents (MCP: list\_channel\_agents) for the same runtime target                                                                                                                                                                                  |
| `name`                      | string       |          | Display name, 1-255 characters                                                                                                                                                                                                                                            |
| `respond_to`                | string       |          | Which Slack messages to answer: mentions, direct\_messages or all                                                                                                                                                                                                         |
| `allowed_slack_channel_ids` | array        |          | Slack channel IDs. Overlap with another channel in the same workspace is rejected with resource-already-exists. IDs come from listSlackChannels (MCP: list\_slack\_channels); empty means every Slack channel the bot is in. A preview\_branch target needs at least one. |
| `welcome_message`           | string,null  |          | Welcome message; null clears                                                                                                                                                                                                                                              |
| `error_message`             | string,null  |          | Message shown when the agent fails; null clears                                                                                                                                                                                                                           |
| `max_response_tokens`       | integer,null |          | Maximum response tokens, 1-65536; null clears                                                                                                                                                                                                                             |
| `runtime_target_kind`       | string       |          | Runtime target: main\_branch, environment or preview\_branch                                                                                                                                                                                                              |
| `target_environment_id`     | string,null  |          | Environment ID; required when runtime\_target\_kind is environment                                                                                                                                                                                                        |
| `target_branch_id`          | string,null  |          | Branch ID; required when runtime\_target\_kind is preview\_branch                                                                                                                                                                                                         |

## Responses

| Status | Description     |
| ------ | --------------- |
| 201    | Created channel |
| 400    | Bad request     |
| 401    | Unauthorized    |
| 403    | Forbidden       |
| 404    | Not found       |
| 409    | Conflict        |
| 500    | Server error    |
| 502    | Bad gateway     |
