# Quickstart: your first watch

> Create a watch, ask for a delivered check, read the event feed and fetch the current page.

Netscrape keeps your website data fresh: a watch re-reads a page on a schedule
you choose and tells you when it really changes. This takes five steps: create a watch, ask for a check now, wait for it to
finish, read the events it produced, and fetch the page Netscrape read. You need
an API key from a paid Netscrape account. Sign up, verify your email, choose a
plan and create a key on the
[API keys page](https://netscrapehq.com/account/keys). If self-serve signup is closed,
[request access](mailto:hello@netscrapehq.com?subject=Netscrape%20access) and
we will issue your key. To have a coding agent do these steps, use
[the agent prompts](https://netscrapehq.com/docs/agents.md).

```sh
export NETSCRAPE_API_KEY="your key"
```

## 1. Create a watch

Watch a page and say how fresh it must stay. Here it's read at least once a day,
and you may ask for a read at most once an hour.

```sh
curl https://netscrapehq.com/v1/watches \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"external_id":"catalogue-home","labels":["catalogue"],"request":{"url":"https://example.com/catalogue","render":"auto","output":"document","policy":{"robots":true}},"compare":{"on":"text"},"freshness":{"max_age":"1d","min_interval":"1h"}}'
```

- `external_id` is your own id for the page. Sending it again updates the same
  watch, so enrolment is safe to repeat.
- `request` is the same body a [one-off job](https://netscrapehq.com/docs/jobs.md) takes. Watches check
  robots.txt before every read; `policy` here only makes that explicit.
- `compare.on: "text"` compares the page's visible text, after masking common
  noise.

Netscrape answers `201` with the watch. Keep its `id`:

```json
{
  "id": "90a38653-a848-4a49-8634-055be25b3cde",
  "kind": "page",
  "external_id": "catalogue-home",
  "labels": ["catalogue"],
  "status": "active",
  "health": "pending",
  "schedule": "auto",
  "request": {
    "url": "https://example.com/catalogue",
    "render": "auto",
    "output": "document",
    "policy": {"robots": true}
  },
  "compare": {"on": "text"},
  "freshness": {"max_age": 86400, "min_interval": 3600, "adaptive": false},
  "interval": 86400,
  "lifecycle": {
    "gone_after": 2,
    "gone_spacing": 86400,
    "failing_after": 3,
    "failing_span": 86400,
    "blocked_after": 2,
    "on_gone": "keep_checking",
    "follow_moves": "same_site"
  },
  "next_check_at": "2026-11-14T08:37:27.659823Z",
  "last_check_at": null,
  "last_change_at": null,
  "current": {},
  "pending_job_id": null,
  "noisy": false,
  "deliver_next": false,
  "emit_checks": false
}
```

The first scheduled read is spread across the first interval, so it may be
hours away. You don't have to wait for it.

## 2. Ask for a check now

```sh
export WATCH_ID=90a38653-a848-4a49-8634-055be25b3cde
curl -X POST https://netscrapehq.com/v1/watches/$WATCH_ID/check \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"deliver":true}'
```

`deliver: true` asks for a delivered check: it always ends in a `watch.checked`
event that points at the page it read, even when nothing changed. The answer is
`202` with the [job](https://netscrapehq.com/docs/jobs.md) that does the read:

```json
{
  "id": "45ef34a0-9648-4240-b752-b89368298eaf",
  "type": "scrape",
  "status": "queued",
  "watch_id": "90a38653-a848-4a49-8634-055be25b3cde",
  "url": "https://example.com/catalogue",
  "status_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf",
  "result_url": null,
  "result_expires_at": "2026-11-20T11:10:15.664934Z"
}
```

The job response has more fields than shown here; the
[API reference](https://netscrapehq.com/docs/api.md#get-a-job) lists them all. A watch has one check in
flight at a time, so asking again before this one finishes returns
`409 check_pending`.

## 3. Wait for the check to finish

The check runs in the background, so its events arrive a few seconds or more
after the `202`. Events are numbered per account. Poll the feed for this watch's
label until the `watch.checked` event for your check's job turns up, moving the
cursor on each time. This loop uses `jq`:

```sh
export JOB_ID=45ef34a0-9648-4240-b752-b89368298eaf
CURSOR=0
until curl -fsS "https://netscrapehq.com/v1/events?after=$CURSOR&label=catalogue" \
    -H "Authorization: Bearer $NETSCRAPE_API_KEY" > events.json &&
  jq -e --arg job "$JOB_ID" \
    '.data[] | select(.type == "watch.checked" and .check.job_id == $job)' events.json > /dev/null
do
  NEXT=$(jq -r '.next_cursor // empty' events.json 2>/dev/null)
  CURSOR=${NEXT:-$CURSOR}
  sleep 5
done
```

In production, take [webhooks](https://netscrapehq.com/docs/events.md#webhooks) instead of polling.

## 4. Read the events

Once it's done, read the feed from the start:

```sh
curl "https://netscrapehq.com/v1/events?after=0&label=catalogue" \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY"
```

The first successful read produces three events: the watch became `healthy`,
its first version was recorded as a change, and the delivered check finished.

```json
{
  "data": [
    {
      "id": "5a138101-2581-44bc-a90e-42ac638fa2b2",
      "sequence": 1,
      "type": "watch.health_changed",
      "at": "2026-11-13T11:10:15.689047Z",
      "watch": {"id": "90a38653-a848-4a49-8634-055be25b3cde", "external_id": "catalogue-home", "labels": ["catalogue"]},
      "from": "pending",
      "to": "healthy",
      "reason": "http_200",
      "evidence": {"kind": "healthy", "reason": "http_200", "status": 200, "challenge": null, "robots_rule": null},
      "check": {"id": "c14c8e51-de4d-464d-8e09-a044893b191a", "job_id": "45ef34a0-9648-4240-b752-b89368298eaf", "at": "2026-11-13T11:10:15.689047Z", "status": 200}
    },
    {
      "id": "914ec707-969a-4f74-a7a0-82b7f7afefdc",
      "sequence": 2,
      "type": "watch.changed",
      "at": "2026-11-13T11:10:15.689047Z",
      "watch": {"id": "90a38653-a848-4a49-8634-055be25b3cde", "external_id": "catalogue-home", "labels": ["catalogue"]},
      "before": {},
      "after": {
        "version": 1,
        "fingerprint": "ffadfb575da1f4732d52d5102d136dab523f095d98c0ba400e808c61ed8ffcfe",
        "job_id": "45ef34a0-9648-4240-b752-b89368298eaf",
        "read_at": "2026-11-13T11:10:15.689047Z",
        "result_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf/result",
        "result_expires_at": "2026-11-20T11:10:15.664934Z",
        "payload_expired": false
      },
      "diff": {"kind": "lines", "added": 2, "removed": 0, "hunks": [{"op": "ins", "text": "Lamp A - 40\nLamp B - 55"}], "truncated": false},
      "reversal": false,
      "earlier_version": null,
      "check": {"id": "c14c8e51-de4d-464d-8e09-a044893b191a", "job_id": "45ef34a0-9648-4240-b752-b89368298eaf", "at": "2026-11-13T11:10:15.689047Z", "status": 200}
    },
    {
      "id": "f0394eb7-dff5-4826-9191-4b6e81bb4655",
      "sequence": 3,
      "type": "watch.checked",
      "at": "2026-11-13T11:10:15.689047Z",
      "watch": {"id": "90a38653-a848-4a49-8634-055be25b3cde", "external_id": "catalogue-home", "labels": ["catalogue"]},
      "delivered": true,
      "changed": true,
      "outcome": "changed",
      "superseded": false,
      "fingerprint": "ffadfb575da1f4732d52d5102d136dab523f095d98c0ba400e808c61ed8ffcfe",
      "job_id": "45ef34a0-9648-4240-b752-b89368298eaf",
      "result_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf/result",
      "result_expires_at": "2026-11-20T11:10:15.664934Z",
      "payload_expired": false,
      "check": {"id": "c14c8e51-de4d-464d-8e09-a044893b191a", "job_id": "45ef34a0-9648-4240-b752-b89368298eaf", "at": "2026-11-13T11:10:15.689047Z", "status": 200}
    }
  ],
  "next_cursor": 3,
  "has_more": false,
  "webhook_status": "healthy"
}
```

Versions carry a few more hashes than shown; see
[Change events & webhooks](https://netscrapehq.com/docs/events.md#event-types). Store `next_cursor` once
you've processed the page, and pass it as `after` next time.

## 5. Fetch the current page

```sh
curl https://netscrapehq.com/v1/watches/$WATCH_ID/current \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY"
```

This returns the latest version, with a `result_url` for the page Netscrape read.
Download the page itself from that URL with the same key:

```sh
curl https://netscrapehq.com/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf/result \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY"
```

Page bodies are kept for seven days. After that, `result_url` is `null` and
`payload_expired` is `true`; ask for a fresh read with a delivered check or a
[resync](https://netscrapehq.com/docs/events.md#resync-and-recovery).

## Next steps

- Receive events as they happen with [webhooks](https://netscrapehq.com/docs/events.md#webhooks) instead
  of polling the feed.
- Cut noise with [ignore rules and confirmation re-reads](https://netscrapehq.com/docs/watches.md#comparisons).
- Enrol many pages at once with [batch upsert](https://netscrapehq.com/docs/api.md#create-or-update-watches-in-a-batch).
- Retire the watch when you're done:

```sh
curl -X DELETE https://netscrapehq.com/v1/watches/$WATCH_ID \
  -H "Authorization: Bearer $NETSCRAPE_API_KEY"
```
