---
title: "Manage citation sources"
description: "Supply source data, publish updates, and choose how revisions are tracked."
canonical_url: "https://tiptap.dev/docs/citations/guides/sources"
---

# Manage citation sources

Supply source data, publish updates, and choose how revisions are tracked.

Each source has a stable `id`, a display `label`, and the [JSON data](https://tiptap.dev/docs/citations/api-reference/source-data.md) you want to track. Your app fetches or extracts that data. If you supply a URL alone, Smart Citations tracks the URL string.

## Try a source change

Edit **Source text** and click **Apply source change**. Only citations of the selected source need review.

> **Interactive demo:** [React](https://embed-pro.tiptap.dev/preview/Extensions/SmartCitationsSources/React)

## Refresh source data

Keep the [configured source collection](https://tiptap.dev/docs/citations/getting-started/install.md) while the editor is open. This example assumes `/api/manual` returns plain text and replaces the data for the existing `manual` source.

```ts
const response = await fetch('/api/manual')
if (!response.ok) {
  throw new Error(`Could not load the manual: ${response.status}`)
}

sources.update('manual', { data: { text: await response.text() } })
```

Keep the last known source if a fetch fails. Run refreshes for the same source in order so an older response cannot overwrite newer data. Finish fetching before applying related updates in `sources.batch()`.

### Choose a revision strategy

| Strategy        | Configuration                           | Behavior                                                                                 |
| --------------- | --------------------------------------- | ---------------------------------------------------------------------------------------- |
| Automatic       | Omit `revision` and `getRevision`.      | Hashes canonical JSON with SHA-256. Array order matters. Object key order has no effect. |
| Explicit        | Set `revision` to a version ID or ETag. | Your app decides when to change the revision.                                            |
| Selected fields | Set `getRevision: data => data.text`.   | Hashes the selector result, so changes to unrelated fields leave the revision unchanged. |

Only sources with an explicit revision accept `revision` updates. Remove and re-add a source to change its strategy.

Selectors run on insert and data replacement. They receive frozen data and must return finite JSON. If a selector throws, the collection keeps its previous state and rethrows the error.

This source tracks `text` and ignores refresh timestamps.

```ts
const sources = createSources([
  {
    id: 'manual',
    label: 'Editor manual',
    data: { text: 'First version', fetchedAt: new Date().toISOString() },
    getRevision: data => data.text,
  },
])
```

See the [source collection API](https://tiptap.dev/docs/citations/api-reference/sources.md) for updates, subscriptions, and batches.
