Protocol
The three calls bx-monitor makes, in full, for anyone writing a collector.
Rules
- JSON over HTTPS,
POSTonly, withAuthorization: Bearer <apiKey>. - The module calls the collector and nothing else. It never opens a listener or accepts an inbound request.
- Every payload carries
protocolVersion: 1. A collector rejects a major version it doesn't know with426and a JSON body naming the versions it supports.
| Call | When |
|---|---|
POST /api/v1/register | Startup, and whenever the collector answers a heartbeat with 409 |
POST /api/v1/heartbeat | Every interval |
POST /api/v1/deregister | Graceful shutdown |
register
json{
"protocolVersion": 1,
"agentId": "6f1c2c1e-6a4e-4f0e-9a5e-2d8c3b1f7a10",
"name": "feedhouse-prod",
"environment": "production",
"tags": [ "boxexpress", "docker" ],
"host": "app-01.local",
"runtime": {
"boxlangVersion": "1.19.0",
"javaVersion": "21.0.5",
"os": "Linux 6.8",
"runtimeType": "miniserver|commandbox|cli|servlet|lambda|unknown"
},
"modules": [ { "name": "bx-mysql", "version": "1.2.0" } ],
"startedAt": "2026-12-03T20:00:00Z",
"agentVersion": "0.1.0"
}
agentId stays the same across restarts; see How It Works. modules[].name is the name a module is installed under, not its mapping. The collector answers 200:
json{ "serverId": "…", "heartbeatIntervalSec": 30 }
The module uses the interval the collector returns, so the collector sets the pace.
heartbeat
json{
"protocolVersion": 1,
"agentId": "…",
"sentAt": "2026-12-03T20:00:30Z",
"uptimeSec": 30,
"status": "ok|degraded|down",
"jvm": { "heapUsedBytes": 0, "heapMaxBytes": 0, "nonHeapUsedBytes": 0, "threadCount": 0, "processCpuLoad": 0.12 },
"requests": {
"count": 0, "errorCount": 0, "p50Ms": 0, "p95Ms": 0,
"byRoute": [ { "route": "GET /api/feeds/:id", "count": 0, "errorCount": 0, "p95Ms": 0 } ]
},
"checks": [ { "name": "datasource:main", "status": "ok|degraded|down", "latencyMs": 3, "detail": "" } ],
"errors": [
{
"occurredAt": "…",
"fingerprint": "…",
"type": "database",
"message": "…",
"detail": "…",
"stackTrace": "…",
"context": { "route": "GET /api/feeds/:id", "method": "GET" }
}
],
"droppedErrors": 0
}
requestsis present only when the module saw requests. Each figure covers the interval since the previous heartbeat, not a running total.statusis the worst ofchecks, orokwith none.errorsare shaped byerrorDetail; see Errors and Redaction.
| Answer | Meaning |
|---|---|
204 | Accepted. |
409 | Unknown agentId (the collector's database was wiped, say). The module registers again and resends. |
401 | Bad key. Logged once, then retried every 5 minutes. |
413 | Too large. Resent without error bodies. |
deregister
Best effort, with a 2 second limit:
json{ "protocolVersion": 1, "agentId": "…", "reason": "shutdown" }
Server states
How a collector should read what it has received:
| State | Rule |
|---|---|
online | Last heartbeat within 2× the interval; shown with the heartbeat's status. |
stale | Last heartbeat 2× to 5× the interval ago. |
lost | No heartbeat for more than 5× the interval, and no deregister. |
stopped | Deregister received, and no heartbeat since. |