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

# Website change digest

> Watch pages with a monitor, receive each change by signed webhook, and send one daily digest of the changes that matter, without noise.

Send one daily digest of the changes that matter instead of an alert for every edit. A monitor judges each change against your `goal`, and your receiver stores events until the digest runs. You need `STOPHY_API_KEY` and a public address that accepts a `POST`. See the [Quickstart](https://docs.stophy.dev/quickstart.md).

## 1. Create the monitor

`goal` tells the judge which changes matter, and `webhook` says where events go. This request watches a page that returns a new identifier on every read, so a later check shows a change. The monthly schedule avoids daily checks while you build the receiver. Use `{ "text": "daily" }` for a real digest, and replace the page and address with yours.

```bash theme={null}
curl -X POST https://api.stophy.dev/v1/monitor \
  -H "Authorization: Bearer $STOPHY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Page that changes",
    "targets": [{ "type": "scrape", "urls": ["https://httpbin.org/uuid"] }],
    "schedule": { "cron": "0 0 1 * *" },
    "goal": "Tell me whenever the uuid changes.",
    "webhook": {
      "url": "https://example.com/stophy-hook",
      "events": ["monitor.page", "monitor.check.completed"]
    }
  }'
```

The answer holds the monitor's `id`. Keep it in `MONITOR_ID`. The first check starts at once and sets the baseline. It sends `monitor.check.completed` and no `monitor.page`. See [Targets](https://docs.stophy.dev/monitors/targets.md).

## 2. Receive and store events

Verify the signature before you store anything. Get the account secret with `POST /v1/webhook/secret` and keep it in `STOPHY_WEBHOOK_SECRET`. This Bun receiver stores each verified event once, keyed by `eventId`, and answers before any digest work. The signature format is on [Webhooks](https://docs.stophy.dev/webhooks.md#verify-signatures).

```typescript theme={null}
import { Database } from "bun:sqlite";
import { createHmac, timingSafeEqual } from "node:crypto";

const db = new Database("events.sqlite");
db.run("CREATE TABLE IF NOT EXISTS events (key TEXT PRIMARY KEY, body TEXT NOT NULL)");

const secret = process.env.STOPHY_WEBHOOK_SECRET ?? "";
if (!secret) throw new Error("Set STOPHY_WEBHOOK_SECRET before starting the receiver.");

function verifySignature(body: string, header: string | null): boolean {
  const match = /^t=(\d+),v1=([0-9a-f]{64})$/.exec(header ?? "");
  if (!match) return false;
  const [, timestamp = "", received = ""] = match;
  if (Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return false;
  const expected = createHmac("sha256", secret).update(`${timestamp}.${body}`).digest();
  return timingSafeEqual(Buffer.from(received, "hex"), expected);
}

export async function handle(request: Request): Promise<Response> {
  const body = await request.text();
  if (!verifySignature(body, request.headers.get("Stophy-Signature"))) {
    return new Response("bad signature", { status: 401 });
  }
  const { eventId } = JSON.parse(body);
  db.run("INSERT OR IGNORE INTO events (key, body) VALUES (?, ?)", [eventId, body]);
  return new Response("ok");
}
```

Run it with `Bun.serve({ port: 3000, fetch: handle })` where the monitor can reach it.

## 3. See a change

After the baseline, run a check by hand instead of waiting for the schedule.

```bash theme={null}
curl -X POST https://api.stophy.dev/v1/monitor/$MONITOR_ID/run \
  -H "Authorization: Bearer $STOPHY_API_KEY"
```

The check starts within a minute. Your receiver gets a `monitor.page` call like this one.

```json theme={null}
{
  "id": "mon_2f3L73izJTdaA1AQ",
  "event": "monitor.page",
  "eventId": "<event id>",
  "url": "https://httpbin.org/uuid",
  "changeStatus": "changed",
  "at": "2026-11-17T18:20:53.979Z",
  "diff": "@@ -1,3 +1,3 @@\n {\n-  \"uuid\": \"0714c38d-…\"\n+  \"uuid\": \"ec011f90-…\"\n }\n",
  "judgment": { "meaningful": true, "confidence": "high", "reason": "The uuid value changed, which is exactly what the goal tracks." }
}
```

`GET /v1/monitor/$MONITOR_ID/checks/$CHECK_ID` returns the same result with the diff, whether or not your receiver was up. See [Checks and changes](https://docs.stophy.dev/monitors/checks-and-changes.md).

## 4. Build the digest

Once a day, parse each stored `body`. Keep `monitor.page` events whose `at` is after your cutoff, and drop one only when `judgment.meaningful` is `false`, since a missing judgment does not rule out a change. Start the message with the number of changes. For each, list `changeStatus`, `url` and the judge's `reason`, or `No judgment.` If nothing matches, send `No changes worth reading in this window.`

## 5. Catch what you missed

Before each digest, list failed deliveries and retry each `id` in `data.deliveries` with `POST /v1/webhook/deliveries/{id}/retry`. Your receiver ignores an `eventId` it already stored.

```bash theme={null}
curl "https://api.stophy.dev/v1/webhook/deliveries?sourceType=monitor&status=failed" \
  -H "Authorization: Bearer $STOPHY_API_KEY"
```

A page that could not be read is not a `monitor.page` event. Read the row's `error` in `GET /v1/monitor/{id}/changes`. See [Webhooks](https://docs.stophy.dev/webhooks.md#delivery-history-and-retry).

## 6. Clean up

An active monitor runs on its schedule. Delete the test monitor, then point a new one at your pages.

```bash theme={null}
curl -X DELETE https://api.stophy.dev/v1/monitor/$MONITOR_ID \
  -H "Authorization: Bearer $STOPHY_API_KEY"
```

## Check it

* `GET /v1/monitor/$MONITOR_ID/checks` shows a `completed` first check.
* A call with a wrong signature gets `401` and stores nothing. The same valid call twice stores one row.
* The digest lists your changes and leaves out one the judge called noise.
* `GET /v1/webhook/deliveries?status=failed` is empty on a normal day.

See [Pricing](https://docs.stophy.dev/account/pricing.md) for check costs, and [Schedules](https://docs.stophy.dev/monitors/overview#schedule) to set how often a monitor checks.


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