# Show the source of an AI answer with text-fragment links

Turn a cited quote into a link that scrolls the browser to the passage or opens the PDF page, after checking that the quote is really in the source.

Documentation index: https://webcite.co/llms.txt
Canonical page: https://webcite.co/api-docs/source-links
API origin: https://api.webcite.co
Authentication: x-api-key header. Keep keys on your server.

## How do I make my RAG app link to the exact page or passage it cited?

Keep the page with every chunk: `POST /api/v1/extract/pages` returns [anchored chunks](/api-docs/chunks), each with a 1-based `page`, so store it in your index metadata. When the model cites a chunk, send the quoted words with the `asset_id` and `page`, or with the web `url`, to `POST /api/v1/citations/source-preview`. It checks that the quote is in the source and returns a `deep_link`: a text-fragment URL that scrolls to the words on a web page, or the page number for a PDF, which you open in your own copy with `#page=N`. Show the link only when `binding.method` is `exact` or `normalized`, as the recorded calls below show.

## Endpoint and minimal request

`POST https://api.webcite.co/api/v1/citations/source-preview` takes a `quote` and either a web `url` or an uploaded `asset_id` with a 1-based `page`. Send the key in the `x-api-key` header. Each call costs 1 credit. Agents call the same operation as the MCP tool `get_source_preview`.

```bash
curl --fail-with-body -X POST 'https://api.webcite.co/api/v1/citations/source-preview' \
  -H "x-api-key: $WEBCITE_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{"url": "https://www.census.gov/library/publications/2024/demo/p60-282.html", "quote": "Real median household income was $80,610 in 2023, a 4.0 percent increase from the 2022 estimate of $77,540"}'
```

Recorded response, 25 November 2026, with account fields removed ([full file](/samples/source-preview-census-exact.json)):

```json
{
  "kind": "web",
  "url": "https://www.census.gov/library/publications/2024/demo/p60-282.html",
  "quote": "Real median household income was $80,610 in 2023, a 4.0 percent increase from the 2022 estimate of $77,540",
  "deep_link": "https://www.census.gov/library/publications/2024/demo/p60-282.html#:~:text=Real%20median%20household%20income%20was%20%2480%2C610%20in%202023%2C%20a%204.0%20percent%20increase",
  "binding": {
    "grounded": true,
    "method": "exact",
    "matched_quote": "Real median household income was $80,610 in 2023, a 4.0 percent increase from the 2022 estimate of $77,540",
    "matched_text": "Real median household income was $80,610 in 2023, a 4.0 percent increase from the 2022 estimate of $77,540",
    "score": 1
  }
}
```

`deep_link` is the page URL with a text fragment (`#:~:text=`) built from the quote. In a browser that supports text fragments, opening it scrolls to the passage and highlights it.

## Read the binding before you link

`binding` says whether the quote is in the source. `grounded` is true only when it was found, and `method` says how. Four recorded calls against the same Census page show the difference:

| Quote sent | `grounded` | `method` | `score` |
| --- | --- | --- | --- |
| The sentence as published | true | `exact` | 1 |
| Reworded: "real median household income was $80,610 in 2023 - a 4.0% increase from the 2022 estimate" | true | `fuzzy` | 1 |
| One figure transposed: "Real median household income was $86,010 in 2023" | false | `unbound` | 0.63 |
| Wrong figures: "Real median household income was $82,400 in 2023, a 6.3 percent increase" | false | `unbound` | 0.5 |

`exact` means the quote was found word for word, and `normalized` means it was found as a substring once both texts were normalized. `fuzzy` means a close passage was found but the wording differs, so show `binding.matched_text`, the passage actually found, rather than the quote. A quote binds only when every figure in it matches the source: value, digit order, decimal point, sign, percent versus percentage points, currency, and million versus billion. Formatting differences such as thousands separators, non-breaking spaces, dash styles, a space before a percent sign and line breaks still bind. `reflowed` used a prepared OCR reading and always needs review. `unbound` means the source does not contain the quote: the transposed and wrong figures above came back unbound, with the real sentence in `matched_text`. Recorded files: [reworded](/samples/source-preview-census-paraphrase.json), [transposed](/samples/source-preview-census-transposed.json), [wrong figures](/samples/source-preview-census-wrong.json).

## Choose the link to show

The text fragment is built from the quote you sent, so it scrolls only when those words are on the page. Use `deep_link` for `exact` and `normalized` matches. For a `fuzzy` match, link the plain URL and show the matched passage. For `unbound`, do not present the quote as sourced.

```javascript
async function sourceLink(url, quote) {
  const response = await fetch("https://api.webcite.co/api/v1/citations/source-preview", {
    method: "POST",
    headers: { "x-api-key": process.env.WEBCITE_API_KEY, "Content-Type": "application/json" },
    body: JSON.stringify({ url, quote }),
  });
  if (!response.ok) throw new Error(`source-preview failed: ${response.status}`);
  const { deep_link, binding } = await response.json();
  if (!binding.grounded) return { status: "unsourced", href: null, passage: null };
  if (["exact", "normalized"].includes(binding.method)) {
    return { status: "found", href: deep_link, passage: quote };
  }
  return { status: "review", href: url, passage: binding.matched_text };
}
```

Run this on your server, where the key lives, and send the result to the page. Cache it with the answer: the preview fetches the source each time, and a page can change after you checked it.

## Link to a page in a PDF

For an uploaded file, send `asset_id`, `page` and `quote`. The response has `kind: "page"`, the page's extracted `text`, and a `deep_link` of the form `asset_url#page=N`. The `evidence://` asset URL identifies the stored file and does not open in a browser, so open your own copy of the file at that page: most PDF viewers, including the ones built into browsers, accept `#page=N` on the file URL.

```json
{
  "asset_id": "YOUR_ASSET_ID",
  "page": 1,
  "quote": "Civilian labor force"
}
```

The [recorded response](/samples/source-preview-bls.json) for page 1 of a BLS table returned `grounded: true`, `method: "exact"` and the page text. For a spreadsheet, source preview reads the sheet grid and takes a cell anchor: `cell: "F8"` with `page` set to the sheet number, or a sheet-qualified `cell: "tableA1!F8"`. The [recorded response](/samples/source-preview-census-xlsx-cell.json) for cell F8 of the Census table A-1 workbook returned `kind: "grid"`, the cells around F8 with F8 marked as the anchor, and `method: "normalized"` for the quote `80610`. [Convert a spreadsheet to Markdown](/api-docs/spreadsheet-to-markdown) shows the extracted sheet. To draw a box around the passage on the page, keep element positions from [extraction](/api-docs/extract), as in [RAG citations that open the exact page](/blog/rag-citations-page-and-bounding-box/).

## Check many quotes at once

Source preview checks one quote and returns something to display. To check up to 200 quotes against their sources in one call, use [batch quote checks](/api-docs/batch) (MCP `verify_batch`), then call source preview for the ones you show. Neither call decides whether the source supports the claim around the quote; [verify a claim](/api-docs/verify) with the URL in `source_urls` does.
