Base URL: TBD (will share once deployed)
- MVP: API key in header
X-ClaWatch-Key - Telegram bot token stored server-side
List all monitored agents.
{
"agents": [
{
"id": "agent_abc123",
"name": "my-assistant",
"host": "macbook-pro",
"status": "running" | "paused" | "stopped" | "error" | "stuck",
"lastHeartbeat": "2026-03-09T14:00:00Z",
"createdAt": "2026-03-09T12:00:00Z",
"costUsd": 1.23,
"tokenCount": 45000,
"errorCount": 2
}
]
}Single agent detail.
{
"id": "agent_abc123",
"name": "my-assistant",
"host": "macbook-pro",
"status": "running",
"lastHeartbeat": "2026-03-09T14:00:00Z",
"createdAt": "2026-03-09T12:00:00Z",
"costUsd": 1.23,
"tokenCount": 45000,
"errorCount": 2,
"recentEvents": [
{
"type": "tool_call" | "error" | "heartbeat" | "cost" | "status_change",
"timestamp": "2026-03-09T14:00:00Z",
"data": {}
}
]
}Pause an agent. Returns updated agent.
Resume a paused agent. Returns updated agent.
Agents POST events here. This is the collection endpoint.
{
"agentId": "agent_abc123",
"agentName": "my-assistant",
"host": "macbook-pro",
"type": "heartbeat" | "tool_call" | "error" | "cost" | "status_change",
"timestamp": "2026-03-09T14:00:00Z",
"data": {
"message": "optional description",
"tokenCount": 1500,
"costUsd": 0.03,
"model": "claude-sonnet-4-20250514",
"toolName": "exec",
"error": "optional error message"
}
}Cost breakdown.
{
"totalUsd": 12.50,
"byAgent": [
{ "agentId": "agent_abc123", "name": "my-assistant", "costUsd": 8.00, "tokenCount": 250000 }
],
"byModel": [
{ "model": "claude-sonnet-4-20250514", "costUsd": 8.00, "tokenCount": 250000 }
]
}Recent alerts (shown in dashboard).
{
"alerts": [
{
"id": "alert_1",
"agentId": "agent_abc123",
"type": "stuck" | "error" | "cost_spike" | "loop_detected",
"severity": "critical" | "warning" | "info",
"message": "Agent stuck — no heartbeat for 5 minutes",
"timestamp": "2026-03-09T14:00:00Z",
"acknowledged": false
}
]
}Mark alert as acknowledged.
- MVP: Frontend polls GET /api/agents every 5 seconds
- V2: WebSocket at /ws for real-time updates
Triggered server-side when:
- Agent stuck (no heartbeat > 5 min)
- Error rate spike (>3 errors in 1 min)
- Cost threshold exceeded
- Agent status change (running → error)
Format: actionable message with inline buttons linking to dashboard.