> ## Documentation Index
> Fetch the complete documentation index at: https://hebeat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Heartbeats

> Get alerted when a cron job or scheduled task is late, fails or runs too long.

A heartbeat monitor works the other way around from a probed monitor: your job calls a unique **ping URL** each time it runs, and Hebeat alerts you when a ping doesn't arrive on time or reports a failure.

> [!NOTE]
>
> Plan feature: **heartbeat monitors**, included in paid plans. Heartbeats count toward your plan's monitor limit. See [pricing](https://hebeat.com/pricing).

## Create a heartbeat

**1. Choose Cron job / Heartbeat**

In **Monitors → Create monitor**, pick **Cron job / Heartbeat**.

**2. Set the schedule**

Choose how often the job runs:

* **Every N minutes, hours or days**: from 1 minute to 30 days.
* **Cron expression**: five fields (minute, hour, day of month, month, day of week) with a time zone.

Then set the **grace period** (1 minute to 7 days): how long to wait after the expected time before alerting. Use it for jobs whose run time varies, and for the time a ping takes to arrive.

**3. Copy the ping URL**

The ping URL is shown **once**, when you create the heartbeat. Copy it into your job. If you lose it, rotate it to get a new one; the previous URL stops working immediately.

## Send pings

Call the ping URL with `GET`, `HEAD` or `POST` when the job runs:

```bash crontab theme={null}
*/5 * * * * /usr/local/bin/backup.sh && curl -fsS -m 10 --retry 3 https://api.hebeat.com/ping/<token>
```

Append a signal to the URL to report more than "it ran":

| URL | Meaning |
| - | - |
| `/ping/<token>` | The job succeeded. |
| `/ping/<token>/start` | The job started. The heartbeat alerts if no success arrives within the grace period (**Running too long**). |
| `/ping/<token>/fail` | The job failed. The heartbeat goes down at once. |
| `/ping/<token>/<exit code>` | The job finished with this exit code (0–255). `0` is success; anything else is a failure. |

```bash Start and exit code theme={null}
curl -fsS -m 10 https://api.hebeat.com/ping/<token>/start
/usr/local/bin/backup.sh
curl -fsS -m 10 https://api.hebeat.com/ping/<token>/$?
```

The heartbeat page shows ready-to-copy snippets for crontab, bash, Node.js and Python, and a **Send test ping** button.

### Ping messages

Turn on **Keep ping messages** to store the first 1 KB of a `text/plain` request body with each ping and show it in the ping log. Email addresses, URL credentials and obvious tokens or passwords are removed, but IP addresses, names and other personal data are not, so don't send them. Turning the option off deletes the stored messages. Request bodies over 10 KB are refused.

### Limits

Each ping URL accepts up to 60 pings per minute; more answer `429 Too Many Requests` and are not evaluated.

## When a heartbeat alerts

A heartbeat goes **Down** and fires an [alert](https://hebeat.com/docs/knowledge-base/incidents-and-alerts.md) with one of these reasons:

| Reason | When |
| - | - |
| **Missed ping** | No ping arrived by the expected time plus the grace period. |
| **Reported failure** | The job called `/fail`. |
| **Reported failure (exit code N)** | The job reported a non-zero exit code. |
| **Running too long** | A `/start` was not followed by a success within the grace period. |

A success ping brings it back **Up**. The first success after creating a heartbeat turns it up without an alert.

**Flap protection:** a heartbeat sends at most one alert and one recovery notification per 5-minute window. A failure shortly after a recovery reopens the same alert instead of opening a new one. Every change is still recorded in the heartbeat's history.

> [!NOTE]
>
> A paused heartbeat records pings but doesn't evaluate them. Changing the schedule or resuming a heartbeat restarts its clock from that moment, so it never alerts for time that already passed.

## Uptime and history

The heartbeat page shows the last ping, the next expected ping, uptime over 24 hours, 7 days and 30 days, and the recent pings with their signal, duration and message. Ping history follows your plan's detailed-history retention.

You can also read pings and uptime from the API (`GET /monitors/{monitor_id}/pings` and `GET /monitors/{monitor_id}/heartbeat-uptime`) and create heartbeats with `POST /monitors` (`config.type: "heartbeat"`) or the `create_heartbeat` [MCP tool](https://hebeat.com/docs/ai/tools.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.