# Create a channel

Create a Telegram channel using a new bot token or a saved secret.

## Endpoint

`POST /api/v1/workspaces/{workspace_id}/channels`

## Authentication

| Class | Authentication | Minimum role | API key |
| --- | --- | --- | --- |
| dashboard-session-api | Dashboard session cookie; mutations also require X-CX-Request: 1. | admin | Not allowed |

## Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `workspace_id` | path | `string` | Yes | — |

## Request body

### application/json request schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | PermintaanKanal | — | No | Yes | — | — |
| `agent_id` | `string` | — | — | No | Yes | — | — |
| `bot_token` | `string or null` | — | — | Yes | No | — | — |
| `secret_name` | `string or null` | — | — | Yes | No | — | — |
| `type` | `string` | — | — | No | Yes | — | — |

## Example

```bash
curl --request POST 'https://operade.ai/api/v1/workspaces/ws_demo/channels' \
  --cookie 'cx_session=YOUR_SESSION_COOKIE' \
  --header 'X-CX-Request: 1' \
  --header 'Content-Type: application/json' \
  --data '{"agent_id":"agt_demo","type":"telegram","bot_token":"EXAMPLE_TELEGRAM_BOT_TOKEN"}'
```

## Responses

| Status | Description | Content |
| --- | --- | --- |
| 4XX | Handled client error | application/json: `ErrorResponse` |
| 201 | Successful Response | application/json: `ChannelCreateResponse` |

### 4XX application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ErrorResponse | — | No | Yes | — | — |
| `error` | `object` | ErrorItem | — | No | Yes | — | — |
| `error.code` | `string` | — | — | No | Yes | — | — |
| `error.details` | `object` | — | — | No | No | — | — |
| `error.message` | `string` | — | — | No | Yes | — | — |

### 201 application/json response schema

| Field path | Type | Reference | Format | Nullable | Required | Enum | Description |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `$` | `object` | ChannelCreateResponse | — | No | Yes | — | — |
| `agent_id` | `string` | — | — | No | Yes | — | — |
| `created_at` | `string` | — | date-time | No | Yes | — | — |
| `enabled` | `boolean` | — | — | No | Yes | — | — |
| `external_id` | `string or null` | — | — | Yes | Yes | — | — |
| `id` | `string` | — | — | No | Yes | — | — |
| `secret_name` | `string or null` | — | — | Yes | Yes | — | — |
| `type` | `string` | — | — | No | Yes | "telegram" | — |
| `webhook_secret` | `string` | — | — | No | Yes | — | — |
| `workspace_id` | `string` | — | — | No | Yes | — | — |

### Response example

```json
{
  "id": "string",
  "workspace_id": "string",
  "agent_id": "string",
  "type": "telegram",
  "external_id": "string",
  "secret_name": "string",
  "enabled": false,
  "created_at": "2026-01-01T00:00:00Z",
  "webhook_secret": "string"
}
```

## Errors

Reviewed common and route-declared errors are summarized here; the list is not exhaustive. Start with the [distributed error index](/docs/reference/api/errors) to find each code's canonical domain page.

| Status | Code | Description |
| --- | --- | --- |
| 401 | `unauthenticated` | Authentication is missing, invalid, or revoked. |
| 403 | `forbidden` | The authenticated caller does not have access to this operation. |
| 404 | `not_found` | The requested workspace resource was not found. |
| 422 | `validation_failed` | The request did not pass field or business validation. |

## Related operations

- [Delete a channel](/docs/api-reference/channels/delete-channel) — `DELETE /api/v1/workspaces/{workspace_id}/channels/{channel_id}`
- [List channels](/docs/api-reference/channels/list-channels) — `GET /api/v1/workspaces/{workspace_id}/channels`
- [Update a channel](/docs/api-reference/channels/update-channel) — `PATCH /api/v1/workspaces/{workspace_id}/channels/{channel_id}`
