Channel API
Complete API reference for listing connected messaging channels, checking their status and capabilities, and reconnecting disconnected channels.
Channel API
Manage the messaging channels connected to your CodeSpar instance. CodeSpar supports five channels: WhatsApp, Slack, Discord, Telegram, and Web (API). Each channel can be independently enabled, monitored, and reconnected.
Endpoints Overview
| Method | Path | Description |
|---|---|---|
GET | /api/channels | List all channels with status and capabilities |
POST | /api/channels/:name/reconnect | Force-reconnect a channel |
List Channels
Retrieve all configured channels, their current connection status, and their capabilities.
Request
Response
Response Schema
Each channel object contains the following fields:
| Field | Type | Description |
|---|---|---|
name | string | Channel identifier: whatsapp, slack, discord, telegram, web |
platform | string | Platform type. Same as name for built-in channels. |
connected | boolean | Whether the channel is currently connected and processing messages |
capabilities | object | Channel-specific capabilities (see below) |
Capabilities Object
The capabilities object describes what each channel supports. CodeSpar uses this information to format messages appropriately for each channel.
| Field | Type | Description |
|---|---|---|
threads | boolean | Whether the channel supports threaded replies. Slack and Discord support threads; WhatsApp and Telegram do not. |
codeBlocks | boolean | Whether the channel renders code blocks with monospace formatting. |
syntaxHighlighting | boolean | Whether code blocks support language-specific syntax highlighting. |
fileAttachments | boolean | Whether the channel can send and receive file attachments. |
reactions | boolean | Whether the channel supports emoji reactions on messages. |
maxMessageLength | number | Maximum characters per message. Messages exceeding this limit are automatically split. |
mentionFormat | string | How the channel handles @mentions: "text" (raw text), "user_id" (platform user ID), "username" (platform username), "none" (no mentions). |
How Capabilities Affect Behavior
CodeSpar adapts its output based on channel capabilities:
| Capability | When true | When false |
|---|---|---|
threads | Responses are posted as thread replies | Responses are posted as flat messages |
codeBlocks | Code is wrapped in triple-backtick blocks | Code is sent as plain text |
syntaxHighlighting | Language identifier is added to code blocks (e.g., ```typescript) | Code blocks use no language identifier |
maxMessageLength | Messages within limit are sent as-is | Messages exceeding limit are split into multiple messages |
Channel Connection States
The connected field is a boolean. For more detailed status information, the full internal states are:
| State | connected Value | Description |
|---|---|---|
| Connected | true | Channel is online and processing messages |
| Disconnected | false | Channel lost connection or encountered an error |
| Disabled | false | Channel is not enabled in configuration |
| Connecting | false | Channel is attempting to establish connection (transitional) |
Reconnect a Channel
Force a channel to disconnect and reconnect. Useful when a channel is stuck in a disconnected or error state.
Path Parameters
| Parameter | Type | Description |
|---|---|---|
name | string | Channel name: whatsapp, slack, discord, telegram |
Request
Response
The connected field reflects the state after the reconnection attempt. If the reconnection fails (e.g., invalid token, service unavailable), connected will be false.
Verify Reconnection
After a reconnection attempt, verify the channel status:
Error Responses
Channel not found (404):
Channel not enabled (400):
Channel Configuration Reference
Each channel requires specific environment variables. See Configuration for full details.
| Channel | Enable Variable | Required Variables |
|---|---|---|
ENABLE_WHATSAPP=true | EVOLUTION_API_URL, EVOLUTION_API_KEY, EVOLUTION_INSTANCE | |
| Slack | ENABLE_SLACK=true | SLACK_BOT_TOKEN, SLACK_APP_TOKEN |
| Discord | ENABLE_DISCORD=true | DISCORD_BOT_TOKEN |
| Telegram | ENABLE_TELEGRAM=true | TELEGRAM_BOT_TOKEN |
| Web | Always enabled | None (built-in REST API) |
Usage Examples
Check If All Channels Are Connected
Reconnect All Disconnected Channels
Check a Channel's Message Length Limit
Configure a Channel
Programmatically configure a channel's connection settings. This is an alternative to setting environment variables manually.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
channel | string | Yes | Channel name: telegram, whatsapp, discord, slack |
config | object | Yes | Channel-specific configuration (see below) |
Channel Config Objects
Telegram:
WhatsApp:
Discord:
Slack:
Request Example
Response
Validation
The endpoint validates:
- The
channelfield must be one of:telegram,whatsapp,discord,slack - The
configobject must contain all required fields for the specified channel - Empty or missing config values are rejected with a 400 error
Invalid channel names return:
All configuration changes are logged to the Audit Trail for traceability.
Next Steps
- Configuration -- Channel environment variables
- Multi-Channel Setup -- Enable multiple channels simultaneously
- Agent API -- Manage agents that use channels