# API reference

> Every Netscrape endpoint for watches, events, jobs and usage, with request and response examples, error codes and status codes.

## Basics

- **Base URL:** `https://netscrapehq.com/v1`
- **OpenAPI:** the [OpenAPI 3.1 spec](https://netscrapehq.com/openapi.json) describes every endpoint
  below with its error codes, for client generators and agents.
- **Authentication:** every request sends `Authorization: Bearer <key>`, an API
  key from a paid Netscrape account, created on the
  [API keys page](https://netscrapehq.com/account/keys). A missing, unknown or revoked key answers
  `401 unauthorised`.
- **Rate limits:** too many requests answer `429 rate_limited` with a
  `Retry-After` header in seconds. Wait that long, then retry. See
  [request rate](https://netscrapehq.com/docs/limits.md#request-rate).
- **Bodies** are JSON, up to 16 KiB (2 MiB for `POST /v1/watches/batch`). Send
  `Content-Type: application/json`.
- **Times** are ISO 8601 in UTC. **Durations** in responses are seconds.
- **Scope:** everything belongs to the account the key belongs to. Another
  account's watch or job answers `404 not_found`.
- **Pagination:** list endpoints take `limit` (1–500, default 100) and return
  `next_cursor`, which is `null` on the last page.

### Errors

Errors have one shape:

```json
{"error": {"code": "check_pending"}}
```

| Status | Codes |
| --- | --- |
| 400 | `invalid_watch`, `invalid_watch_request`, `invalid_batch`, `external_id_required`, `external_id_conflict`, `label_required`, `invalid_filter`, `invalid_cursor`, `invalid_deliver`, `invalid_period`, `unsupported_option`, `watch_not_manual`, `watch_request_mismatch`, `invalid_idempotency_key`, `invalid_request` and other request validation codes |
| 401 | `unauthorised` |
| 402 | `subscription_required` (the account has no active plan), `plan_limit_reached` (110% of your plan's credits are used), `watch_limit_reached` (your plan's active watches are all in use). See [credits](https://netscrapehq.com/docs/limits.md#credits). |
| 403 | `tenant_suspended`, `account_pending_approval` (your account was closed after review), `route_not_allowed`, `robots_required` (your account requires robots.txt checks and the request said `"robots": false`), `host_blocked` (the host has asked not to be read, or Netscrape refuses to read it) |
| 404 | `not_found` |
| 409 | `check_pending`, `watch_inactive`, `watch_retired`, `robots_disallowed`, `idempotency_conflict`, `job_finished`, `result_not_available` |
| 410 | `cursor_expired`, `result_expired` |
| 413 | The request body is over 16 KiB, or 2 MiB for a watch batch |
| 422 | `tenant_watch_limit_reached`: an account billed by agreement is at its active watch cap |
| 429 | `rate_limited`, `check_rate_limited`, `queue_full`; each sends `Retry-After` |
| 503 | `database_unavailable`, `result_storage_unavailable`; try again shortly |

## Watches

### The watch object

```json
{
  "id": "90a38653-a848-4a49-8634-055be25b3cde",
  "kind": "page",
  "external_id": "catalogue-home",
  "labels": ["catalogue"],
  "status": "active",
  "health": "healthy",
  "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:46:15.718997Z",
  "last_check_at": "2026-11-13T11:10:15.712792Z",
  "last_change_at": "2026-11-13T11:10:15.718997Z",
  "current": {
    "version": 2,
    "fingerprint": "282e4f317485b6200782eb438730a04231f2f08a11db8b8cf0a8b6a1a02b5b17",
    "compare_hash": "282e4f317485b6200782eb438730a04231f2f08a11db8b8cf0a8b6a1a02b5b17",
    "content_hash": "19fd9d6e67ef44bc6627596ef527d16ad2ef02439db44e7183a5b3a9ee76c103",
    "text_hash": "3e9a71c0d4b2f58e6a1c07d93b4f2e85a6c1d07b9e3f42a8d5c60b1e7f9a2d34",
    "values": {},
    "extract_empty": false,
    "job_id": "84994c2c-0502-4322-aaff-b468c2a463ca",
    "read_at": "2026-11-13T11:10:15.718997Z",
    "result_url": "/v1/jobs/84994c2c-0502-4322-aaff-b468c2a463ca/result",
    "result_expires_at": "2026-11-20T11:10:15.712792Z",
    "payload_expired": false
  },
  "pending_job_id": null,
  "noisy": false,
  "deliver_next": false,
  "emit_checks": false,
  "capabilities": ["deferred_confirmation"]
}
```

| Field | Meaning |
| --- | --- |
| `status` | `active`, `paused` or `retired`; yours to set. |
| `health` | `pending`, `healthy`, `failing`, `gone`, `blocked` or `robots_disallowed`. See [health states](https://netscrapehq.com/docs/watches.md#health-states). |
| `capabilities` | Behaviour this deployment supports that you may check for: `deferred_confirmation` (manual watches get no confirmation re-reads, `confirm_changes: false` makes none, and `watch.changed` carries `confirmed`). Also at the top of `GET /v1/watches` and in the `x-netscrape-capabilities` header. |
| `interval` | The interval scheduled reads aim for, in seconds. |
| `current` | The latest version, or `{}` before the first successful read. |
| `pending_job_id` | The job reading the page now, if any. |
| `noisy` | `true` while the page keeps flipping without a change holding. |
| `deliver_next` | `true` while the next scheduled read is marked as delivered. |

### Create or update a watch

`POST /v1/watches`

```http
POST /v1/watches
Authorization: Bearer <key>
Content-Type: application/json

{
  "external_id": "catalogue-home",
  "labels": ["catalogue"],
  "request": {"url": "https://example.com/catalogue", "render": "auto", "output": "document", "policy": {"robots": true}},
  "compare": {"on": "text", "confirm_changes": true},
  "freshness": {"max_age": "1d", "min_interval": "1h"}
}
```

| Field | Required | Meaning |
| --- | --- | --- |
| `request` | Yes | A [job request](https://netscrapehq.com/docs/jobs.md#parameters) to repeat. No `deadline`, GET only. |
| `freshness.max_age` | Yes | Seconds, or `"Nh"` / `"Nd"`. 1 hour to 90 days. |
| `freshness.min_interval` | No | At least 1 hour, at most `max_age`. Defaults to `max_age`. |
| `external_id` | No | Your id, 1–256 bytes. Repeating it updates that watch. |
| `labels` | No | Up to 50 strings of 1–256 bytes. |
| `compare` | No | `on` (`text`, `bytes`, `extract`), `confirm_changes`, `ignore`, `ignore_selectors`. See [comparisons](https://netscrapehq.com/docs/watches.md#comparisons). |
| `lifecycle` | No | Health thresholds; see [health states](https://netscrapehq.com/docs/watches.md#health-states). |
| `schedule` | No | `auto` (default) or `manual`. |
| `status` | No | `active` (default) or `paused`. |
| `emit_checks` | No | `true` sends `watch.checked` for every read. |
| `kind` | No | `page`, the only kind for now. |

Answers `201` with the [watch](#the-watch-object). Errors: `400 invalid_watch`,
`400 invalid_watch_request`, `400 unsupported_option`, `402` (see
[errors](#errors)), `403 route_not_allowed`, `403 robots_required`,
`403 host_blocked`.

### Create or update watches in a batch

`POST /v1/watches/batch`

```http
POST /v1/watches/batch
Authorization: Bearer <key>
Content-Type: application/json

{
  "watches": [
    {"external_id": "a", "request": {"url": "https://example.com/a"}, "freshness": {"max_age": "7d"}},
    {"external_id": "old", "retire": true},
    {"request": {"url": "https://example.com/b"}, "freshness": {"max_age": "7d"}}
  ]
}
```

Takes 1–500 entries, each with an `external_id`, in a body of up to 2 MiB.
`"retire": true` retires that entry's watch. Each entry succeeds or fails on its
own. Answers `200` with one result per entry, in order: the watch, or an error.

```json
{
  "data": [
    {"id": "7a5f2aaf-7c89-412e-9b04-a5595f5599d4", "external_id": "a", "status": "active", "health": "pending"},
    {"id": "1c9e8d7f-6a5b-4c3d-8e2f-1a0b9c8d7e6f", "external_id": "old", "status": "retired", "health": "healthy"},
    {"external_id": null, "error": {"code": "external_id_required"}}
  ]
}
```

Successful entries are full watch objects, shortened here. A malformed envelope
answers `400 invalid_batch`.

### List watches

`GET /v1/watches`

```http
GET /v1/watches?label=catalogue&health=failing&limit=100
Authorization: Bearer <key>
```

| Parameter | Meaning |
| --- | --- |
| `status`, `health`, `schedule`, `kind` | Exact match. |
| `label` | Watches that have this label. |
| `url_prefix` | Watches whose URL starts with this. |
| `changed_since` | Watches whose last change is at or after this ISO 8601 time. |
| `after` | The `next_cursor` from the previous page. |
| `limit` | 1–500, default 100. |

```json
{
  "data": [
    {"id": "90a38653-a848-4a49-8634-055be25b3cde", "external_id": "catalogue-home", "status": "active", "health": "failing"}
  ],
  "next_cursor": null,
  "capabilities": ["deferred_confirmation"]
}
```

Each item is a full watch object. Filters take single strings; an array such
as `label[]=a` answers `400 invalid_filter`.

### Get a watch

`GET /v1/watches/:id` answers `200` with the [watch](#the-watch-object),
including retired watches.

### Update a watch

`PATCH /v1/watches/:id`

```http
PATCH /v1/watches/90a38653-a848-4a49-8634-055be25b3cde
Authorization: Bearer <key>
Content-Type: application/json

{"compare": {"ignore_selectors": [".reviews"]}, "freshness": {"max_age": "12h", "min_interval": "1h"}}
```

Takes the same fields as create. Fields you leave out keep their values;
`request` replaces the request, `compare` and `lifecycle` merge. Changing the
request or comparison starts a new baseline. Answers `200` with the watch; a
retired watch answers `409 watch_retired`.

### Retire a watch

`DELETE /v1/watches/:id` answers `200` with the watch, now `retired`. It stays
readable for 90 days. Creating it again by `external_id` brings it back.

### Pause or resume a watch

`POST /v1/watches/:id/pause` and `POST /v1/watches/:id/resume` answer `200`
with the watch. A retired watch answers `409 watch_retired`.

### Pause or resume watches by label

```http
POST /v1/watches/pause
Authorization: Bearer <key>
Content-Type: application/json

{"label": "catalogue"}
```

`POST /v1/watches/resume` works the same way. `label` is required
(`400 label_required`); the other [list filters](#list-watches) narrow the
selection. Answers `200` with the number of watches that changed state:

```json
{"count": 12}
```

### Check a watch now

`POST /v1/watches/:id/check`

```http
POST /v1/watches/90a38653-a848-4a49-8634-055be25b3cde/check
Authorization: Bearer <key>
Content-Type: application/json

{"deliver": true}
```

Starts a read now. `deliver: true` makes it a delivered check, which always
ends in `watch.checked`. Answers `202` with the [job](#get-a-job).

| Error | When |
| --- | --- |
| `409 check_pending` | A read is already in flight |
| `409 watch_inactive` | The watch is paused or retired |
| `409 robots_disallowed` | robots.txt refuses the page |
| `429 check_rate_limited` | The last read was less than `min_interval` ago |
| `429 queue_full` | You have `max_pending_checks` reads waiting |
| `400 invalid_deliver` | `deliver` isn't `true` or `false` |
| `402 subscription_required`, `402 plan_limit_reached` | No active plan, or 110% of your credits used |

### Deliver the next read

`POST /v1/watches/:id/deliver_next` marks the next scheduled read as delivered,
at no extra cost. Answers `200` with the watch, `deliver_next: true`.

### Deliver the next read by label

```http
POST /v1/watches/deliver_next
Authorization: Bearer <key>
Content-Type: application/json

{"label": "catalogue"}
```

Marks every matching watch that isn't retired. `label` is required. Answers
`200 {"count": n}`.

### Resync watches

```http
POST /v1/watches/resync
Authorization: Bearer <key>
Content-Type: application/json

{"label": "catalogue", "changed_since": "2026-11-01T00:00:00Z"}
```

Asks for a delivered read of every matching watch as soon as each one's
`min_interval` and site budget allow. Both filters are optional; with neither,
every watch that isn't retired is resynced. Answers `202`:

```json
{"count": 240}
```

### Get the current version

`GET /v1/watches/:id/current` answers `200` with the watch's latest version, or
`{}` before the first successful read:

```json
{
  "version": 2,
  "fingerprint": "282e4f317485b6200782eb438730a04231f2f08a11db8b8cf0a8b6a1a02b5b17",
  "compare_hash": "282e4f317485b6200782eb438730a04231f2f08a11db8b8cf0a8b6a1a02b5b17",
  "content_hash": "19fd9d6e67ef44bc6627596ef527d16ad2ef02439db44e7183a5b3a9ee76c103",
  "text_hash": "3e9a71c0d4b2f58e6a1c07d93b4f2e85a6c1d07b9e3f42a8d5c60b1e7f9a2d34",
  "values": {},
  "extract_empty": false,
  "job_id": "84994c2c-0502-4322-aaff-b468c2a463ca",
  "read_at": "2026-11-13T11:10:15.718997Z",
  "result_url": "/v1/jobs/84994c2c-0502-4322-aaff-b468c2a463ca/result",
  "result_expires_at": "2026-11-20T11:10:15.712792Z",
  "payload_expired": false
}
```

`result_url` is the latest read of the page, refreshed by unchanged reads too,
and `null` once its body has expired.

### List checks

`GET /v1/watches/:id/checks?after=0&limit=100` lists the watch's reads, oldest
first. `after` is a check `number`.

```json
{
  "data": [
    {
      "id": "c14c8e51-de4d-464d-8e09-a044893b191a",
      "number": 1,
      "job_id": "45ef34a0-9648-4240-b752-b89368298eaf",
      "outcome": "changed",
      "delivered": true,
      "confirmation": false,
      "evidence": {
        "kind": "healthy",
        "reason": "http_200",
        "status": 200,
        "challenge": null,
        "robots_rule": null,
        "response_bytes": 48211,
        "execution_ms": 412,
        "browser_ms": 0,
        "network_requests": 2
      },
      "inserted_at": "2026-11-13T11:10:15.664934Z",
      "finished_at": "2026-11-13T11:10:15.689047Z"
    }
  ],
  "daily_unchanged": [{"day": "2026-10-02", "count": 1}],
  "next_cursor": null
}
```

`outcome` takes the values listed under
[watch.checked](https://netscrapehq.com/docs/events.md#watchchecked), or `pending` while the read runs.
After 30 days, unchanged and undelivered checks are folded into
`daily_unchanged` counts.

### List changes

`GET /v1/watches/:id/changes?limit=20` lists the watch's `watch.changed` events,
newest first. Pass `next_cursor` as `before` for the next page. History is kept
for the life of the watch, plus 90 days after it's retired.

```json
{
  "data": [
    {
      "id": "0a670d22-0010-4713-bd84-15105ca681a7",
      "sequence": 4,
      "type": "watch.changed",
      "at": "2026-11-14T08:46:15.718997Z",
      "watch": {"id": "90a38653-a848-4a49-8634-055be25b3cde", "external_id": "catalogue-home", "labels": ["catalogue"]},
      "before": {"version": 1, "fingerprint": "ffadfb575da1f4732d52d5102d136dab523f095d98c0ba400e808c61ed8ffcfe", "result_url": null, "payload_expired": true},
      "after": {"version": 2, "fingerprint": "282e4f317485b6200782eb438730a04231f2f08a11db8b8cf0a8b6a1a02b5b17", "result_url": "/v1/jobs/84994c2c-0502-4322-aaff-b468c2a463ca/result", "payload_expired": false},
      "diff": {"kind": "lines", "added": 2, "removed": 1, "hunks": [{"op": "del", "text": "Lamp B - 55"}, {"op": "ins", "text": "Lamp B - 60\nLamp C - 75"}], "truncated": false},
      "reversal": false,
      "earlier_version": null
    }
  ],
  "next_cursor": 4
}
```

Versions are shortened here; they have the same fields as
[the current version](#get-the-current-version).

## Events

### Read the event feed

`GET /v1/events`

```http
GET /v1/events?after=0&limit=100&types=watch.changed,watch.health_changed&label=catalogue
Authorization: Bearer <key>
```

| Parameter | Meaning |
| --- | --- |
| `after` | Events with a higher sequence; start at `0`. |
| `limit` | 1–500, default 100. |
| `types` | Comma-separated event types. |
| `label` | Events for watches with this label. |

```json
{
  "data": [
    {
      "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", "result_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf/result", "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
    }
  ],
  "next_cursor": 2,
  "has_more": false,
  "webhook_status": "healthy"
}
```

Store `next_cursor` after processing each page, even an empty one. A cursor
older than 30 days answers `410`:

```json
{"error": {"code": "cursor_expired"}, "next_cursor": 912}
```

See [the event feed](https://netscrapehq.com/docs/events.md#the-event-feed) and
[event types](https://netscrapehq.com/docs/events.md#event-types).

## Jobs

### Submit a job

`POST /v1/jobs`

```http
POST /v1/jobs
Authorization: Bearer <key>
Content-Type: application/json
Idempotency-Key: catalogue-2026-11-13

{"url": "https://example.com/catalogue", "render": "auto", "output": "document", "policy": {"robots": true}}
```

Parameters are listed under [Jobs](https://netscrapehq.com/docs/jobs.md#parameters). Add `"watch_id"` to
attach the job to a [manual watch](https://netscrapehq.com/docs/watches.md#manual-watches). Answers `202`
with the job and a `Location: /v1/jobs/:id` header. A matching job that's still
queued or running is returned instead of a new one.

| Error | When |
| --- | --- |
| `400 invalid_request` (or a more specific code) | The request isn't valid |
| `402 subscription_required`, `402 plan_limit_reached` | No active plan, or 110% of your credits used |
| `400 unsupported_option` | No worker can run an option you asked for |
| `409 idempotency_conflict` | The key was used with a different request |
| `429 queue_full` | 1,000 jobs are already pending; retry after `Retry-After` |

### Get a job

`GET /v1/jobs/:id`

```json
{
  "id": "45ef34a0-9648-4240-b752-b89368298eaf",
  "type": "scrape",
  "status": "succeeded",
  "url": "https://example.com/catalogue",
  "parent_id": null,
  "watch_id": "90a38653-a848-4a49-8634-055be25b3cde",
  "progress": {},
  "attempts": 1,
  "retries": 0,
  "error": null,
  "response_status": 200,
  "provider": "go",
  "engine": "go",
  "scheduled_at": "2026-11-13T11:10:15.664934Z",
  "started_at": "2026-11-13T11:10:15.684452Z",
  "finished_at": "2026-11-13T11:10:15.689047Z",
  "expires_at": "2026-11-14T11:10:15.664934Z",
  "lease_expires_at": null,
  "result_available": true,
  "result_expired": false,
  "result_expires_at": "2026-11-20T11:10:15.664934Z",
  "delete_at": "2027-02-11T11:10:15.664934Z",
  "result_bytes": 51840,
  "response_bytes": 48211,
  "execution_ms": 412,
  "browser_ms": 0,
  "network_requests": 2,
  "network_metered": true,
  "status_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf",
  "result_url": "/v1/jobs/45ef34a0-9648-4240-b752-b89368298eaf/result"
}
```

`status` is `queued`, `running`, `succeeded`, `failed` or `cancelled`. It's the
job's state, not the site's answer: that's `response_status`. Discovery jobs
also report `progress` counters.

### Get a job's result

`GET /v1/jobs/:id/result` answers `200` with the saved result; see
[results](https://netscrapehq.com/docs/jobs.md#results). The `X-Netscrape-Result-Status` header carries
the execution status.

| Error | When |
| --- | --- |
| `409 result_not_available` | The job hasn't saved a result |
| `410 result_expired` | The result is more than seven days old |
| `503 result_storage_unavailable` | Storage is briefly unavailable; retry |

### Cancel a job

`DELETE /v1/jobs/:id` cancels queued or running work and answers `200` with the
job. A finished job answers `409 job_finished`. Cancelling a running read is
best effort: a request already sent to the site may complete.

## Usage

### Get your usage

`GET /v1/usage` answers your [credits](https://netscrapehq.com/docs/limits.md#credits) for the current
UTC calendar month.

```json
{
  "period": {
    "label": "2026-11",
    "start": "2026-11-01T00:00:00Z",
    "end": "2026-12-01T00:00:00Z",
    "since": "2026-11-01T00:04:12.118377Z"
  },
  "credits": {"used": 12840, "limit": 100000, "remaining": 87160},
  "by_kind": {
    "page": {"count": 9340, "credits": 9340, "rate": 1},
    "browser_page": {"count": 700, "credits": 3500, "rate": 5}
  }
}
```

`period.since` is when the first credit of the month was charged, or `null`
with none yet. `credits.limit` and `credits.remaining` are `null` when your
account has no monthly limit. `?period=YYYY-MM` reads another month; a
malformed one answers `400 invalid_period`. The answer is never cached.
