Protocol

The three calls bx-monitor makes, in full, for anyone writing a collector.

Rules

  • JSON over HTTPS, POST only, with Authorization: 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 with 426 and a JSON body naming the versions it supports.
CallWhen
POST /api/v1/registerStartup, and whenever the collector answers a heartbeat with 409
POST /api/v1/heartbeatEvery interval
POST /api/v1/deregisterGraceful 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
}
  • requests is present only when the module saw requests. Each figure covers the interval since the previous heartbeat, not a running total.
  • status is the worst of checks, or ok with none.
  • errors are shaped by errorDetail; see Errors and Redaction.
AnswerMeaning
204Accepted.
409Unknown agentId (the collector's database was wiped, say). The module registers again and resends.
401Bad key. Logged once, then retried every 5 minutes.
413Too 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:

StateRule
onlineLast heartbeat within 2× the interval; shown with the heartbeat's status.
staleLast heartbeat 2× to 5× the interval ago.
lostNo heartbeat for more than 5× the interval, and no deregister.
stoppedDeregister received, and no heartbeat since.