Channels API
Canonical reference: docs/api-reference.md (generated endpoint directory) — this page is a task-oriented summary.
Channel integrations connect ZERG to external messaging platforms: Slack, Microsoft Teams, Telegram, Discord, and generic webhooks.
Overview
Channels are gen_server-based integrations that receive messages from external platforms, relay them to a Luna agent for processing, and send responses back. Each channel type has a dedicated adapter that handles the platform-specific wire format and authentication.
Authentication
Channel management endpoints require Authorization: Bearer <token>. Webhook receivers use platform-specific signature verification.
Endpoints
List Channels
GET /api/v1/channels
Returns configured channels (paginated envelope). Each entry carries
id, type, name, status, enabled, last_message_ms, error_count
the channel config (secrets included) is never echoed back:
{
"items": [
{
"id": "ch-slack-001",
"type": "slack",
"name": "general",
"status": "active",
"enabled": true,
"last_message_ms": 1745600000000,
"error_count": 0
}
],
"total": 1,
"limit": 50,
"offset": 0,
"page": 1,
"total_pages": 1,
"has_more": false
}
Create Channel
POST /api/v1/channels/spawn
Admin only. Spawns a new channel integration. The type must match a loaded plugin.
{
"type": "slack",
"name": "support",
"config": {
"webhook_url": "https://hooks.slack.com/services/T00/B00/xxx",
"signing_secret": "abc123"
}
}
Request Body (Telegram):
{
"type": "telegram",
"name": "alerts",
"config": {
"bot_token": "123456:ABC-DEF",
"chat_ids": ["-1001234567890"]
}
}
Request Body (Teams):
{
"type": "teams",
"name": "dev-ops",
"config": {
"webhook_url": "https://outlook.office.com/webhook/...",
"tenant_id": "tenant-uuid"
}
}
Returns the new channel’s status map on success. 400 (Zerg envelope) if the plugin type is not loaded; 403 if not admin. Requires the channels:manage permission at the middleware.
Delete Channel
DELETE /api/v1/channels/:id
Admin only. Remove a channel integration. {status: "removed"}.
Webhook Receiver
POST /api/v1/webhook/:channel_id
Generic webhook receiver keyed by channel id. Accepts arbitrary JSON payloads:
{
"text": "What is the current deployment status?",
"user": "deploy-bot",
"metadata": { "source": "jenkins" }
}
The route is unauthenticated by design (auth-exempt): the platform
signature validation IS the auth, and it refuses missing/mismatched
credentials fail-closed. Success answers 200 with an empty body.
Webhook Signature Verification:
| Platform | Method | Credential |
|---|---|---|
| Slack | HMAC-SHA256 over v0:timestamp:body | X-Slack-Signature |
| Discord | Ed25519 | X-Signature-Ed25519 + X-Signature-Timestamp |
| Teams | Bearer token compare (teams_auth_token config; subscription validation echoes validationToken) | Authorization |
| Telegram | Secret-token compare (telegram_secret_token config) | X-Telegram-Bot-Api-Secret-Token |
An unconfigured secret refuses all traffic for that platform (fail-closed).
Error Codes (bodies are empty — the status is the contract):
| Code | Condition |
|---|---|
| 400 | Request body could not be read |
| 403 | Signature/credential verification failed |
| 404 | Channel not found (or disabled) |
| 413 | Payload over the 1 MB cap |
Examples:
curl http://127.0.0.1:21434/api/v1/channels \
-H "Authorization: Bearer $TOKEN"
curl -X POST http://127.0.0.1:21434/api/v1/channels/spawn \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"type": "slack", "name": "ops", "config": {"webhook_url": "https://hooks.slack.com/services/...", "signing_secret": "..."}}'