> Source: https://vitna.ai/docs/web/endpoints
> Raw Markdown: https://vitna.ai/docs/web/endpoints.md
> Corpus index: https://vitna.ai/llms.txt

# Web data endpoints

Complete request and response contracts for Search, Reader and Scrape, Batch Scrape, Browser controls, Structured extraction, Extraction recipes, Site map, Crawl jobs, Change monitors, Screenshots and PDFs, Linked documents, Product and company data, Store catalogs, Careers, IR, Parse, Verify, Diff, Entity dossiers, Grids, Datasets, Firehose, and Research.

## Indexed search

```text
POST /v1/search
```

Search the local index with the same Web bearer key:

```json
{
  "query": "product pricing",
  "maxResults": 5,
  "domains": ["example.com"],
  "maxAgeDays": 30
}
```

`query` accepts 1 to 1,000 characters; `maxResults` defaults to 5 and accepts
1 to 20. Optional `index` targets `web` or a configured vertical index, and
optional `effort` (`fast`, `balanced`, `deep`) tunes native retrieval vs.
inline excerpt depth. Optional `domains` and `excludeDomains` filter public hostnames;
`maxAgeDays` accepts 1 to 3,650 and filters observed crawl age. Optional `asOf`
(or `contents.snapshotAsOf`, accepting `YYYY-MM-DD` or ISO 8601 with a UTC
offset) queries historical snapshots captured on or before that instant with
zero lookahead; it requires lexical ranking and cannot accompany live `scrape`.
`timeoutMs` accepts 1,000 to 60,000 milliseconds. Optional `contents` attaches stored
indexed text, `highlights`, or `excerpts` (with optional `maxTotalCharacters` /
`maxTotalTokens` and `injection` guard) in one native call without a live fetch.
The response contains `query`, ranked `results`, engine information, and
request `meta`. Titles, snippets, and crawl timestamps come from the indexed pages. By default,
search makes no live page fetch, and no matching indexed pages returns an empty
result list. See [Vitna Library](/library) on vitna.ai for the full catalog of
vertical indexes and native data sources.

To search and fetch each matching page in one call, set `scrape: true` or pass
a `scrape` object with `format`, `maxCharacters` (default 20,000, up to
100,000), `onlyMainContent`, `includeTags`, `excludeTags`, `render`, `waitFor`,
`timeoutMs`, `retries`, browser controls, `highlights`, `question`, `extract`,
`injection`, or `redact`. Each result then
carries a `scrape` object with `status: "ok"` and the page document, or
`status: "failed"` and the error code when that single URL could not be read.
When `scrape.highlights` is enabled without its own `query`, it defaults to the
search `query`. Each scraped hit counts against the client's page-attempt quota.

### Experimental local semantic ranking

Lexical retrieval remains the default. Operators can enable
`VITNA_WEB_SEARCH_SEMANTIC=true` on the native backend, then request
`ranking:"semantic"` on `POST /v1/search`. This fits a local TF-IDF/LSA
model over at most 128 currently enabled indexed documents, bounded to
300 title characters and 3,500 plaintext characters per document. It uses
eight retained dimensions by default and a cosine cutoff of 0.2. Training
and ranking use no external provider or model download.

The model learns associations within that bounded corpus. It abstains on
unobserved query terms and detected negation/exclusion. It cannot establish
every logical constraint or factual implication. Strict lexical admission
requires `ranking:"lexical"`; combining semantic ranking with strict mode
is rejected. Scores are latent cosine similarities, not probabilities.

Operator host scope restricts the training corpus. Domain, site and age
filters restrict returned IDs; the model still trains over the broader
allowed-host corpus. Source policy and current plaintext are rechecked
after asynchronous fitting, and a changed corpus makes the query abstain
instead of returning a stale passage. Content changes refresh the cached
fingerprint; timestamp-only refreshes need not retrain unchanged text.

Run the frozen authored evaluation locally:

```bash
npm run search:semantic
```

On its 32-document, 26-query synthetic fixture, default eight-dimensional
ranking raises held-out nDCG@5 from 0.566860 to 0.837790 and recall from
0.625000 to 1.000000. MRR falls from 0.916667 to 0.861111; negative accuracy
falls from 5/8 to 4/8. Exact-detail queries include regressions, and observed
cross-topic combinations still produce false positives. The frozen report
at `.search-data/reports/local-semantic.json` records all predeclared
dimensions and regressions. These measurements describe this authored
fixture, not broad web relevance or a general semantic model.

## Reader and scrape

```text
POST /v1/read
POST /v1/scrape
```

These routes are aliases. Read a page as Markdown, readable text, or cleaned
HTML. The reader prefers main/article content, removes page furniture and
scripts, and includes page metadata and links.

```json
{
  "url": "https://example.com/docs",
  "format": "markdown",
  "render": true,
  "waitFor": "main article",
  "timeoutMs": 30000,
  "maxCharacters": 50000
}
```

| Field | Default | Meaning |
|---|---|---|
| `url` | Required | Public HTTPS page, up to 4,096 characters |
| `format` | `markdown` | `markdown`, `text`, or `html` |
| `render` | `true` | `true` executes page JavaScript; `false` reads over pooled HTTP/2 without JavaScript; `"auto"` tries pooled HTTP/2 first (charging `pagesPerDay` only and `0` browser milliseconds on HTTP/2 hits) and escalates to a browser on SPA shells, blocks, or challenges |
| `waitFor` | Omitted | CSS selector for content readiness; requires rendering |
| `timeoutMs` | 30,000 | Request deadline, from 1,000 to 60,000 milliseconds |
| `maxCharacters` | 100,000 | Output limit, from 1 to 1,000,000 characters |
| `onlyMainContent` | `true` | Prefer `<main>`/`<article>` and omit `<nav>`/`<aside>` chrome; `false` reads the full `<body>` (still omitting scripts and styles) |
| `includeTags` | Omitted | 1 to 20 CSS selectors (up to 100 chars each); render only matching subtrees in document order |
| `excludeTags` | Omitted | 1 to 20 CSS selectors (up to 100 chars each); omit matching subtrees everywhere, including inside `includeTags` |
| `extract` | Omitted | `schema`, `selectors` and `prompt`, as for Structured extraction; adds `data` from the same render |
| `highlights` | Omitted | `true` or `{ query?, maxCharacters? }` (up to 4,000, default 1,000); returns verbatim `highlights` with `offsetUnit: "unicode_code_points"` |
| `question` | Omitted | A question (up to 1,000 characters) answered from the rendered page; returns `answer` and `answerEngine`. Runs locally on the native extractive model or on a configured language model |
| `injection` | Omitted | `scan` reports what could steer a model reading the page; `strip` also removes invisible characters from `content` (see below) |
| `redact` | Omitted | `true`, or a list of `email`, `phone`, `card`, `iban`, `ssn` and `ip`; takes personal data out of the response |

The HTML output is cleaned content, not the complete serialized browser DOM.
Use [Unblocker](../unblocker/overview.md) when the complete DOM is needed.
Truncated reader output is marked in the response. The configured service
deadline can be shorter than the requested deadline.

**Personal data.** `redact: true` takes email addresses, phone numbers,
payment card numbers, IBANs, US Social Security numbers and IPv4 addresses
out of the response, each replaced by a marker such as `[redacted:email]`. A
list such as `["email", "phone"]` takes only those kinds. The response's
`redacted` counts what was replaced, by kind, for example
`{ "email": 2, "phone": 1 }`. Redaction covers `content`, `title`,
`metadata.description`, `links` and extracted `data`, and `/v1/extract` and
`/v1/crawl` accept the same field. The content is redacted before it is cut to
`maxCharacters`, so a cut cannot leave half an address behind. A language model
reading the page for extraction is given the redacted text, and its answer is
redacted too, since a model can repeat what it has seen elsewhere. A page's own
address (`url`, and the `url` of a failed page in a crawl) is how a result is
matched to its page, so it stays as read. A crawl follows a page's links as the
page wrote them and returns them redacted. An address a page splits with
invisible characters, such as a zero-width space, is still found, and the
replacement takes the invisible characters with it, so `injection: "strip"`
cannot rejoin one. With `injection`, the findings' excerpts are redacted too:
they quote the page's hidden parts, which the content leaves out.

Each kind is found by its shape and a check, never by guessing:

| Kind | Found when |
|---|---|
| `email` | An address with a domain. Image names such as `logo@2x.png` and remotes such as `git@github.com:org/repo` are not addresses |
| `phone` | A number with `+` and a country code, 8 to 15 digits; a `tel:` link; or a North American number with its punctuation, such as `(212) 555-0147`, `212-555-0147` or `212.555.0147` |
| `card` | 13 to 19 digits, run together or in the usual groups, with the prefix and length of Visa, Mastercard, American Express, Diners Club, JCB, Discover or UnionPay, passing the Luhn check |
| `iban` | A country code, two check digits and up to 30 letters and digits, passing the mod-97 check |
| `ssn` | Three, two and four digits with dashes, never starting 000, 666 or 900 to 999, with no all-zero group |
| `ip` | Four numbers of at most 255. Loopback, multicast, reserved and documentation addresses are left, as are network blocks such as `10.0.0.0/8` and numbers after "Section", "§" or "version" |

**What redaction does not find.** Names, street addresses, dates of birth and
other personal data with no shape of its own; IPv6 addresses; Social Security
numbers without dashes; and phone numbers outside North America written
without their `+` country code. A page about one of these formats, such as an
article on IP addressing, has its examples redacted. A reference number that
passes a card's checks reads as a card, and its marker shows where. An
asynchronous extraction keeps the pages it has read in its restart checkpoint
until the job ends, with or without redaction.

### Documents

A URL that serves a PDF, Word (`.docx`), Excel (`.xlsx`) or PowerPoint
(`.pptx`) file is read as text, with no extra field. A document is recognised
by its content type, or, when the server sends a generic type such as
`application/octet-stream`, by its file name, and its first bytes must agree.
The same reading applies wherever a page is read: Scrape, Extract, Crawl,
Monitors and Research. A page that sends the browser on to a document, as a
cleared challenge page or a script redirect can, is read as that document.

| Kind | Output |
|---|---|
| PDF | A section per page, headed `Page N`, with each page's text in the order the page draws it |
| Word | Headings, paragraphs, bulleted lists, web links and tables |
| Excel | A table per sheet, headed `Sheet: name`; dates and times as their cell formats show them, in ISO 8601, and other numbers as stored |
| PowerPoint | A section per slide in the deck's order, headed `Slide N` and the slide's title |

The response's `metadata.document` describes the file: `kind`,
`contentType`, `filename`, `bytes`, and `pages`, `sheets` or `slides`, with
`truncated: true` when the document passed the reading limit of 1,000,000
characters. Pictures, charts, formulas, speaker notes and other formatting are
not read. Page controls (`waitFor`, `actions`) do not apply to a document, so
a crawl that sets them still reads the documents it links to. `/v1/screenshot`
and `/v1/pdf` capture what the browser shows and do not read documents.
[Linked documents](#linked-documents) downloads the files themselves.

| Code | HTTP | Meaning |
|---|---|---|
| `document_too_large` | 422 | The file exceeds 16 MiB |
| `document_invalid` | 422 | The bytes are not a readable file of the kind they claim |
| `document_encrypted` | 422 | The PDF is encrypted |
| `document_no_text` | 422 | The file has no text; a scanned PDF needs OCR, which is not available |
| `document_unreadable` | 422 | The file's text could not be read, for example a PDF whose fonts carry no map to letters |
| `document_timeout` | 504 | Reading did not finish within 20 seconds or the request deadline |

A document is requested twice: once by the browser, which is stopped as soon
as the response's headers show a document, and once to read it. A download
link that works only once fails on the second request.

**Prompt-injection scan.** Set `injection` to `scan` on `/v1/read`,
`/v1/scrape` or `/v1/crawl` to have each page checked for what could steer a
language model that reads it. The scan uses rules, not a model, so it costs
nothing beyond the read. It reports mechanisms and phrases, and does not judge
intent: a page that writes about prompt injection is reported, because it
holds the phrases.

| Finding | What it is |
|---|---|
| `unicode_tags` | Invisible tag characters spelling text a model can read; the finding shows what they spell. Flag emoji are not reported |
| `invisible_run`, `invisible_characters` | Four or more zero-width characters in a row, the shape of a hidden encoding, or sixteen or more in all. The joiners emoji, Indic and Persian text need are not reported |
| `bidi_override` | A right-to-left override that makes text display other than it reads |
| `ignore_instructions`, `new_instructions`, `role_token`, `system_prompt_probe`, `persona_shift`, `conceal_from_user`, `addressed_to_ai` | Instruction-like text, such as "ignore previous instructions", or the role tokens of a chat template, such as `im_start` and `[INST]` |
| `exfiltration_link` | A Markdown image whose address carries a placeholder for data to send out |

Each finding says where it was found (`text`, `characters`, `hidden_text`,
`comment`, `attribute` or `meta`), whether that text reaches the returned
`content` (`inContent`), its severity, and an excerpt. Hidden places include
elements the reader leaves out, comments, `alt`, `title`, `aria-label` and
meta descriptions, and text hidden by inline styles the reader keeps, such as
zero opacity or font size and off-screen positioning. Text hidden by a
stylesheet class is not seen.

```json
"injection": {
  "risk": "high",
  "findings": [
    { "kind": "unicode_tags", "severity": "high", "where": "characters", "inContent": true, "excerpt": "28 invisible tag characters spelling: ignore previous instructions" }
  ]
}
```

`risk` is the most serious finding that reaches the content, or `low` when
every finding sits where the content does not reach. `strip` removes tag
characters, zero-width characters and bidi controls from `content`, keeping
flag emoji and joiners, and reports how many it removed as `stripped`. It
never rewrites visible text. Whatever a request asks, those characters are
removed from everything Vitna's own language model reads.

### Batch scrape

```text
POST /v1/batch
```

Scrape a known list of public HTTPS URLs with shared reader, browser, action,
extraction, highlight, question, injection, and redaction options.

```json
{
  "urls": [
    "https://example.com/pricing",
    "https://example.com/security"
  ],
  "format": "markdown",
  "maxCharacters": 20000,
  "highlights": { "query": "SOC 2", "maxCharacters": 800 },
  "extract": { "selectors": { "heading": "h1" } }
}
```

Synchronous requests accept 1 to 20 URLs and answer `200` with `urls`, `pages`,
`errors`, `counts` (`total`, `completed`, `failed`), `truncated`, and `meta`.
Pass `async: true` to run up to 100 URLs as a background task (`202`), polled
with `GET /v1/jobs/:id`, cancelled with `DELETE /v1/jobs/:id`, and optionally
delivered to `webhookUrl`. `maxCharacters` defaults to 20,000 per page (up to
100,000), and `retries` defaults to `0`.

Each URL is isolated: a page that fails to render or extract is recorded in
`errors` (or `extractError` / `answerError` when reading succeeded) without
aborting the rest of the batch. Background batch jobs checkpoint after every
URL and recover across restarts, recording an in-flight ambiguous URL as
`outcome_unknown` rather than repeating work twice. Result payloads respect the
job byte budget and set `truncated: true` if remaining pages would exceed it.

## Browser controls

Page-reading requests also accept these options:

```json
{
  "url": "https://example.com/",
  "country": "US",
  "session": "product-run-01",
  "language": "en-US",
  "viewport": { "width": 1440, "height": 960 },
  "headers": { "dnt": "1" }
}
```

| Field | Meaning |
|---|---|
| `country` | Two uppercase letters selecting a configured proxy route that serves that country |
| `network` | `auto` (the default) starts on the cheapest configured route and steps up a tier after a block; `datacenter`, `isp`, or `residential` uses only routes of that kind |
| `session` | 1 to 64 letters, numbers, underscores, or hyphens; sticky proxy selection |
| `persistSession` | Explicit boolean; `true` requires `session` and retains tenant-isolated cookies/localStorage |
| `actions` | Up to 50 scroll, wait, click, write or press actions; requires rendering (`render: true` or `"auto"`). Bounds, the GET-only guard and failed-step reporting (`error.action`) are under Browser actions in the [Unblocker request reference](../unblocker/overview.md#request). `/v1/read` and `/v1/scrape` also take screenshot and scrape steps, below |
| `allowFormPost` | Explicit boolean (default `false`); permits up to 10 bounded same-origin form or fetch POST requests (at most 128 KiB each) strictly while executing `actions`; requires non-empty `actions` and `render !== false` |
| `language` | BCP 47 locale, such as `en-US`, up to 35 characters; defaults coherently from `country` when omitted |
| `viewport` | Width from 320 to 4,096; height from 240 to 4,096 |
| `headers` | Only `accept-language` up to 200 ASCII characters and `dnt` equal to `0` or `1` |

A country request needs a matching route configured by the operator. An
unavailable country fails explicitly, as does a `network` with no route of
that kind (`network_unavailable`). When the operator configures residential
or ISP provider routes, a blocked attempt's retry moves up a tier, and the
bytes an attempt moves through those routes are metered for pricing; see
[proxy routes](../unblocker/overview.md#proxy-routes). When the operator runs
the [auto browser profile](../unblocker/overview.md#the-auto-profile), a
challenged attempt's retry also moves from Chromium to Camoufox, so a page
behind a browser check can still be read with the default `retries`. So can
a [document](#documents): Camoufox takes the file from the response to the
navigation that cleared the check, so `/v1/read` and each file
[`/v1/documents`](#linked-documents) downloads return it with the same 16 MiB
limit and first-bytes check, and without asking for it a second time. A
document Camoufox still cannot hand over, such as one whose bytes are not the
file they claim to be, fails as the `target_challenge` that sent the read to
Camoufox.
A session keeps route selection
deterministic while the route list stays unchanged. Every attempt still
uses a fresh browser/context. With explicit `persistSession: true`, the
renderer restores and saves that tenant's cookies and localStorage after
successful delivery and cleanup. State stays in RAM with a 15-minute sliding
TTL, 100 total sessions, 20 per tenant, and 256 KiB per session. It is lost on
renderer restart. Same-session concurrent persistence returns `session_busy`.
`DELETE /v1/sessions/SESSION_ID` clears the caller's session and cancels its
active attempt. The caller cannot submit proxy credentials, cookies,
authorization headers, or browser scripts.

**Screenshot and scrape steps.** On `/v1/read` and `/v1/scrape`, an action
sequence can capture the page partway through: `{ "type": "screenshot" }`
images what the page shows at that step, and `{ "type": "scrape" }` reads it.
A list paged by a button reads as one request:

```json
{
  "url": "https://example.com/filings",
  "actions": [
    { "type": "scrape" },
    { "type": "click", "selector": "button.next" },
    { "type": "scrape" },
    { "type": "screenshot", "fullPage": true }
  ]
}
```

The response's `content` is the page after the last step, as always, and
`actions` holds the captures, each with the `index` of the step that took it:

```json
{
  "actions": {
    "screenshots": [{ "index": 3, "contentType": "image/png", "base64": "iVBORw0KGgo...", "bytes": 48213 }],
    "scrapes": [
      { "index": 0, "url": "https://example.com/filings", "title": "Filings", "format": "markdown", "content": "# Filings ...", "links": ["https://example.com/filings?page=2"], "truncated": false },
      { "index": 2, "url": "https://example.com/filings?page=2", "title": "Filings", "format": "markdown", "content": "# Filings ...", "links": [], "truncated": false }
    ]
  }
}
```

A step waits for the page's text to settle before it captures, as the final
read does, so a scrape after a click takes the next page rather than the one
before it. Scraped pages use the request's `format` and `maxCharacters`. A
screenshot shows the viewport unless `fullPage` is `true`, and is a PNG unless
`format` is `jpeg`. A sequence may hold 10 screenshot and scrape steps, which
together may capture 8 MiB (images, and the HTML of scraped pages). A step
past that budget, or a full-page image larger than 16,384 pixels on a side or
32 million pixels in all, fails with `action_output_too_large` (HTTP 422) and
names itself in `error.action`. Other routes, crawls included, refuse these
steps, and `/v1/status` lists them under `capabilities.actionOutputs`.
A scraped page is treated as the final one is: with `injection` it carries its
own `injection` report, and with `redact` its personal data comes out and is
counted in the response's one `redacted`. A screenshot is an image, which
neither the scan nor redaction reads.

Without `waitFor`, the browser allows an initial 500-millisecond grace
period, then waits for 200 milliseconds of stable meaningful visible content,
within five seconds or the remaining request deadline. A persistent empty
or loading state fails with `target_incomplete`. Set a populated content
selector for delayed applications; page stability cannot establish that
every requested product field has finished loading. A `waitFor` selector
that never becomes visible fails with `selector_timeout` (HTTP 504) shortly
before the deadline rather than `request_timeout`, and a retry waits within
what is left of `timeoutMs`.

### Encrypted sessions across restarts

Session state remains in RAM by default. For local browsers, pair
`VITNA_WEB_SESSION_DATA` with `VITNA_WEB_SESSION_KEY_HEX`, an exact 32-byte
hexadecimal operator key. Use a separate private directory from
`VITNA_WEB_DATA`; with the supplied systemd unit it can be
`/var/lib/vitna-web-sessions`. Requests still need a named session and
`persistSession:true`. Browser-worker deployments configure persistence
on each worker instead of the API coordinator.

Cookies and local storage are encrypted using AES-256-GCM with fresh
nonces and authenticated tenant/session identity, expiry and byte bounds.
The same stable key restores unexpired sessions after restart. A wrong key
fails closed and preserves the prior database. A key that opens some rows
but not others is the right key with damaged rows: each damaged row is set
aside unchanged for inspection and counted, and the other sessions open
normally. After startup a damaged row affects only its own session, which
its owner can delete. TTL,
per-client/global capacity, successful-state commit and explicit deletion
continue to apply to durable rows. Deletion cannot be undone by a stale
active lease. Renderer shutdown retains ciphertext and closes storage only
after physical browser cleanup settles.

The helper rejects directory/data-file links and database hardlinks that
could bypass the writer lock. Existing POSIX storage must belong to the
service user and grant no group/other access. Windows deployments must
configure equivalent private ACLs. Session keys are operator secrets;
back up the key separately from a consistent stopped-service database
backup. Key rotation and replicated session storage are not implemented.

## Structured extraction

```text
POST /v1/extract
```

Provide CSS selectors for known fields. A string selector reads text; an
object with `attribute` reads an attribute from matching elements. This
path runs locally without a model. Supply up to 32 selector fields. Supported
syntax includes tags, IDs, classes, attribute matches, descendant and child
combinators, and comma-separated groups. A supplied selector scopes its field;
a missing match is not replaced with an unrelated structured-data value.

```json
{
  "url": "https://example.com/products/desk",
  "selectors": {
    "name": "h1",
    "price": ".price",
    "image": { "selector": "img.product", "attribute": "src" }
  }
}
```

To shape published structured data, provide a supported JSON Schema.
Extraction reads JSON-LD, microdata/RDFa, supported embedded application data,
and any supplied selectors. Canonical URLs, explicit primary-entity references,
product identifiers, and visible headings help select the page's company or
product. An unresolved choice between multiple entities returns
`extraction_ambiguous` (HTTP 422); explicit selectors can select the intended
fields. Schema fields can use object, array, string, number,
integer, and boolean types, including nullable unions with `null`.
Supported keywords include `properties`, `required`, `items`, `enum`,
`additionalProperties`, `description`, and `title`.

```json
{
  "url": "https://example.com/products/desk",
  "schema": {
    "type": "object",
    "properties": {
      "name": { "type": "string" },
      "price": { "type": ["number", "null"] },
      "currency": { "type": ["string", "null"] }
    },
    "required": ["name", "price", "currency"],
    "additionalProperties": false
  }
}
```

Missing fields use the same bounded observed-fact parser as native Research.
It recognizes explicit JSON objects, labelled literals, dotted/indexed fields,
two-column tables, definition lists, and a finite set of unambiguous prose
facts, including named company founding dates, exact employee counts,
headquarters, and product prices/weights. It preserves the source wording,
units, currencies, billing periods, and ranges internally. A measured value
such as `2 kg` needs a string field; it is not reduced to the number `2`.
The symbol `$` alone does not establish the currency code `USD`.

The parser rejects conflicting requested observations with
`extraction_ambiguous` (HTTP 422). Missing required fields return
`extraction_incomplete`; invalid extracted values return `extraction_invalid`,
also HTTP 422. If the configured native engine is called for remaining fields,
its unsupported or conflicting observations return
`native_extraction_unsupported` or `native_ambiguous_data`. An optional
self-hosted compatible model can handle language-based fields beyond these
rules. The final result must satisfy the schema, including nested objects,
arrays, required fields, and enums. Schema responses include configured engine
metadata in `extractionEngine`; extracted `data` follows the requested schema.

**Extract with a prompt.** Add `prompt`, up to 10,000 characters, to tell the
model what to extract in plain language. With a schema, the prompt guides how
the model fills it; without one, the model's JSON object is the data:

```json
{
  "url": "https://example.com/investors/governance",
  "prompt": "List every board member with their role and the committees they chair."
}
```

A prompt needs a language model (`VITNA_WEB_MODEL_BACKEND=self-hosted`); the
native engine returns `model_not_configured` (HTTP 503) rather than ignoring
it, and `/v1/status` reports `capabilities.promptExtraction`. With a prompt,
the model reads every field that no selector names, because published data
cannot follow an instruction such as "prices in euros". Without one, published
data, selectors and observed facts come first and the model fills only what
they miss. A prompt cannot accompany a recipe, and selectors with a prompt
need a schema that declares their fields.

**Long pages and repairs.** A language model reads the page in parts of 60,000
characters, cut at paragraph breaks, at most eight of them; each part is a
metered model request. The answers combine in page order: a list gathers
values from every part without repeats, and a single value is the first a part
established. An answer that does not match the schema is sent back once with
the problem named before the request fails with `extraction_invalid`. A
response that used a language model reports how it read the page:

```json
"extraction": { "parts": 3, "truncated": false, "repaired": 0 }
```

`truncated` means the text ran past eight parts. Data from a prompt without a
schema is limited to 1 MiB (`extraction_too_large`) and 32 levels of nesting.
The native engine reads a single pass, as before, since it refuses
observations that conflict and must see them together.

**Personal data.** With `redact`, as described under
[Reader and scrape](#reader-and-scrape), a language model reads the pages with
the named kinds already taken out, every string in `data` (and in `rows`) is
redacted as well, and the response's `redacted` counts what came out of them.

**Scrape and extract in one request.** `/v1/read` and `/v1/scrape` accept an
`extract` object with `schema`, `selectors` and `prompt`, under the same rules.
The response carries the page's `content` and the extracted `data` from one
browser render:

```json
{
  "url": "https://example.com/products/desk",
  "format": "markdown",
  "extract": { "prompt": "The price in euros and whether it is in stock" }
}
```

### Extract across pages

Supply `urls` instead of `url` to combine up to 20 pages into one result:

```json
{
  "urls": ["https://example.com/about", "https://example.com/contact"],
  "schema": {
    "type": "object",
    "properties": {
      "name": { "type": "string" },
      "foundingDate": { "type": "string" },
      "employees": { "type": "integer" }
    },
    "required": ["name"],
    "additionalProperties": false
  },
  "async": true,
  "jobTimeoutMs": 120000
}
```

For site discovery, provide `url` and `maxPages`, up to 20, with the map
discovery and path-filter options below. The default extraction page budget
is 1. Arrays are combined without duplicate values; scalar fields use the
first valid local value, and compatible nested objects can fill complementary
fields. Flat product extraction combines pages only when their selected
products have matching identity; one product's name cannot borrow another's
price. Use an object array such as `products` for multiple product pages.
Conflicting requested prose observations remain an error. Observed-fact
parsing and the optional model fallback use at most 100,000 combined content
characters. The parser also bounds source count, nesting, arrays, and fact
count; it does not read every page of a domain automatically.

The result includes `url`, successfully read `urls`, combined `data`, and
per-page `errors`. With `async: true`, the response is a job receipt instead.
Poll `/v1/jobs/:id` for progress and the final result. `jobTimeoutMs` accepts
1,000 to 600,000 milliseconds for background work; `timeoutMs` remains the
per-page browser deadline. An optional `webhookUrl` can receive a job
completion notification. Fetch the result from the job endpoint.

## Extraction recipes

```text
POST /v1/recipes/draft
POST /v1/recipes
GET /v1/recipes
GET /v1/recipes/:id
DELETE /v1/recipes/:id
```

A recipe names the fields to read from one kind of page, and how to read
each, once, so every page built from the same template can be extracted or
watched by its id. A draft builds one from examples: name a sample page and,
for each field, its value as the page shows it.

```json
{
  "url": "https://shop.example.com/products/desk-lamp",
  "samples": ["https://shop.example.com/products/office-chair"],
  "fields": {
    "name": "Desk Lamp",
    "price": "$24.99",
    "image": { "example": "https://shop.example.com/img/lamp.jpg", "attribute": "src" },
    "reviews": { "examples": ["Great lamp", "Too bright"] },
    "sku": { "describe": "the product's SKU" }
  }
}
```

| Field form | Meaning |
|---|---|
| `"value"` or `{ "example": "value" }` | Text the page shows, matched regardless of case and spacing; an element whose text closely contains it also matches |
| `{ "examples": ["a", "b"] }` | Two to 20 values of one repeated field, which becomes a list |
| `{ "example": "value", "list": true }` | One value of a repeated field |
| `{ "example": "value", "attribute": "src" }` | An attribute's value rather than text. Without `attribute`, an example not found as text is looked for in `content`, `src`, `href`, `datetime`, `value`, `alt`, `title` and `data-src`, and a relative URL matches its absolute form |
| `{ "describe": "words" }` | No example: extraction finds the value from published data, observed facts and the operator's model when one is configured, and that value becomes the example |

The draft renders the pages with the request's browser controls, finds the
element holding each example in text a reader sees, never under a hidden
ancestor, and keeps the selector that reaches it most steadily. An id comes
first, then `itemprop`, `data-testid` and similar attributes, then classes,
then a class or tag scoped by a named ancestor. Generated class names such as
`css-1x2y3z` or `Button_label__a8Kq3` are never used. A single field's
selector must reach the example before anything else, because extraction
keeps the first match; a list field's must reach every example. Each
candidate is run on the page before it is chosen. The selector engine has no
positions, so an element told from its siblings only by position gets no
selector.

The response gives each field its `selector`, `attribute` and `list`, with
`basis` (`id`, `attribute`, `class`, `scoped` or `tag`), the number of
elements it `matches`, and whether the example matched as `text`, by
`contains` or as an `attribute`. A field without a selector gives its
`reason`: `example_not_found`, `examples_disagree`, `no_stable_selector` or,
for a description, `value_not_found`. A described field's value is returned as
`described`. `recipe.fields` is ready to save, and `preview` reads every page
with the recipe:

```json
{
  "preview": [
    { "url": "https://shop.example.com/products/desk-lamp", "data": { "name": "Desk Lamp", "price": "$24.99", "reviews": ["Great lamp", "Too bright", "Works fine"] }, "missing": [] },
    { "url": "https://shop.example.com/products/office-chair", "data": { "name": "Office Chair", "price": "$89.00" }, "missing": ["reviews"] }
  ]
}
```

This preview is illustrative. A draft is one request, and it reads the
sample page and up to three `samples` through the same browser slots, page
quota and accounting as any read. A sample that cannot be read appears in the
preview with its error code; a first page that cannot be read fails the
draft.

Save a recipe with a `name`, its `fields`, and optionally `render` and
`waitFor`. Each field is a selector string, or an object with `selector`,
`attribute`, `list` and `describe`, of which a selector or a description is
required. A draft's `recipe.fields` can be sent as returned. A selector the
engine cannot parse is refused when the recipe is saved. A key holds up to 50
recipes of up to 32 fields each, and only that key can read, run or delete
them.

Run one by sending `recipe` in place of `schema` and `selectors`:

```json
{
  "urls": ["https://shop.example.com/products/desk-lamp", "https://shop.example.com/products/office-chair"],
  "recipe": "RECIPE_ID"
}
```

A recipe run adds `rows`, one `{ "url", "data" }` per page read, beside the
combined `data`; a page whose own extraction fails keeps its row with an
`error` code. A described field without a selector is found by extraction on
each page. The recipe's `render` and `waitFor` are defaults that the request's
own values override. `POST /v1/monitors` with `recipe` watches the recipe's
selected fields; a recipe with none is refused with `recipe_unmonitorable`.
An unknown or another key's recipe is `recipe_not_found` (404), and a key at
its limit is `recipe_limit` (429).

## Site map

```text
POST /v1/map
```

Discover links, sitemap entries, and indexed search results. Include and
exclude filters match case-sensitive pathname substrings, and excludes take
priority. Discovery defaults to the starting hostname. Additional domains
must be explicitly allowed.

```json
{
  "url": "https://example.com/",
  "maxPages": 100,
  "maxBreadth": 100,
  "sitemap": "include",
  "maxSitemaps": 3,
  "includePaths": ["/products/"],
  "excludePaths": ["/account/"],
  "timeoutMs": 30000
}
```

The default `maxPages` is 50, with a maximum of 1,000 for maps. Filters can
contain up to 20 paths per list. The seed page can be read to discover links
even when it does not match an include filter. The response reports
discovery counts and errors in addition to the URLs.

| Field | Default | Meaning |
|---|---|---|
| `maxDepth` | 20 for maps; 2 for crawls | Link depth from the seed, from 0 to 20 |
| `maxBreadth` | 100 | Maximum discovery breadth, from 1 to 1,000 |
| `pathMatch` | `substring` | `substring` (case-sensitive pathname substring) or `regex` (regular expression matching on `URL.pathname`) |
| `crawlEntireDomain` | `true` | Follow links anywhere on the starting host (`true`), or restrict same-host links to the starting URL path prefix (`false`) |
| `sitemap` | `skip` | `skip`, `include`, or `only` |
| `sitemapUrls` | Omitted | Up to 5 explicit public HTTPS sitemap URLs |
| `maxSitemaps` | 3 | Sitemap document budget, from 1 to 10 |
| `searchQuery` | Omitted | Optional discovery query, up to 500 characters; uses the selected indexed Search backend |
| `searchLimit` | 20 | Search-result budget, from 1 to 100 |
| `includeSubdomains` | `false` | Allow public subdomains of the starting host |
| `allowedDomains` | `[]` | Up to 20 explicitly allowed public hostnames |
| `maxConcurrency` | `1` for crawls; up to `4` for maps | Concurrent page reads within the crawl or map (1 to 64). Concurrent crawls batch checkpoints and record in-flight URLs for restart recovery. Explicit `render: false` crawls run on a separate static HTTP/2 pool rather than queueing behind browser slots |
| `delayMs` | Omitted | Optional polite delay between requests (0 to 30,000 ms; forces concurrency to 1 when positive) |
| `respectRobotsTxt` | `false` | Fetch and honor the host's `/robots.txt` `Allow`/`Disallow` and `Crawl-delay` rules for `VitnaWeb`, reporting blocked URLs in `discovery.robotsBlocked` |
| `render` | `true` | `true` renders in a browser, `false` reads over pooled HTTP/2 without JS, `"auto"` tries HTTP/2 first and escalates to Chromium on JS shells or blocks |

For example, add `searchQuery: "site:example.com products"` to discover
pages through the selected indexed Search backend. Search results and sitemap
entries pass the same destination checks, host scope, and path filters as
links found on a page. `sitemap: "only"` uses sitemap discovery without a
full link walk. A map request remains bounded by its total `timeoutMs`, and
by the service's request deadline when that is shorter. A map that runs out of
time, by either deadline, fails with `crawl_timeout` (HTTP 504); only a caller
that disconnects ends one with `request_cancelled`.

## Crawl jobs

```text
POST /v1/crawl
GET /v1/jobs/:id
DELETE /v1/jobs/:id
```

Collect cleaned pages in a background job:

```json
{
  "url": "https://example.com/docs/",
  "maxPages": 100,
  "maxDepth": 4,
  "maxBreadth": 100,
  "format": "markdown",
  "includePaths": ["/docs/"],
  "excludePaths": [],
  "timeoutMs": 30000,
  "jobTimeoutMs": 120000
}
```

The create response includes a job `id`, `status`, `pages`, and `errors`.
Poll `GET /v1/jobs/:id` using the same client key to retrieve progress and
collected pages. `DELETE` cancels queued or running work.

The default page budget is 50 and the default depth is 2 links from the
seed. The supported depth is 0 to 20; the page budget is 1 to 500. A page
budget bounds attempted reads, while `maxCharacters` bounds each collected
document. `timeoutMs` bounds each browser read. `jobTimeoutMs` bounds the
whole background job, from 1,000 to 600,000 milliseconds, and defaults to
`timeoutMs` when omitted. Partial page failures appear in `errors`.

`redact` takes personal data out of every collected page before the job
stores it, with a `redacted` count on each page, as described under
[Reader and scrape](#reader-and-scrape). Crawls also accept `extract`,
`highlights`, and `question` to run per-page structured extraction, passage
selection, or page-grounded Q&A during the crawl; if extraction or Q&A fails on
one page, that page keeps its content and records `extractError` or
`answerError` while the crawl continues.

Crawls accept the same sitemap, search, domain, and path controls as maps.
Retrieve a bounded slice of crawl results with query parameters:

```text
GET /v1/jobs/JOB_ID?offset=0&limit=25&includeContent=false
```

`offset` accepts 0 to 500, `limit` accepts 1 to 100, and `includeContent`
chooses whether page content accompanies the page metadata. The response
includes `pagination` with `offset`, `limit`, `total`, and `nextOffset`.

Each job also caps returned content at two million characters and five MiB
of serialized pages/errors. When that budget is reached, completed pages
remain available and the job reports `truncated: true` with
`truncationReason: "result_limit"`. Up to 20 jobs per client are retained;
older finished jobs are removed to admit new work. Queued jobs recover after
restart. Crawl resumes its committed frontier and extraction resumes committed
page snapshots; unresolved page attempts are recorded as `outcome_unknown`
and skipped. An ambiguous final model invocation, running Research jobs, and
running catalog and backfill jobs remain failed rather than repeating metered
work. Recovery preserves the
original absolute deadline, backs off, and permits at most three restarts.
Extraction checkpoints share the five-MiB result bound; oversized checkpoints
fail explicitly. Recovery metadata is public, while its snapshots and intents
remain private. These leases are single-writer restart bookkeeping.

Jobs and monitors belong to the client identity associated with the key.
A different client cannot inspect or cancel them.

## Change monitors

```text
POST /v1/monitors
GET /v1/monitors
GET /v1/monitors/:id
DELETE /v1/monitors/:id
POST /v1/monitors/:id/check
```

Watch readable page text, or selected fields, on an interval. Supply a
public HTTPS webhook to receive changes:

```json
{
  "url": "https://example.com/products/desk",
  "intervalSeconds": 3600,
  "selectors": { "price": ".price", "availability": ".availability" },
  "webhookUrl": "https://your-app.example/webhooks/vitna"
}
```

The interval defaults to 3,600 seconds and accepts 60 seconds to 30 days.
The first successful check establishes a baseline. Subsequent checks compare
normalized text or selector values. A missing field can be a change; it is
not treated as a price of zero.

To score changes structurally instead of flat text diffs, pass `diffMode`
(`prose`, `pricing`, `policy`, or `risk_factors`) and optional
`minMateriality` (`0` to `1`). When the computed structural materiality score
falls below `minMateriality`, the monitor records a `below_materiality`
suppression entry, skips webhook delivery, and preserves its baseline; when
it meets or exceeds the threshold, the event carries typed hunks, numeric
deltas, and a SHA-256 `diff.attestation` digest.

To suppress minor noise on a page monitor, set `meaningfulChange: true`
(default 5% changed-token ratio), `{ "minChangedRatio": 0.1 }`, or
`{ "prompt": "..." }` (requires a configured language model). When a change is
judged not meaningful, the monitor records a `suppressed` reason in history,
sends no webhook, and keeps the previous baseline intact so gradual drift still
crosses the threshold.

To watch search results for a query instead of a single URL, create a web
monitor with `kind: "web"` (or omit `url` and pass `query`), along with
optional `maxResults` (1 to 20, default 10), `domains`, `excludeDomains`,
`ranking`, `goal`, `dedup` (`"story"` default or `"url"`), `maxAgeDays` (1 to
3,650), `minSnippetCharacters` (1 to 1,000), `summarize` (`true` for cited
bullet summaries), and `schema` (for cited structured event payloads):

```json
{
  "kind": "web",
  "query": "vitna release notes",
  "domains": ["example.com"],
  "goal": "pricing change or new enterprise plan",
  "dedup": "story",
  "maxAgeDays": 14,
  "summarize": true,
  "intervalSeconds": 3600,
  "webhookUrl": "https://your-app.example/webhooks/vitna"
}
```

Web monitors report `added` and `removed` result URLs against the previous
snapshot. With `dedup: "story"`, syndicated reprints with matching canonical URLs,
normalized headlines, or 3-word shingle Jaccard similarity at or above 0.6 are
suppressed across up to 200 seen stories without firing webhooks (`suppressedCount`
is recorded in check history). When `goal` is set, alerts fire only when a newly
added result matches the goal (judged by the configured language model when available,
or deterministically by query-term match otherwise). Setting `summarize: true` or
`schema` attaches cited `summary`, `data`, and `citations` fields to `monitor.changed`.

List or inspect monitors to see their current snapshot, recent changes,
check times, and webhook delivery state. The manual `/check` route takes
an empty JSON object and runs a check immediately. `DELETE` stops the
monitor. Scheduling requires the service process to remain running.

Readiness selectors and retry settings are saved with each monitor. History
is bounded to 20 checks. Webhook failures retain the same event ID across
up to five delivery attempts. An event that fails all five leaves the
queue, so a later successful delivery reports `delivered` again; the loss
stays visible as `webhook.failedEvents`, a running count, and
`webhook.lastFailure`, which names the event, its attempts and the last
error.

## Screenshots and PDFs

```text
POST /v1/screenshot
POST /v1/pdf
```

Capture a browser view:

```json
{
  "url": "https://example.com/",
  "format": "png",
  "fullPage": true,
  "width": 1440,
  "height": 960
}
```

Screenshots support `png` and `jpeg`. The default viewport is 1,440 by 960
pixels; width accepts 320 to 4,096 and height accepts 240 to 4,096. PDFs
use Chromium print output and need only a URL for the default layout. On
`/v1/pdf`, you can also bound long pages with `pageRanges` (page numbers or
ranges between 1 and 1,000, such as `"1-3"` or `"1-2,5"`), `scale` (`0.1`
to `2`), and `printBackground` (boolean, default `true`) to keep artifacts
under the 10 MiB capture limit:

```json
{
  "url": "https://example.com/",
  "pageRanges": "1-2",
  "scale": 0.75,
  "printBackground": false
}
```

Both routes return an artifact in a JSON envelope:

```json
{
  "artifact": {
    "contentType": "image/png",
    "base64": "BASE64_ENCODED_BYTES",
    "bytes": 12345
  }
}
```

This envelope is illustrative. Decode `base64` into bytes and save them with
the returned content type. The playground provides a download button for
live artifacts.

## Linked documents

```text
POST /v1/documents
```

Download the PDFs a page links to, as the files they are:

```json
{ "url": "https://investors.example.com/financials", "maxFiles": 10 }
```

The page is read in the browser, as for Read, and every document link on it
is listed. A link counts when its path ends in `.pdf` or its `type` attribute
is `application/pdf`; a link whose text, title, label or class says "PDF"
("Annual report (PDF, 2 MB)") counts too and is listed after those, since it
can lead to a page rather than a file. Links in embedded viewers (`iframe`,
`embed`, `object`) count, fragments are dropped, and a link back to the page
itself does not count. Each file is then fetched through the same browser and
network path as the page, with its `country`, `session`, `network` and
`language`, so a site that serves the page to the browser serves its files
too. A `url` that is itself a document is the one file.

| Field | Default | Meaning |
|---|---|---|
| `kinds` | `["pdf"]` | Which documents to find: any of `pdf`, `docx`, `xlsx`, `pptx` |
| `maxFiles` | 10 | How many of the listed links to download, 1 to 20, in the order listed |
| `download` | true | false lists the links without downloading any |
| `timeoutMs` | 30,000 | The whole request's deadline, the page and every file together |

The browser fields (`render`, `waitFor`, `actions`, `country`, `session` and
the rest of [Browser controls](#browser-controls)) apply to the page; files
take its network and identity but not its `waitFor` or `actions`.

```json
{
  "url": "https://investors.example.com/financials",
  "found": [
    { "url": "https://cdn.example.com/2025-annual-report.pdf", "text": "2025 Annual Report" },
    { "url": "https://investors.example.com/static-files/0f1c", "text": "Q3 results (PDF)" }
  ],
  "documents": [
    {
      "url": "https://cdn.example.com/2025-annual-report.pdf",
      "text": "2025 Annual Report",
      "kind": "pdf",
      "contentType": "application/pdf",
      "filename": "2025-annual-report.pdf",
      "bytes": 2481503,
      "sha256": "9f2c...",
      "base64": "JVBERi0xLjcK..."
    }
  ],
  "errors": [{ "url": "https://investors.example.com/static-files/0f1c", "code": "not_a_document" }],
  "truncated": false
}
```

This response is illustrative. `found` lists up to 500 links in the order
they are tried. `documents` holds each file downloaded, with `finalUrl` when
a redirect served it from elsewhere, and `errors` each link that did not give
one: `not_a_document` when it served a page, `document_kind_excluded` when it
served a kind not asked for, `documents_too_large` when it would take the
answer past 32 MiB, or the code a Read of it would fail with, such as
`target_http_error` or `document_too_large` for a file over 16 MiB. A link in
`found` but in neither list was not reached, and `truncated` is then true:
`maxFiles`, the byte budget or the deadline stopped the downloads, or the
page had more than 500 document links. The downloads already made are always
returned; only a page that cannot be read fails the request.

The page and each file attempted count against the daily page quota, and each
is metered as a browser read. Files are read one at a time, so ten files take
about ten times as long as one; ask for fewer, or a longer `timeoutMs`, on a
slow site.


## Product and company data

```text
POST /v1/product
POST /v1/company
```

Both accept a URL and the common browser options. Extraction reads
published JSON-LD, microdata/RDFa, supported embedded application data, and
page metadata, with bounded fallbacks for explicit labels and supported
factual prose. These routes run locally without model configuration.

Product data contains `name`, `description`, `price`, `currency`,
`availability`, `sku`, `brand`, `images`, `offers`, and `variants`. Published
`url`, `gtin`, and `mpn` can also be returned. Records are matched using page
identity, canonical URLs, identifiers, and primary-entity references. Related
records for the same product can contribute offers and variants; unrelated
product cards do not contribute a price to the selected product.

When offers publish different prices, `price` is `null` and `priceRange` can
contain observed `low` and `high` bounds with `currency`. A published single
bound remains a single bound. Prices in different currencies are not combined
into a range. Offers preserve their own `price`, `currency`, `availability`,
and `url`, plus published `lowPrice`, `highPrice`, `offerCount`, or `seller`.
A variant price becomes the selected price only when the page identifies that
variant; otherwise variant prices remain in `variants` and `offers`.

On a Shopify storefront, recognized by Shopify's own page markers, a product
URL (`/products/<handle>`, under an optional locale or collection) also reads
the store's own record from `/products/<handle>.json`. That record sits beside
the page's as `platform`: `name: "shopify"`, `productId`, `handle`, `vendor`,
`productType`, `tags`, `options`, `priceRange`, and every variant with its
`sku`, `barcode`, `price`, `compareAtPrice`, `currency` and `options`. Its
values fill only the fields the page left empty: `brand` from the vendor,
`currency`, `images`, and the `sku` and `gtin` of a product with one variant.
The page's own price and availability stand. When the page's published data
cannot be resolved, for example a graph past the 25,000-node bound, the store's
record answers alone, with one offer per variant; when the store's record
cannot be read, the page's record stands as on any other site. The record is a
plain public HTTPS read with no browser and no further page quota.

Company data contains `name`, `description`, `url`, `industry`, `locations`,
`contactLinks`, `socialLinks`, and `products`. Published `legalName`,
`foundingDate`, `employees`, `email`, and `telephone` can also be returned.
Multiple distinct contacts produce `emails` or `telephones` arrays. A scalar
contact is returned when the page identifies a primary contact or publishes
only one value. Public contact links and `sameAs` social profiles are retained;
a directory's own footer contacts are not assigned to an external company it
profiles. An unresolved choice between companies returns
`extraction_ambiguous` (HTTP 422).

Unknown baseline scalar fields are `null` and baseline lists are empty.
Additional fields appear only when supported by published values. Prices,
dates, employee counts, locations, and contacts are not estimated from other
entities, approximate prose, or missing data.

```json
{ "url": "https://example.com/", "render": true }
```

Available fields depend on what the page publishes. These endpoints do not
fill missing company facts or product details with invented values.

## Store catalogs

```text
POST /v1/catalog
```

List a Shopify or WooCommerce store's products from the store's own catalog:

```json
{ "url": "https://shop.example.com/", "maxProducts": 250 }
```

`url` is any page of the store; its origin is the store. `maxProducts` accepts
1 to 1,000 and defaults to 100. The store's home page says which platform it
runs on, through Shopify's or WooCommerce's own page markers or a WordPress
REST link. When the home page names neither, as on a headless storefront, each
platform's catalog is tried in turn, Shopify first, and each attempt counts as
a page.

The response gives:

- the `store` origin, after following at most two redirects (such as a
  `myshopify.com` address, or a bare domain, to the store's own address);
- `platform`, `shopify` or `woocommerce`;
- the store's `currency`;
- `products`;
- the catalog `pages` read;
- `truncated`, when more products remain;
- on WooCommerce, the store's `total` product count.

Each product carries `id`, `handle`, `url`, `title`, `description`, `vendor`,
`tags`, `options`, `images`, `priceRange`, `available` (whether any variant
is), and its `variants`. Each variant has `id`, `title`, `sku`, `price`,
`compareAtPrice`, `currency`, `available` and `options`.

**Shopify.** The catalog is `/products.json`, read a page of 100 at a time.
The `currency` comes from the storefront's own `Shopify.currency` script, and
is `null` on a headless storefront without one. Every product has at least one
variant. Products add `productType`, `publishedAt` and `updatedAt`, and
variants add `barcode`.

**WooCommerce.** The catalog is the Store API that WooCommerce publishes under
the WordPress REST root, read up to 100 products a page in product id order.
The root is `/wp-json/`, or the one the home page names, such as `/?rest_route=/`
or a subdirectory install. A root on another origin is not followed.

Each page's variable products have their variations read beside it, 100 at a
time and up to 250 per product, so each variant carries its own SKU, price and
stock. A variant whose attribute accepts any value names no option for it.
A simple product has no `variants`; its `sku`, `price` and `available` are its
own. Prices are converted from the Store API's minor units, and `vendor` is the
product's brand. Products add:

| Field | Value |
|---|---|
| `sku` | The product's own SKU |
| `type` | `simple`, `variable`, `grouped` or `external` |
| `categories` | Category names |
| `attributes` | The product's attributes that do not define variants, each with its `name` and `values` |
| `price`, `compareAtPrice` | The product's one price and its regular price when on sale; `null` when its variations are priced differently |
| `currency` | The store's currency code |
| `onSale`, `onBackorder` | As the store reports them |
| `lowStockRemaining` | Where the store shows a low-stock count |
| `rating` | `average` and `count`, where the product has reviews |

The catalog is read with plain public HTTPS requests through the same guard as
crawl discovery, with no browser. Every catalog read counts against the page
quota: one per 100 Shopify products, and on WooCommerce one per page of
products plus one per 100 variations. The request counts once against the
request limits. A WooCommerce page may decode to 32 MiB; its compressed
transfer stays within the 2 MiB bound of every public read.

A catalog request must finish within the service's request deadline, 30
seconds by default. WooCommerce stores often serve the Store API uncached, and
a page of 100 products can take several seconds. For a large catalog on a slow
store, set `async: true` to read it as a background job:

```json
{ "url": "https://shop.example.com/", "maxProducts": 1000, "async": true, "jobTimeoutMs": 600000 }
```

The response is a job receipt (HTTP 202) with `kind: "catalog"`. Poll
`GET /v1/jobs/:id`: the job's `progress` counts each catalog read as it
happens, and its `result` is the catalog answer described above.
`jobTimeoutMs` (300,000 by default, up to 600,000) and `webhookUrl` work as
on other [background jobs](#background-jobs), and both require `async: true`.

A job's result is stored whole, within five MiB. A catalog job therefore stops
before the product that would take its result past that bound, and reads no
more pages. It reports `truncated: true` with
`truncationReason: "result_limit"`, as a crawl job does. Products measured on
live stores average about 4 KB, so 1,000 products usually fit. A catalog cut
short by `maxProducts` names no `truncationReason`.

A service restart fails a running catalog job with `job_interrupted`; send it
again. A queued catalog job survives a restart. A catalog dataset reads the
same catalog on a schedule, with its 30-minute run deadline.

The store's `robots.txt` is read first, under the agent name `VitnaWeb`. A
store that disallows its catalog to that agent, or to every agent, is refused
with `catalog_disallowed` (403). The catalog is `/products.json` on Shopify and
the Store API path on WooCommerce. The store's `Crawl-delay`, up to two
seconds, is kept between reads.

These errors can also be returned:

- `catalog_unsupported` (422): the site publishes neither catalog.
- `catalog_unavailable` (502): a later WooCommerce page or variation read
  fails. A partial catalog is not returned.
- `destination_blocked` (400): with `VITNA_WEB_ALLOWED_HOSTS` set, every read
  must stay in scope, including the redirects it follows.

Requests identify themselves as
`VitnaWeb/0.1 (+https://vitna.ai/docs/web/overview)`.

## Careers

```text
POST /v1/careers
```

A company's open roles from its own job board on Greenhouse, Lever, Ashby,
Workable, Recruitee or Personio, read from each platform's public job board
API:

```json
{ "url": "https://jobs.lever.co/acme", "maxJobs": 200, "descriptions": true }
```

`url` is the board (`job-boards.greenhouse.io/NAME` or `boards.greenhouse.io/NAME`,
`jobs.lever.co/NAME` or `jobs.eu.lever.co/NAME`, `jobs.ashbyhq.com/NAME`,
`apply.workable.com/NAME`, `NAME.recruitee.com`, `NAME.jobs.personio.de` or
`.com`), one of its job pages, or a careers page that links or embeds exactly one board.
`maxJobs` accepts 1 to 1,000 and defaults to 100. `descriptions`, true by
default, includes each posting's description as plain text that keeps its
lines; false leaves it out.

The response gives the `board` (`platform`, `name`, an EU Lever board's or a
Personio board's `region`, and its public `url`), `jobs`, the `pages` read, `truncated`
when more postings remain, and, for Greenhouse, the board's own `total`. Each
job carries the same fields on every platform, `null` or empty where the
board publishes nothing:

| Field | Meaning |
|---|---|
| `id` | The board's id for the posting |
| `title`, `url`, `applyUrl` | The posting, its page, and where to apply |
| `company` | The company name, where the board gives one (Greenhouse, Workable, Recruitee, Personio) |
| `department`, `departments`, `team` | The board's own grouping |
| `locations`, `country` | Every location the posting names |
| `workplaceType`, `remote` | `remote`, `hybrid` or `onsite` as the board states it, and whether the role is remote |
| `employmentType` | The board's own words, such as `FullTime` or `Permanent` |
| `publishedAt`, `updatedAt` | ISO timestamps, where published |
| `compensation` | Lever's or Recruitee's published salary range (`min`, `max`, `currency`, `interval`), or Ashby's `summary` where the company shows pay on its postings |
| `description` | The posting's text, when `descriptions` is true |
| `platform` | `greenhouse`, `lever`, `ashby`, `workable`, `recruitee` or `personio` |

Boards are read with plain public HTTPS requests through the same guard as
store catalogs, with no browser, and the API host's `robots.txt` is read
first under the agent name `VitnaWeb`. Every page read counts against the
page quota: one for a Greenhouse, Ashby, Workable or Recruitee board, one per
50 postings on Lever (with Lever's `Crawl-delay` kept between them), and one
for a careers page that has to be read to find its board. A Personio board is
one read, or up to three with descriptions, since Personio's feed carried its
description sections only when a language was named (measured 2026-10-07):
it is read as it stands, then in English, then in German, until one carries
them. With `VITNA_WEB_ALLOWED_HOSTS` set, the
board's API host must be in scope as well as the `url`. Postings an Ashby
board marks unlisted are left out, as are Recruitee offers not published.
Workable says only whether a role is remote, so its other roles have no
`workplaceType`. A renamed Recruitee company's board redirects to its new
name, which is followed. A whole board's response may decode to
32 MiB; its compressed transfer stays within the 2 MiB bound of every public
read.

| HTTP | Codes |
|---|---|
| 403 | `job_board_disallowed` when `robots.txt` disallows the board's API, which Personio's does for a company it does not know |
| 404 | `job_board_not_found` for a board that does not exist |
| 422 | `job_board_unsupported` when no board is found at `url`; `job_board_ambiguous` when a careers page links more than one, naming each |
| 502 | `job_board_unavailable` when the board answers with anything but its postings |

The platforms document these APIs as public (retrieved 2026-10-07): the
[Greenhouse Job Board API](https://docs.greenhouse.io/job-board.html), the
[Lever Postings API](https://github.com/lever/postings-api), Ashby's
[public job posting API](https://developers.ashbyhq.com/docs/public-job-posting-api),
Recruitee's offers API (`NAME.recruitee.com/api/offers/`), and Personio's
[XML job feed](https://developer.personio.de/docs/retrieving-open-job-positions);
Workable's board widget API (`apply.workable.com/api/v1/widget/accounts/NAME`)
is the one its own job widget reads. SmartRecruiters publishes a posting API
too, but its API host's `robots.txt` disallows every agent but LinkedIn's,
so it is not read.
A careers page rendered only by script names no board in its HTML; send the
board's own URL instead.

## Investor Relations (`POST /v1/ir`)

```text
POST /v1/ir
```

Discover and classify Investor Relations presentations, press releases, financial
reports, earnings transcripts, and webcasts from a company URL or IR portal via
Q4 feeds and rendered IR pages:

```json
{ "url": "https://investor.nvidia.com/", "kinds": ["presentation", "press_release", "financial_report"], "maxItems": 25 }
```

## Document parsing (`POST /v1/parse`)

```text
POST /v1/parse
```

Parse a public HTTPS URL or base64-encoded PDF, DOCX, XLSX, or PPTX document
into structured pages, typed blocks, extracted tables, Markdown, and character
citation offsets:

```json
{ "url": "https://example.com/report.pdf", "format": "both", "maxPages": 100 }
```

## Claim verification (`POST /v1/verify`)

```text
POST /v1/verify
```

Deterministically verify a factual claim against supplied URLs or native search
results, returning per-segment support status, verbatim quotes with character
offsets, content hashes, and a SHA-256 attestation digest:

```json
{ "claim": "Example Domain is maintained for illustrative examples.", "urls": ["https://example.com/"], "maxSources": 3 }
```

## Structural change detection (`POST /v1/diff`)

```text
POST /v1/diff
```

Compare two public URLs (`beforeUrl`, `afterUrl`) or two inline text snapshots
(`beforeText`, `afterText`) across `prose`, `pricing`, `policy`, or `risk_factors`
modes with materiality scores and a SHA-256 attestation digest:

```json
{ "beforeText": "Starter is $29/mo.", "afterText": "Starter is $39/mo.", "mode": "pricing" }
```

## Entity alt-data dossiers (`POST /v1/entity`)

```text
POST /v1/entity
```

Assemble a company dossier in parallel across requested modules (`profile`,
`careers`, `ir`, `infra`, `filings`, `news`):

```json
{ "domain": "nvidia.com", "ticker": "NVDA", "modules": ["profile", "careers", "ir", "infra", "filings", "news"] }
```

## Enrichment matrices (`POST /v1/grid`)

```text
POST /v1/grid
```

Enrich an `entities` by `columns` table synchronously (up to 10 entities, or
asynchronously with `async: true` for up to 100 entities) using `entity`,
`search`, `verify`, or `source` column strategies with cited source URLs, quotes,
and attestation digests. Pass `discover` (with `query`, optional `entityType`,
`count`, `criteria`, `domains`, `excludeDomains`, `queries`, `index`, and `asOf`)
and optional hard `budget` controls (`maxSearches`, `maxVerifications`,
`maxDurationMs`) to discover and verify matching entities in one call, with or
without explicit `entities` or `columns`:

```json
{
  "discover": {
    "query": "AI inference hardware startups",
    "entityType": "company",
    "count": 10,
    "criteria": ["founded after 2022", "builds custom silicon"]
  },
  "budget": { "maxSearches": 6, "maxVerifications": 20 },
  "columns": [{ "id": "org", "strategy": "entity", "field": "profile.name" }]
}
```

Pass the same `discover`, `budget`, `entities`, and `columns` definition inside
`source.grid` on `POST /v1/datasets` to maintain it as a recurring living
webset with incremental diffs, webhooks, and CSV/JSONL export.

## Datasets

```text
POST   /v1/datasets
GET    /v1/datasets
GET    /v1/datasets/DATASET_ID
DELETE /v1/datasets/DATASET_ID
POST   /v1/datasets/DATASET_ID/run
GET    /v1/datasets/DATASET_ID/records?run=latest&format=jsonl
GET    /v1/datasets/DATASET_ID/changes?after=RUN
```

A dataset is a collection you define once and Vitna keeps current. You give
it a source, the field that identifies a record, and how often to run. Each
run keeps a snapshot of the records and what changed since the run before.

```json
{
  "name": "Competitor prices",
  "source": { "recipe": "RECIPE_ID", "urls": ["https://shop.example.com/p/1", "https://shop.example.com/p/2"] },
  "key": "url",
  "ignoreFields": ["checkedAt"],
  "intervalSeconds": 86400,
  "webhookUrl": "https://hooks.example.com/vitna"
}
```

| Source | Fields | Records |
|---|---|---|
| A recipe over pages | `recipe`, `urls` (1 to 100) | One per page: its `url` and the recipe's fields |
| A recipe over a site | `recipe`, `url`, `maxPages` (1 to 100, default 20), `includePaths`, `excludePaths` | One per page the site map finds |
| A store catalog | `catalog` (a Shopify or WooCommerce store's URL), `maxProducts` (1 to 1,000, default 250) | One per product, as `/v1/catalog` returns it |
| A careers board | `careers` (a board or careers page URL), `maxJobs` (1 to 1,000, default 250), `descriptions` (default true) | One per posting, as `/v1/careers` returns it, keyed by `id` |
| Vitna's market record | `market`: `model`, `tooling`, `extraction`, `speech`, `retrieval`, or `compute` | One per figure on the class's tape, with an `id` naming its sku, seller, meter and any band |
| A grid (living webset) | `grid`: `discover`, `budget`, `entities`, `columns`, `concurrency` (same contract as `POST /v1/grid`, without task fields) | One flat record per matched or supplied entity (`id`, `name`, `domain`, `ticker`, `url`, optional `verification`, and each column id) |

`key` names the field that identifies a record from one run to the next. It
defaults to `url` (`id` for a market, a careers board, or a grid); records without it are skipped and
counted.
When a `grid` run hits a hard `budget` cap or a column cell error, the run is
marked `partial`, preserves previously discovered records, and removes none.
`ignoreFields` lists fields whose changes don't count, such as timestamps.
`intervalSeconds` is 900 to 2,592,000, a day by default. The first run starts
when the dataset is created. `POST .../run` runs it now; a dataset that is
already running answers 409 `dataset_running`.

`GET /v1/datasets/DATASET_ID` lists the runs, newest first. Each gives its
`status`, the counts of `records`, `added`, `changed`, and `removed`, the
`pages` read, and the first 100 page `errors` with their total. A run's
status is one of:

- `succeeded`: it read every page.
- `partial`: it missed a page or stopped at a limit. It keeps the records it
  could not reach as they were and removes nothing. A record leaves the
  dataset only on a run that read its whole source.
- `failed`: its source could not be read at all. The previous records stay.

`GET .../records` returns a run's records as JSONL (`format=jsonl`, the
default) or CSV (`format=csv`). CSV has one column per field, in the order
fields first appear. Nested values are written as JSON, and text a
spreadsheet would run as a formula gets a leading `'`. `run` is `latest`
(the default) or a run number.

`GET .../changes?after=RUN` returns what each run after `RUN` added, changed,
and removed, oldest first, whole runs at a time, up to 10,000 changes. Added
and changed entries carry the record as it now is; removed entries carry the
key. Read on with `after` set to the response's `next`; `more` says further
runs follow. `resync: true` means runs after yours have been pruned, so read
the records afresh. With `webhookUrl`, each run sends a
`dataset.run.completed` event with its counts, retried with backoff up to
five times.

Runs use the same browser slots, page quota, and accounting as API calls,
one run at a time per service. A run that a restart interrupts starts again
at the next tick. The limits:

| Limit | Value |
|---|---|
| Datasets per key | 5 |
| Records per run | 5,000, each up to 16 KiB |
| Size per run | 8 MiB |
| Runs kept | The last `retainRuns` (1 to 30, default 10), within 32 MiB |

The latest run is always kept, and so is the run the next one is compared
against.

### Published datasets

```text
GET /v1/published
GET /v1/published/SLUG
GET /v1/published/SLUG/records?run=latest&format=jsonl
GET /v1/published/SLUG/changes?after=RUN
```

The operator can publish datasets that every key can read. Vitna's market
record is the main example: each class's prices, kept current, with a feed
of what moved. Published datasets take the same `records` and `changes`
parameters. No key can run or remove them, and reading one counts as a
request like any other.

```dotenv
VITNA_WEB_PUBLISHED_DATASETS=[{"slug":"market-model","name":"AI model prices","source":{"market":"model"},"ignoreFields":["confirmedAt","fetchedAt","evidenceSha256","observationId"],"intervalSeconds":3600}]
```

Each entry is a dataset definition with a `slug` (up to 48 lowercase
letters, numbers, and hyphens) and no webhook. A published dataset keeps its
runs across restarts while its source and key stay the same. It starts
afresh when either changes, and is removed when the configuration drops it.
A market source reads the record's public tape at
`https://vitna.ai/api/v1/markets/{class}/tape`; `VITNA_WEB_RECORD_ORIGIN`
names another origin. Ignoring the confirmation and evidence fields, as in
the example, means a price that is re-confirmed unchanged doesn't count as
a change.

## Firehose

```text
GET /v1/firehose
```

A continuous stream of freshly crawled web pages: every news page in Common
Crawl's news crawl (CC-NEWS), about 300,000 a day in many languages, read by
cursor. Common Crawl publishes a news file every one to two hours. The service
reads each file whole and keeps every HTTP 200 HTML page's title and text, in
the order it read them, for a retention window of 72 hours by default.

```text
GET /v1/firehose?after=0&limit=100&domain=reuters.com,de&language=en,de
```

| Parameter | Default | Meaning |
|---|---|---|
| `after` | 0 | The cursor: records after this one. Send the previous answer's `next` |
| `limit` | 100 | Records per answer, 1 to 1,000 |
| `domain` | Omitted | Up to 20 domains, separated by commas. A domain covers its subdomains, and a top-level domain such as `de` or a suffix such as `co.uk` covers every site under it |
| `language` | Omitted | Up to 10 language codes, such as `en` or `de`, from the page's own `lang` attribute or `Content-Language` header |
| `text` | `true` | `false` leaves each page's text out |

```json
{
  "records": [
    {
      "id": 4102,
      "url": "https://www.example.com/news/rates",
      "host": "www.example.com",
      "fetchedAt": "2026-10-07T14:58:25.000Z",
      "language": "en",
      "title": "Rates rise",
      "text": "The bank raised rates by a quarter point.",
      "htmlBytes": 280039,
      "digest": "sha1:NQ5RS4U4IVNJT3QEUFJYXWG45ZAZ2XDJ",
      "source": {
        "crawl": "CC-NEWS",
        "file": "crawl-data/CC-NEWS/2026/10/CC-NEWS-20261007145826-00176.warc.gz",
        "offset": 951,
        "length": 58004,
        "url": "https://data.commoncrawl.org/crawl-data/CC-NEWS/2026/10/CC-NEWS-20261007145826-00176.warc.gz"
      }
    }
  ],
  "next": 4102,
  "more": true,
  "missed": false
}
```

Read on by sending `next` as `after`.

- `more` is true while further records already match.
- When `more` is false, the cursor has caught up and `next` holds its place, so
  polling with it returns only the pages read since.
- `missed: true` means records past the cursor were pruned before they were
  read.

Each record's `fetchedAt` is when Common Crawl fetched the page. `language` is
`null` when the page names none, and `digest` is the payload's SHA-1 as Common
Crawl records it. `source` names the news file and the `offset` and `length`
of the page's WARC record in it, so the page's HTML is one ranged read away:

```bash
curl -r 951-58954 https://data.commoncrawl.org/crawl-data/CC-NEWS/2026/10/CC-NEWS-20261007145826-00176.warc.gz | gunzip
```

The firehose is off until the operator sets `VITNA_WEB_FIREHOSE_PATH` to its
store's SQLite file. Until then it answers `firehose_not_configured` (503), and
`firehose_empty` (503) while the store holds nothing yet. `GET /v1/status`
reports `capabilities.firehose` and `limits.firehoseRecords`. While the
firehose is on, it also reports `firehose`: the store's `files`, `records`,
its newest `latestFile`, and the `from` and `to` of its pages' fetch times.

Each record returned adds one `firehoseRecords` to usage and to an account's
statement. The ledger rate is `VITNA_WEB_BILLING_FIREHOSE_RECORD_MICRO_USD`,
and the operator estimate rate for static clients is
`VITNA_WEB_FIREHOSE_RECORD_USD`. A read counts once against the request
limits and uses no page quota.

Common Crawl publishes the crawl under its terms of use; the pages themselves
remain their publishers'.

### Monthly crawl backfill

```text
POST /v1/firehose/backfill
```

A backfill reads one domain's pages from a Common Crawl monthly crawl
(CC-MAIN), in the firehose's record shape, so a feed can start with a site's
recent history. It is always a background job: the request answers HTTP 202
with a job of `kind: "backfill"`. Poll `GET /v1/jobs/:id`; its `result` holds
the pages.

```json
{ "domain": "example.org", "path": "/news/", "language": "de", "maxPages": 200 }
```

| Field | Default | Meaning |
|---|---|---|
| `domain` | Required | A registered domain, such as `example.org`, with its subdomains |
| `path` | Omitted | A path prefix, such as `/news/`, read on the domain itself and its `www` host |
| `crawl` | The newest | A monthly crawl, such as `CC-MAIN-2026-39` |
| `language` | Omitted | One language code, such as `de`, as Common Crawl's own detection reports a page's languages |
| `maxPages` | 100 | Pages read, 1 to 500 |
| `jobTimeoutMs` | 600,000 | The job's deadline, up to 600,000 milliseconds |
| `webhookUrl` | Omitted | A public HTTPS destination told when the job finishes |

Common Crawl's URL index lists the domain's captures in URL order. A URL
captured more than once in the crawl is read once, from its latest capture.
Up to `maxPages` pages are read, each with one ranged request, and each
record is checked against the index before it is kept: its URL, its length
and its payload digest. Aim a backfill at a section with `path`, since URL
order otherwise starts wherever the site's addresses sort first. A record's
`language` is still the one the page declares, which can differ from the
index's detection.

The result gives:

- `crawl` and `domain`, and `path` or `language` when they were asked for;
- `records`, each with `source.crawl` naming the monthly crawl, and no `id`,
  since a backfill's pages are not in the stream;
- `captures`, the index rows read (up to five for each page asked for);
- `pages`, the records read, and `skipped`, those that failed a check;
- `truncated`, when more pages exist than were read.

A backfill can also stop early, keeping the pages it already read, with a
`truncationReason`: `result_limit` when the job's five-MiB result is full,
or `commoncrawl_blocked` or `commoncrawl_unavailable` when Common Crawl
stops answering. Many publishers block Common Crawl's crawler, and a backfill
of such a domain finds nothing (`captures: 0`).

Every Common Crawl request from every backfill takes its turn at one a second
by default, so 100 pages take about two minutes. The host shares Common
Crawl's allowance with Vitna Search's archive imports.

- `VITNA_WEB_FIREHOSE_BACKFILL_RATE` raises the pace, up to 4 a second.
- A busy index (a 429 or a 5xx) is asked again twice, 10 and 20 seconds later.
- A 403 stops every backfill for 20 minutes. New ones answer
  `commoncrawl_blocked` (503) until then, and `GET /v1/status` reports
  `firehoseBackfill.blockedUntil`.

Each record returned is one `firehoseRecords` unit. Backfills are off until
the operator sets `VITNA_WEB_FIREHOSE_BACKFILL=true`, and answer
`firehose_backfill_not_configured` (503) until then. They do not need the
stream's store. `GET /v1/status` reports `capabilities.firehoseBackfill`,
`limits.backfillPages` and, while backfills are on, `firehoseBackfill` with
its `ratePerSecond`. A service restart fails a running backfill with
`job_interrupted`.

### Structured topic events

```text
GET /v1/firehose/events
```

Aggregates normalized public-registry and SEC filing events across up to eight
structured topics (`cisa-kev`, `federal-register`, `fda-drug-recalls`,
`fda-device-recalls`, `treasury-debt`, `sec-8k`, `sec-13d`, `sec-form4`) with a
5-minute in-memory TTL cache per topic:

```text
GET /v1/firehose/events?topic=cisa-kev,sec-8k&since=2026-10-01&limit=20
```

| Parameter | Default | Meaning |
|---|---|---|
| `topic` | All 8 topics | Comma-separated or repeated topic names |
| `since` | Omitted | Earliest publication date formatted `YYYY-MM-DD` |
| `limit` | 20 | Maximum events returned across selected topics, 1 to 100 |

### Ingestion

The Web service only reads the store. `platform/web/firehose-run.mjs` fills
it, run on a timer (`deploy/web-api/firehose.timer`) as the Web service's own
user, so both can open the file. Each run:

1. Lists the current month's news files on `data.commoncrawl.org`, and the
   previous month's while the retention window reaches into it.
2. Reads up to `VITNA_FIREHOSE_FILES_PER_RUN` files it does not yet hold,
   oldest first.
3. Prunes pages past the window or the text budget, oldest file first.

A file is one request: about 1 GB and 26,000 pages, measured on 2026-10-07,
read in about two minutes. That keeps far inside Common Crawl's request
limits.

- **A 403 stops the run** at once, with no further request, and the run exits
  with status 2 so the block shows in the journal.
- **A 429, a 5xx or a dropped connection** stops the run until the next one.
- **A run that stops part-way keeps the pages it read** and resumes at the next
  record with a ranged read, so no page is stored twice.
- **One run at a time:** a lease in the store keeps a second run from starting
  while one is still going.

| Setting | Default | Meaning |
|---|---|---|
| `VITNA_FIREHOSE_PATH` | Required | Absolute path of the store's SQLite file; the Web service's `VITNA_WEB_FIREHOSE_PATH` names the same file |
| `VITNA_FIREHOSE_RETAIN_HOURS` | 72 | Hours of pages kept, by when their file was crawled, from 1 to 720 |
| `VITNA_FIREHOSE_MAX_TEXT_GB` | 6 | Text kept at most, in GiB; past it the oldest files' pages go first |
| `VITNA_FIREHOSE_MIN_FREE_GB` | 10 | A run reads no file while the disk has less free space than this |
| `VITNA_FIREHOSE_FILES_PER_RUN` | 2 | Files read in one run, from 1 to 24 |

Pages average 4.2 KB of text, so 72 hours of news is about 4.5 GB.

The raw CC-NEWS crawl stream does not yet carry:

- the monthly crawl as a stream, only as a backfill of one domain at a time;
- each page's HTML in the answer;
- delivery by webhook or to a storage bucket.

Structured public-registry event topics are served separately at
`GET /v1/firehose/events`.

## Research

```text
POST /v1/research
```

Search and read bounded page sets, then optionally return extractive findings:

```json
{
  "query": "What does this company offer?",
  "maxSources": 3,
  "answer": true
}
```

Discovery uses the local Vitna index by default; populate that index as
described below, or supply your own `urls` array. `maxSources` defaults to 3
and accepts 1 to 20. With `answer: true`, the native engine selects observed
source passages using lexical matches and returns numbered citations.
Set `answer` to `false` to retrieve page content without an answer:

```json
{
  "query": "What does this company offer?",
  "urls": ["https://example.com/"],
  "maxSources": 3,
  "answer": false
}
```

The response includes the query, source page content, an answer when
requested, and page errors. Native passage answers begin with "Extractive
findings from supplied sources". Supported comparisons and arithmetic begin
with "Grounded comparison" or "Grounded calculation" and show observed operands,
units, formulas, and numbered citations. Supported arithmetic includes sum,
average, difference, ratio, percentage change, minimum, and maximum over named
entities and explicit compatible attributes. Conflicting facts, units, billing
periods, missing facets, and unsupported qualifiers refuse instead of guessing.
`generation` carries `engine: "vitna-native"`, `mode: "extractive"`,
`planning: "intent_decomposition"`, and `reasoning: "bounded_rules_v1"`.
Optional `analysis` contains validated coverage and finite calculations with
existing source IDs. This is a finite rule engine; general reasoning still
requires a separately operated self-hosted model. Unsupported requests return
HTTP 422 `native_research_unsupported`.
Supplied URLs bypass indexed discovery. Disabling Search or the answer
engine can return `search_not_configured` or `model_not_configured` when
the request needs that engine.

### Multiple searches and structured results

Use search rounds to refine discovery after earlier pages have been read:

```json
{
  "query": "Compare available products and pricing for this company.",
  "maxSources": 10,
  "maxQueries": 6,
  "maxRounds": 3,
  "maxPages": 20,
  "planQueries": true,
  "answer": true,
  "async": true,
  "jobTimeoutMs": 300000
}
```

| Field | Default | Meaning |
|---|---|---|
| `query` | Required | Question or research brief, up to 1,000 characters |
| `maxSources` | 3 | Readable source budget, from 1 to 20 |
| `maxQueries` | `maxRounds` | Search-query budget, from 1 to 10 |
| `maxRounds` | 1 (`2` with `followLinks`) | Search/read rounds, from 1 to 3 |
| `maxPages` | `maxSources` | Page-attempt budget, from 1 to 40 |
| `followLinks` | `false` | Follow query-relevant links discovered on read pages across rounds (same host when `urls` are supplied) |
| `planQueries` | `false` | Bounded query planning; deterministic source-based variants in native mode |
| `schema` | Omitted | Supported JSON Schema for `data`; requires `answer: true` |
| `stream` | `false` | Server-Sent Events progress and final result |
| `async` | `false` | Submit a durable background job |
| `jobTimeoutMs` | 300,000 | Background deadline, up to 600,000 milliseconds; requires `async: true` |
| `webhookUrl` | Omitted | Public HTTPS completion destination; requires `async: true` |

The input remains one `query`. The returned `queries` array records the
searches actually executed. Up to 20 supplied `urls` bypass search
discovery; they cannot be combined with `planQueries: true`. With
`followLinks: true`, research scores unseen links found on each read page
against the query terms and follows top-ranked candidates in subsequent rounds
(scoped to the seed hosts when `urls` are supplied), bounded by `maxRounds`,
`maxPages`, and `maxSources`. The response `budget` reports actual rounds,
searches, page attempts, sources, model calls, context characters, limits, and
the stopping reason.

Provide a schema to receive validated JSON in `data` alongside the answer
and collected pages. Native mode extracts supported literal values; an
optional self-hosted model can generate schema-shaped data:

```json
{
  "query": "List the products this company sells.",
  "urls": ["https://example.com/"],
  "answer": true,
  "schema": {
    "type": "object",
    "properties": {
      "products": { "type": "array", "items": { "type": "string" } }
    },
    "required": ["products"],
    "additionalProperties": false
  }
}
```

### Timelines and multi-attribute comparisons

Native Research can order observed historical events, select explicit
earliest/latest events and calculate elapsed days between two cited dates.
It accepts full ISO calendar dates, timezone-qualified ISO instants and
unambiguous month-name/day/year dates. Year-only dates, numeric slashes,
implicit timezones, mixed day/instant precision and crawl metadata are
refused. Conflicting dates for the same named event remain ambiguous;
requesting a year cannot resolve that contradiction.

Structured responses expose `analysis.timeline` with at most 24 ordered
events, normalized dates, precision and source IDs. Elapsed calculations
use cited epoch-millisecond operands and an explicit day result.
Multi-attribute comparisons expose at most 24 `analysis.comparisons` cells
with entity, attribute, observed display value and source ID. Explicit date
filters apply before selecting historical numeric records; absent or
conflicting cells are refused rather than silently filled. All emitted
analysis must pass the finite public response contract.

The preserved native evaluation remains 44/44 cases. A separate authored
timeline/comparison group passes 40/40, including 22 refusal diagnostics,
in `outputs/web-native-evaluation/report-v3.json`. These fixtures exercise
the bounded deterministic grammar, not open-ended general reasoning.

### Stream progress

Set `stream: true` on a synchronous research request. The response content
type is `text/event-stream`. Progress event names include `started`,
`round`, `planning`, `search`, `source`, `source_error`, `generating`, and
`completed`. Events include a monotonic sequence number and measured
progress. The final `result` event contains the complete JSON response:

```text
event: source
data: {"type":"source","sequence":3,"url":"https://example.com/"}

event: result
data: {"query":"What does this company offer?","answer":null,"mode":"sources","sources":[],"meta":{}}
```

This wire example is illustrative. A stream failure uses an `error` event
with `error.code` and `error.message`. Inspect that event even if the HTTP
status was 200. The synchronous stream deadline is at most 60 seconds and
may be shorter under the deployment settings. Disconnecting cancels the
request. The playground displays progress, the final result, and stream
errors; cURL users should include `-N` to see events as they arrive.

### Background jobs

Set `async: true` for research, extraction or a [store catalog](#store-catalogs)
that needs a longer deadline. A [firehose backfill](#monthly-crawl-backfill) is
always a job.
The create response uses HTTP 202 and includes `id`, `kind`, `status`,
timestamps, `jobTimeoutMs`, `progress`, `result`, and `error`. Poll
`GET /v1/jobs/:id`. Completed research, extraction, catalog or backfill
output is in `result`;
failed jobs carry `error`. `DELETE /v1/jobs/:id` cancels active work.

`async` and `stream` cannot both be true. Async jobs can use an optional
completion webhook. Store the job ID even when using a webhook, so progress
and delivery outcomes remain inspectable. Job scheduling and callbacks
require the service process to keep running.
