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
| Method | Path | Permission | Description |
|---|---|---|---|
POST | /api/heartbeat | write:heartbeats | Create or update a heartbeat. Counts as a receive |
GET | /api/heartbeat/<id> | read:heartbeats | Get one heartbeat |
PUT | /api/heartbeat/<id> | write:heartbeats | Edit a heartbeat's settings. Does not count as a receive |
GET | /api/heartbeats | read:heartbeats | List heartbeats (filters, sorting, paging) |
DELETE | /api/heartbeat/<id> | write:heartbeats | Delete a heartbeat |
POST | /api/heartbeats/bulk/delete | write:heartbeats | Delete several heartbeats |
admin:heartbeats grants every heartbeat operation. See API keys.
Heartbeat fields
| Field | Type | Default | Description |
|---|---|---|---|
origin | String | — | Identity of the heartbeat. Sending the same origin again updates the same heartbeat. Always set it |
type | String | Heartbeat | Free label |
tags | Array | [] | Tags, copied to the generated alert |
attributes | Object | {} | Extra data |
timeout | Integer (s) | HEARTBEAT_TIMEOUT (86400) | Seconds without a receive before the status is expired |
maxLatency | Integer (ms) | HEARTBEAT_MAX_LATENCY (2000) | Latency above which the status is slow |
createTime | ISO 8601 | Receive time | When the sender created the heartbeat. Needed to measure latency |
environment | String | Production | Environment of the generated alert |
service | Array | [] | Services of the generated alert |
severity | String | major | Severity of the HeartbeatFail alert |
group | String | Heartbeat | Group of the generated alert |
text | String | — | Text of the generated alert (the origin is used when empty) |
Read-only fields returned by the API:
| Field | Description |
|---|---|
id | Heartbeat id |
href | Link to the heartbeat editor in the Web UI (…/tobealert/heartbeats?edit=<id>) |
lastReceiveTime | When the last heartbeat was received |
latency | Milliseconds between createTime and the receive |
since | Seconds since the last receive |
status | ok, slow, or expired |
alertId | Id of the heartbeat's alert, when one was raised |
Status rules
expiredwhensince>timeout.slowwhenlatency>maxLatency(only possible when the sender sendscreateTime).okotherwise.
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"
| Parameter | Description |
|---|---|
status | ok, slow, or expired; repeat it for several. Other values return 400 |
origin, environment, service, … | Filter by field |
sort-by | Field to sort by |
page, page-size | Paging |
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
typeisheartbeat(case-insensitive; settingHEARTBEAT_ALERT_TYPE), or - its
eventis inHEARTBEAT_EVENTS(default["Heartbeat"]).
| Alert field | Heartbeat field |
|---|---|
resource | origin |
attribute heartbeatTimeout, or timeout | timeout |
attribute heartbeatMaxLatency | maxLatency |
attribute heartbeatSeverity | severity |
createTime, environment, service, group, text, tags | Same field |
| Other attributes | attributes |
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:
| Transition | event | severity |
|---|---|---|
→ expired | HeartbeatFail | The heartbeat's severity |
→ slow | HeartbeatSlow | warning |
expired / slow → ok | HeartbeatOK | normal (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
| Setting | Default | Description |
|---|---|---|
HEARTBEAT_TIMEOUT | 86400 | Default timeout (s) |
HEARTBEAT_MAX_LATENCY | 2000 | Default max latency (ms) |
HEARTBEAT_ALERT_TYPE | heartbeat | Alert type that turns an alert into a heartbeat |
HEARTBEAT_EVENTS | ["Heartbeat"] | Alert events that turn an alert into a heartbeat |
See Settings file.