Skip to main content
Version: 1.4 (Current)

Heartbeats API

A heartbeat is a periodic "I am still alive" signal from a monitored system. ToBeAlert stores when each heartbeat was last received and raises an alert when it stops arriving or arrives late. Concepts, statuses, generated alerts, and the Alerts → Heartbeats page are described in Heartbeats (Web UI).

All requests need an API key in the Authorization: Key <api-key> header.

Endpoints​

MethodPathPermissionDescription
POST/api/heartbeatwrite:heartbeatsCreate or update a heartbeat. Counts as a receive
GET/api/heartbeat/<id>read:heartbeatsGet one heartbeat
PUT/api/heartbeat/<id>write:heartbeatsEdit a heartbeat's settings. Does not count as a receive
GET/api/heartbeatsread:heartbeatsList heartbeats (filters, sorting, paging)
DELETE/api/heartbeat/<id>write:heartbeatsDelete a heartbeat
POST/api/heartbeats/bulk/deletewrite:heartbeatsDelete several heartbeats

admin:heartbeats grants every heartbeat operation. See API keys.

Heartbeat fields​

FieldTypeDefaultDescription
originString—Identity of the heartbeat. Sending the same origin again updates the same heartbeat. Always set it
typeStringHeartbeatFree label
tagsArray[]Tags, copied to the generated alert
attributesObject{}Extra data
timeoutInteger (s)HEARTBEAT_TIMEOUT (86400)Seconds without a receive before the status is expired
maxLatencyInteger (ms)HEARTBEAT_MAX_LATENCY (2000)Latency above which the status is slow
createTimeISO 8601Receive timeWhen the sender created the heartbeat. Needed to measure latency
environmentStringProductionEnvironment of the generated alert
serviceArray[]Services of the generated alert
severityStringmajorSeverity of the HeartbeatFail alert
groupStringHeartbeatGroup of the generated alert
textString—Text of the generated alert (the origin is used when empty)

Read-only fields returned by the API:

FieldDescription
idHeartbeat id
hrefLink to the heartbeat editor in the Web UI (…/tobealert/heartbeats?edit=<id>)
lastReceiveTimeWhen the last heartbeat was received
latencyMilliseconds between createTime and the receive
sinceSeconds since the last receive
statusok, slow, or expired
alertIdId of the heartbeat's alert, when one was raised

Status rules​

  • expired when since > timeout.
  • slow when latency > maxLatency (only possible when the sender sends createTime).
  • ok otherwise.

Create or update (send a heartbeat)​

curl -X POST https://your-tobealert.com:9000/api/heartbeat \
-H "Content-Type: application/json" \
-H "Authorization: Key <api-key>" \
-d '{
"origin": "nightly-backup",
"timeout": 90000,
"maxLatency": 5000,
"createTime": "2026-10-24T02:00:00.000Z",
"environment": "Production",
"service": ["Backup"],
"severity": "critical",
"group": "Backup",
"text": "Nightly backup of the file server",
"tags": ["backup"]
}'

Response 201:

{
"status": "ok",
"id": "a1b2c3d4-…",
"heartbeat": {
"id": "a1b2c3d4-…",
"href": "https://your-tobealert.com/tobealert/heartbeats?edit=a1b2c3d4-…",
"origin": "nightly-backup",
"status": "ok",
"timeout": 90000,
"maxLatency": 5000,
"latency": 120,
"since": 0,
"…": "…"
}
}

Invalid values (for example timeout not an integer, service not a list, or an unknown severity) return 400.

Edit settings​

PUT /api/heartbeat/<id> changes timeout, maxLatency, environment, service, severity, group, text, tags, and attributes without counting as a receive (the last receive time and since stay as they were). origin cannot be changed (it is ignored if sent). Any other field returns 400; a missing heartbeat returns 404.

curl -X PUT https://your-tobealert.com:9000/api/heartbeat/<id> \
-H "Content-Type: application/json" \
-H "Authorization: Key <api-key>" \
-d '{"timeout": 7200, "severity": "major"}'

List​

curl -H "Authorization: Key <api-key>" \
"https://your-tobealert.com:9000/api/heartbeats?status=expired&environment=Production&page=1&page-size=50"
ParameterDescription
statusok, slow, or expired; repeat it for several. Other values return 400
origin, environment, service, …Filter by field
sort-byField to sort by
page, page-sizePaging

Response: {"status": "ok", "heartbeats": [...], "total": 3, "page": 1, "pageSize": 50, "pages": 1, "more": false}.

Delete​

# One heartbeat
curl -X DELETE -H "Authorization: Key <api-key>" \
https://your-tobealert.com:9000/api/heartbeat/<id>

# Several heartbeats
curl -X POST https://your-tobealert.com:9000/api/heartbeats/bulk/delete \
-H "Content-Type: application/json" \
-H "Authorization: Key <api-key>" \
-d '{"heartbeats": ["<id-1>", "<id-2>"]}'

The bulk response lists the deleted ids in deleted and their number in count. Deleting a heartbeat does not change its alert.

Sending a heartbeat as an alert​

Tools that can only send alerts can send heartbeats through POST /api/alert or a custom webhook. An alert is converted into a heartbeat instead of being stored when:

  • its type is heartbeat (case-insensitive; setting HEARTBEAT_ALERT_TYPE), or
  • its event is in HEARTBEAT_EVENTS (default ["Heartbeat"]).
Alert fieldHeartbeat field
resourceorigin
attribute heartbeatTimeout, or timeouttimeout
attribute heartbeatMaxLatencymaxLatency
attribute heartbeatSeverityseverity
createTime, environment, service, group, text, tagsSame field
Other attributesattributes

An alert timeout equal to the default alert timeout (ALERT_TIMEOUT) is treated as not set, so the heartbeat keeps HEARTBEAT_TIMEOUT; use heartbeatTimeout to be explicit.

curl -X POST https://your-tobealert.com:9000/api/alert \
-H "Content-Type: application/json" \
-H "Authorization: Key <api-key>" \
-d '{
"resource": "nightly-backup",
"event": "Heartbeat",
"type": "heartbeat",
"environment": "Production",
"service": ["Backup"],
"timeout": 90000,
"attributes": {"heartbeatSeverity": "critical", "heartbeatMaxLatency": 5000}
}'

The alert API answers 202 with the heartbeat id ({"status": "ok", "id": "<heartbeat-id>", …}); no alert is created. Custom webhooks report the number of converted alerts in heartbeats_received.

Alerts raised by the heartbeat monitor​

Every 60 seconds ToBeAlert checks all heartbeats and sends an alert only when a status changes:

Transitioneventseverity
→ expiredHeartbeatFailThe heartbeat's severity
→ slowHeartbeatSlowwarning
expired / slow → okHeartbeatOKnormal (closes the alert)

The three events are correlated into one alert per heartbeat with resource = heartbeat origin, origin = tobealert/heartbeat-monitor, type = heartbeatAlert, and the heartbeat's environment, service, group, tags, and text. The alert attributes include heartbeatId, heartbeatStatus, timeout, maxLatency, and lastReceiveTime. Policies, maintenance windows, and notification rules apply as to any alert. A new heartbeat does not alert until its timeout passes.

Configuration​

SettingDefaultDescription
HEARTBEAT_TIMEOUT86400Default timeout (s)
HEARTBEAT_MAX_LATENCY2000Default max latency (ms)
HEARTBEAT_ALERT_TYPEheartbeatAlert type that turns an alert into a heartbeat
HEARTBEAT_EVENTS["Heartbeat"]Alert events that turn an alert into a heartbeat

See Settings file.