# Uptime Monitor Alerts (/docs/experiments/uptime-monitor-alerts)



Extend the is-it-down pattern into a persistent monitor. **Cron** pings registered URLs, logs checks to **D1**, and sends **email alerts** when a URL transitions from up to down.

## Features [#features]

* POST /monitors - register URL + alert email
* DELETE /monitors/:id - remove monitor
* GET /monitors/:id/history - check history and uptime percentage
* Scheduled checks every 5 minutes

## API Reference [#api-reference]

### POST /monitors [#post-monitors]

```json
{ "url": "https://example.com", "alertEmail": "you@example.com" }
```

### DELETE /monitors/:id [#delete-monitorsid]

Remove a monitor.

### GET /monitors/:id/history [#get-monitorsidhistory]

Returns check history and uptime percentage.

#### Error Codes [#error-codes]

* `400` - `INVALID_URL`, `INVALID_EMAIL`, `INVALID_BODY`
* `404` - `NOT_FOUND`

## Use Cases [#use-cases]

* Lightweight uptime monitoring for side projects
* Learn Cron + D1 + send\_email alert patterns on Workers
* Track uptime percentage over time for SLA reporting

## Limitations [#limitations]

* Requires D1, Cron, and send\_email bindings configured for your domain
* 5-minute check interval; not sub-minute alerting
* Single-region edge checks; not global multi-PoP consensus

## Deployment [#deployment]

<Steps>
  <Step>
    ### Click the deploy button [#click-the-deploy-button]

    [![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/shrinathsnayak/cloudflare-experiments/tree/main/apps/experiments/uptime-monitor-alerts)
  </Step>

  <Step>
    ### Configure bindings [#configure-bindings]

    D1 `DB`, `send_email` binding `EMAILER`, cron `*/5 * * * *`. Configure allowed sender/destination addresses in wrangler.
  </Step>

  <Step>
    ### Test your deployment [#test-your-deployment]

    See the experiment README for curl examples.
  </Step>
</Steps>

## Local Development [#local-development]

```bash
cd apps/experiments/uptime-monitor-alerts
npm install
npm run dev
```

## Configuration [#configuration]

D1 `DB`, `send_email` binding `EMAILER`, cron `*/5 * * * *`. Configure allowed sender/destination addresses in wrangler.

## Cloudflare Features Used [#cloudflare-features-used]

* **[D1](https://developers.cloudflare.com/d1/)**
* **[Cron Triggers](https://developers.cloudflare.com/workers/configuration/cron-triggers/)**
* **[Email Routing / send\_email](https://developers.cloudflare.com/email-routing/email-workers/send-email-workers/)**
