# Monitor parameters

The endpoints, every field of a monitor, the intervals each plan and source allows, and the events.

A monitor is a saved target, an interval and a place to deliver events.

| Kind | Target | A change is | Credits per check |
|---|---|---|---|
| `query` | A search: a query, one source, and the search filters | A result URL this monitor has not seen before, among the first `top_n` results | 1 |
| `url` | One page | The page's main text differs from the last check by more than `min_change_chars` | The price of the mode: 0.5 for `live`, 2 for `rendered` |

A check that fails, is put off, or cannot be paid for is free, except a `rendered` check whose page the site says does not exist (`404`, `410`), which is charged like a check that ran.

## Endpoints

| Endpoint | What it does |
|---|---|
| `POST /v1/monitors` | Create a monitor |
| `GET /v1/monitors` | List your monitors. Free |
| `GET /v1/monitors/{id}` | One monitor. Free |
| `PATCH /v1/monitors/{id}` | Change `status` (`active` or `paused`), `interval_minutes`, `webhook_id` or `name` |
| `DELETE /v1/monitors/{id}` | Delete it |
| `POST /v1/monitors/{id}/run` | Check now. Charged like a scheduled check. Four an hour per monitor |
| `GET /v1/monitors/{id}/events` | Pull its events. Free. Events are kept 30 days |

## Create a query monitor

```bash
curl https://api.millionshort.com/v1/monitors \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "query",
    "name": "bridge tenders",
    "query": "bridge inspection",
    "source": "contracts",
    "top_n": 10,
    "interval_minutes": 1440
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/monitors",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "kind": "query",
        "name": "bridge tenders",
        "query": "bridge inspection",
        "source": "contracts",
        "top_n": 10,
        "interval_minutes": 1440
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/monitors', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "kind": "query",
    "name": "bridge tenders",
    "query": "bridge inspection",
    "source": "contracts",
    "top_n": 10,
    "interval_minutes": 1440
  }),
});
if (!res.ok) throw new Error(`POST /v1/monitors failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

## Create a URL monitor

```bash
curl https://api.millionshort.com/v1/monitors \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "url",
    "url": "https://example.org/pricing",
    "mode": "live",
    "ignore": ["numbers", "dates"],
    "min_change_chars": 40,
    "interval_minutes": 60
  }'
```

```python
import os

import requests

r = requests.post(
    "https://api.millionshort.com/v1/monitors",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    json={
        "kind": "url",
        "url": "https://example.org/pricing",
        "mode": "live",
        "ignore": [
            "numbers",
            "dates"
        ],
        "min_change_chars": 40,
        "interval_minutes": 60
    },
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch('https://api.millionshort.com/v1/monitors', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "kind": "url",
    "url": "https://example.org/pricing",
    "mode": "live",
    "ignore": [
      "numbers",
      "dates"
    ],
    "min_change_chars": 40,
    "interval_minutes": 60
  }),
});
if (!res.ok) throw new Error(`POST /v1/monitors failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

## Fields

| Field | Type | Default | Notes |
|---|---|---|---|
| `kind` | `query` or `url` | | Required |
| `interval_minutes` | integer, 1 to 43,200 | | Required. How often to check. The longest is 30 days. The shortest your monitor may use depends on the plan and the source ([below](#sources-and-intervals)): no plan or source today allows less than 5 minutes, and a shorter value is refused with the shortest allowed |
| `name` | string, up to 120 characters | | A label for you |
| `webhook_id` | string | | An active [webhook endpoint](https://millionshort.com/docs/webhooks). Without it, you pull events |
| `notify_on_create` | boolean | `false` | The first check records a baseline and sends nothing, unless this is `true` |
| `confirm_after` | integer, 0 to 5 | `0` | A change must still be there on the next n checks before the event is sent |
| `query` | string | | `query` monitors: what to search for |
| `source` | one source | | `query` monitors: `social`, `hn`, `news`, `law`, `contracts`, `podcasts`, `academic`, `medical` or `finance` |
| `filters` | object | | `query` monitors: the search request's domain lists, page types, topics and `safe_search` |
| `top_n` | integer, 1 to 25 | `10` | `query` monitors: how far down the list to look for new results |
| `url` | string | | `url` monitors: the page to watch |
| `mode` | `live` or `rendered` | `"live"` | `url` monitors: how the page is fetched |
| `ignore` | array of `numbers`, `dates` | | `url` monitors: kinds of change to disregard |
| `min_change_chars` | integer, 0 to 10,000 | `40` | `url` monitors: the smallest change worth an event |

## Sources and intervals

A query monitor watches one source, and only sources that are kept current:

| Source | Shortest interval |
|---|---|
| `social`, `hn` | 15 minutes (5 minutes on the Scale plan and above) |
| `news` | 1 hour |
| `law`, `contracts`, `podcasts`, `academic`, `medical`, `finance` | 24 hours |
| `web`, `smallweb`, `discussions`, `communities` | Not offered. The call answers `400 UNSUPPORTED_OPTION`. Watch a page with a `url` monitor instead |

`web` is left out on purpose: it is [refreshed periodically](https://millionshort.com/docs/search/freshness), so a monitor on it would report the index changing, not the world.

| Plan | Active monitors | Shortest interval |
|---|---|---|
| Free | 3 | 24 hours |
| Starter | 25 | 1 hour |
| Growth | 100 | 15 minutes |
| Scale | 500 | 5 minutes (`social`, `hn`) |
| Business | 2,000 | 5 minutes |

A monitor's shortest interval is the longer of its plan's and its source's. A `url` monitor follows the plan column, and is never shorter than 15 minutes.

## A monitor

| Field | Type | Notes |
|---|---|---|
| `id` | string | |
| `kind` | `query` or `url` | |
| `name` | string or null | |
| `status` | `active` or `paused` | |
| `paused_reason` | string or null | `user`, `insufficient_credits`, `webhook_disabled`, `failing`, `unavailable` or `plan`. [Monitor errors](https://millionshort.com/docs/monitor/errors#a-check-that-fails) says what each means |
| `target` | object | What it watches |
| `interval_minutes` | integer | |
| `webhook_id` | string or null | |
| `last_checked_at`, `last_changed_at`, `next_check_at` | date and time, or null | |
| `consecutive_failures` | integer | |
| `created_at` | date and time | |

## Events

Events are delivered to the monitor's webhook when it has one, and can always be pulled:

```bash
curl "https://api.millionshort.com/v1/monitors/$MONITOR_ID/events?limit=50" \
  -H "Authorization: Bearer $MILLIONSHORT_API_KEY"
```

```python
import os

import requests

r = requests.get(
    f"https://api.millionshort.com/v1/monitors/{os.environ['MONITOR_ID']}/events?limit=50",
    headers={"Authorization": "Bearer " + os.environ["MILLIONSHORT_API_KEY"]},
    timeout=30,
)
r.raise_for_status()
print(r.json()["data"])
```

```ts
const res = await fetch(`https://api.millionshort.com/v1/monitors/${process.env.MONITOR_ID}/events?limit=50`, {
  headers: { Authorization: `Bearer ${process.env.MILLIONSHORT_API_KEY}` },
});
if (!res.ok) throw new Error(`GET /v1/monitors/…/events failed: ${res.status}`);
const { data } = (await res.json()) as { data: unknown };
console.log(data);
```

Pass the id of the last event you handled as `after` to get only newer ones.

Every event has `id` (`evt_` and an identifier), `type`, `monitor_id`, `created_at` and `data`.

| Type | When | `data` |
|---|---|---|
| `monitor.changed`, query | New result URLs appeared | `kind`, `new_results` (each with `title`, `url`, `site`, `source`, `snippet`, `published_date`, `position`, `topic`, `page_type`, `source_hint`, `label_confidence`), `checked_at` |
| `monitor.changed`, URL | The page changed | `kind`, `url`, `topic`, `page_type`, `source_hint`, `label_confidence`, `added`, `removed`, `truncated`, `previous_hash`, `current_hash`, `checked_at` |
| `monitor.failed` | 3 checks in a row failed | `code`, `message`, `consecutive_failures` |
| `monitor.paused` | Out of credits 3 checks in a row, or its webhook endpoint was disabled | `reason` |

Every `monitor.changed` event says what its pages are, with the same [labels](https://millionshort.com/docs/extract/parameters#labels) an extracted page carries, so the program that receives an event can route it without fetching anything. A page event carries the labels of the page as it is now. A new search result carries the `topic` and `page_type` the search gave it where it gave them, and otherwise ones read from its title and snippet; its `source_hint` is the source it came from. A label that is a known fact rather than a reading has a `null` confidence. Any label can be `null`, as on Extract. Labels are free.

`added` and `removed` are the changed blocks of text, capped at 20 KB together. We keep the last two snapshots of a watched page, not its history.

## Behaviour to know

- The first check records a baseline and sends nothing, unless `notify_on_create` is `true`.
- Scheduled checks are spread by up to 10% of the interval, so a 60-minute monitor runs roughly hourly, not on the hour.
- After 10 failed checks in a row a monitor is paused, with `paused_reason: "failing"`. A check we could not make because search was busy, or because a page's site was busy for us, is put off: it is free, and it is not a failed check.
- A scheduled check that was put off is tried again about two minutes later, up to three times, before the monitor goes back to its interval. This holds for `query` and `url` monitors alike.
- A query check costs 1 credit whatever `top_n` is.
- A `url` monitor passes the same URL rules and robots.txt check as [Extract](https://millionshort.com/docs/extract/parameters) on every check, not only when it is created.
- Checks count towards the [per-site daily fetch limit](https://millionshort.com/docs/extract/parameters#the-daily-limit-per-site) of Extract (2,000 fetches of one site a day), in the way that limit counts: **a check that finds the page unchanged is not another fetch of the day.** The first check of a page in a day counts once, and after that only a check that finds the page changed counts. A hundred monitored pages of one site, checked every 15 minutes, use about a hundred fetches a day plus one for each change. A page that is different on every check (a search page, a feed with a clock in it) counts on every check; `ignore: ["numbers", "dates"]` applies here as it does to what the monitor reports. When the day's fetches of a site are used up, a check that finds a changed page fails, free, until the next day (UTC).

## Errors

`400 INVALID_PARAM`, which includes an interval shorter than the plan and the source allow (`error.details.min_interval_minutes` says the shortest); `400 UNSUPPORTED_OPTION` for a source a query monitor cannot watch; `401` for a missing or refused key; `404 JOB_NOT_FOUND` for a monitor that does not exist or is not yours; `429`. See [Errors](https://millionshort.com/docs/errors).

## Over MCP

The MCP server has a read-only `list_monitor_events` tool. No MCP tool creates or deletes a monitor.

## Without a monitor

A search run on a schedule that remembers the URLs it has seen does the same job in your own code. The [news monitoring guide](https://millionshort.com/docs/monitor/guides/news-monitoring) has both ways.
