# Documents reference

> Each document consent-kit docs generates, the documents report, the gap codes, and the phrase API of @consent-kit/documents.

Each document `consent-kit docs` generates, the documents report, the gap codes, and the phrase API of `@consent-kit/documents`.

For the model behind it, read [documents and phrase review](/docs/manual/concepts/documents-and-phrase-review/).

> [!WARNING]
> Generated text is not legal advice. Every phrase was drafted by a non-lawyer and is a draft until a lawyer's review of exactly that text is on record. As shipped, no phrase has a review on record: every generated document is stamped as an unreviewed draft.

## What is generated

One set per registry locale that the phrase library has a language for. The library is written in English and German; a registry locale such as `de-AT` uses the German texts. A locale with no language in the library is skipped, listed under `skippedLocales`, and reported as a required gap.

| Document | Files | Contents |
| --- | --- | --- |
| Privacy policy | `privacy-policy.<locale>.md` | See [sections](#privacy-policy-sections). |
| Cookie table | `cookies.<locale>.md`, `.json` | One row per artefact: type, name or pattern, duration, purpose, service provider, whether consent is required. |
| Record of processing activities | `ropa.<locale>.md`, `.csv` | The controller, one entry per purpose (description, legal basis, data subjects, personal data, recipients, third-country transfers, erasure period), and the security measures. Art. 30 GDPR. |
| Processor list | `processors.<locale>.md`, `.json` | One row per processor: legal entity, role, country, transfer safeguard, purposes, DPA link, privacy information, where to send subject requests. |
| Field notices | `field-notices.<locale>.json` | For every field of every collection point: the text to show, or the label of a consent checkbox. |
| Imprint | `imprint.<locale>.md` | The provider identification ("Impressum", § 5 DDG, § 18 (2) MStV). Written only when the registry declares `imprint`. See [imprint](#imprint). |
| Changelog entry | `changelog-entry.<locale>.md`, `.json` | "What changed", in visitor-facing words. Written only while the registry has unreleased changes. |

Generation is pure: the same registry, lock and `privacy.documents.json` always give the same files. The generator never reads the clock. A date appears only when `generatedAt` is set in `privacy.documents.json`.

### Privacy policy sections

Sections are numbered in order; a section that does not apply is left out.

| Section | Source in the registry |
| --- | --- |
| (the `intro` slot) | `privacy.documents.json` |
| Controller | `controller.name`, `.address`, `.contact` |
| Representative in the Union | `controller.euRepresentative`, when present |
| Data protection officer | `controller.dpo`, when one is named. With `dpo: false` no section is printed. |
| Purposes and legal bases of processing | `purposes`, grouped by lawful basis. Per purpose: description, categories of data (special categories marked), storage period, recipients, and the legitimate interest where that is the basis. |
| Recipients and processors | `processors`, with the purposes each receives data for. |
| Transfers to third countries | Processors whose `country` is outside the EU/EEA, with their `transferMechanism`. |
| Cookies and similar technologies | A link to the cookie table (`cookieTableLinks`, or the generated file's name). |
| Your rights | Fixed text. With `subjectRequests`: a link to the request form (`subjectRequestFormLinks`, or the endpoint), the types it takes, and how long a request record is kept after closing. |
| Withdrawing your consent | The consent purposes and how to withdraw. With `receipts.endpoint`, a sentence that each choice is kept as proof and what the record holds. With the opt-out, nothing about a record; the opt-out reason is never printed. |
| Right to lodge a complaint | `controller.supervisoryAuthority` |
| Automated decision-making | `purposes[].automatedDecisionMaking` |
| Whether you are required to provide data | `collectionPoints[].fields[].provision` and `.consequence`, when there are collection points |
| (the `outro` slot) | `privacy.documents.json` |

### Imprint

Written only with `imprint` in the registry; without it there is no `imprint.<locale>.md`. Each section appears only when its data is there. The German text is the one that counts legally; the English one is a translation for visitors.

| Section (de / en) | Source in the registry |
| --- | --- |
| Angaben gemäß § 5 DDG / Information pursuant to § 5 DDG | `controller.name`, `imprint.legalForm`, `controller.address`, then `imprint.representedBy` ("Vertreten durch") |
| Kontakt / Contact | `controller.contact` as the email address, `imprint.phone`, `imprint.contactForm`. With neither of the last two: the advisory gap `imprint_second_contact_missing`. |
| Registereintrag / Register entry | `imprint.register`: the register, the court and the number |
| Umsatzsteuer-ID / VAT ID | `imprint.vatId` (§ 27a UStG) |
| Wirtschafts-ID / Business ID | `imprint.businessId` (§ 139c AO) |
| Verantwortlich für den Inhalt nach § 18 Abs. 2 MStV / Responsible for the content pursuant to § 18(2) MStV | `imprint.editorialResponsible`: name and address |

For a one-person studio with a phone number and a VAT ID, the German imprint reads:

```markdown
# Impressum

## Angaben gemäß § 5 DDG

**Jane Doe**  
Musterstraße 1, 10115 Berlin

## Kontakt

E-Mail: hello@studio.example  
Telefon: +49 30 1234567

## Umsatzsteuer-ID

Umsatzsteuer-Identifikationsnummer gemäß § 27a Umsatzsteuergesetz: DE123456789
```

Like every Markdown document it starts with the stamp comment and, while a phrase in it is unreviewed, the "Unreviewed draft" banner, and it ends with the policy hash. Regulated professions, licensed activities, share capital and the consumer dispute resolution statement (§ 36 VSBG) are not covered; see the [registry reference](/docs/manual/reference/registry/#imprint).

### The built-in purpose of subjectRequests

With `subjectRequests`, every document lists the purpose `subject-requests`, "Handling your data protection requests", under legal obligation. It is listed like any other: with its data categories, storage period ("3 years after the request is closed"), recipients and data subjects. Its texts and the names of its data categories, data subjects and retention event come from the phrase library, unless the registry's glossaries name the same ids. They count as used only in the documents that print them.

### Fulfilment checklist

`fulfilmentChecklist(registry, type, { locale? })` returns, as plain text, the steps for answering one request type. `consent-kit build` puts one per offered type and locale into `subject-requests.manifest.gen.json`, and the handler adds it to every notification. The steps are:

1. Check that the request comes from the person the data is about (Art. 12(6)).
2. For each purpose (the built-in one included), its data categories, basis and retention. Where its data lives: its artefacts, its collection points, and for the built-in purpose the request records. Then its recipients.
3. Each third-party processor, with its `subjectRequestProcess`, or a line saying that none is recorded.
4. For erasure only: the purposes under `legal_obligation`, whose data must be kept (Art. 17(3)(b)).
5. With `receipts.endpoint`: `findReceipts` for access, and for erasure the decision whether receipts are still needed as proof before `eraseReceipts`.
6. Answer by the due date, extend with reasons if needed (Art. 12(3)), and close the request with its outcome.

The checklist lists what the registry declares, and nothing more.

### Field notices

```json
{
  "correction_form": {
    "display_name": {
      "purpose": "contributor_credit",
      "basis": "consent",
      "kind": "consent_checkbox",
      "preChecked": false,
      "required": false,
      "provision": "voluntary",
      "provisionLabel": "Voluntary",
      "consequence": null,
      "text": "I consent to this information being used for the following purpose: Crediting you by name. …",
      "source": "generated"
    },
    "email": {
      "purpose": "correction_reply",
      "basis": "contract",
      "kind": "notice",
      "required": true,
      "provision": "contractual",
      "provisionLabel": "Required by contract, or necessary to enter into a contract",
      "consequence": "Without an email address we cannot reply to your report.",
      "text": "We use this only to reply about this report; deleted 30 days after it is closed.",
      "source": "registry"
    }
  }
}
```

The file has the shape `{ "_meta": {…}, "notices": { <collection point id>: { <field name>: {…} } } }`.

| Field | Meaning |
| --- | --- |
| `kind` | `notice`: text shown next to the field. `consent_checkbox`: the label of a checkbox the visitor has to tick before the field may be used for this purpose. Used when the field's purpose is based on consent. |
| `preChecked` | Only for `consent_checkbox`, and always `false`. |
| `text` | The field's own `notice` from the registry, or a text written from the purpose with the phrase library. |
| `source` | `registry` or `generated`. |

consent-kit generates this file; rendering the notices and the checkbox in your form is your code's job.

### Stamps

Every Markdown document starts with a comment:

```
<!-- Generated by @consent-kit/documents. Do not edit: change the registry, the slots or the phrase overrides and generate again. document=privacy-policy locale=en policy=72ab647d… revision=2 generated-at=none phrases=bd6991600467 overrides=none slots=none -->
```

`phrases` is the hash of the phrase library, `overrides` and `slots` are hashes of the overrides and slots in use. JSON documents carry the same information under `_meta`, including the ids of the unreviewed phrases they use.

While a document uses at least one unreviewed phrase, it carries this banner, in its own language, directly under the comment:

> **Unreviewed draft: this document contains 67 generated text passage(s) that have not been legally reviewed. Do not publish it without review.**

Every Markdown document ends with the policy hash, the revision and, when set, the date. The CSV record has a column `unreviewed_text`.

## The documents report

`consent-kit docs` prints it; `docs --json` prints it as JSON.

```
unreviewed  196 phrase texts in use have not been legally reviewed (98 de, 98 en). The documents are stamped as unreviewed drafts. List them with --json.

196 unreviewed phrase texts, 0 overrides, 0 required gaps, 0 advisory gaps. Generated text is not legal advice.
```

| Field | Meaning |
| --- | --- |
| `ok` | `false` when `errors` is not empty. `docs` then writes nothing and exits 1. |
| `errors` | `{ code, message }`. Codes: `unreviewed_phrases` (only with `--require-reviewed`), `override_rejected`, `unknown_slot`, `unknown_locale`. |
| `policyHash` | The policy hash stamped on the documents. |
| `phraseLibraryHash` | One hash over every id and text in the library. It changes whenever any phrase changes. |
| `locales`, `skippedLocales` | Registry locales that were written, and those the library has no language for. |
| `unreviewedPhrases` | `{ id, locale, source, files }` for every phrase in use that no lawyer has reviewed, including unreviewed overrides. `source` is `library` or `override`. |
| `overrides` | Every project override that was applied: `{ id, locale, status, text, libraryText, files }`. `status` is `reviewed` only when the override carries the project's own review of exactly this text. |
| `rejectedOverrides` | Overrides that could not be applied: `{ id, locale, reason }`. |
| `gaps` | See below. |
| `slots` | `{ filled, notApplicable }`: slot ids that had text, and those set to `false`. |

### Gaps

A gap is something a document needed that the registry does not state. `subject` is the registry field that would close it.

| Code | Severity | Meaning |
| --- | --- | --- |
| `registry_statement_missing` | required | A statement the validator requires is absent. Only possible for a registry that was not validated; the CLI never produces it. |
| `locale_unsupported` | required | A registry locale has no language in the phrase library. No documents are written for it. |
| `controller_address_missing` | advisory | `controller.address` is not set. |
| `data_category_label_missing` | advisory | A data category has no name; the documents print the id. |
| `data_subject_label_missing` | advisory | A data subject category has no name. |
| `retention_event_label_missing` | advisory | A retention event has no description. |
| `purpose_recipients_unknown` | advisory | A purpose has no recipient: no artefact binds a third-party processor to it and it lists none. Add `processors: []` to state that there are none. |
| `processor_dpa_missing` | advisory | A third-party processor in the `processor` role has no `dpaUrl`. |
| `security_measures_missing` | advisory | `securityMeasures` is not set. |
| `storage_lifetime_undeclared` | advisory | A storage artefact has no `duration`. |
| `imprint_second_contact_missing` | advisory | `imprint` has neither `phone` nor `contactForm`: the imprint names only an email address, and § 5 (1) no. 2 DDG is commonly read to ask for a second fast channel. |

Gaps never fail `docs`. A required gap means a document is incomplete; an advisory gap means it reads worse or may be incomplete.

## Phrases

Every sentence the generator can write is a phrase in `packages/documents/src/phrases/library.ts`: an id, an English text, a German text and a note that says where it appears. The shipped library has 284 phrases, 568 texts.

| Property | Rule |
| --- | --- |
| Id | Stable, such as `basis.consent.explanation`. An id is never reused for a different meaning. |
| Placeholders | `{name}` is filled in from the registry. English and German use exactly the same placeholders. |
| Status | `draft`, or `reviewed` when a review of exactly this text is on record. |
| Content hash | Lowercase hex SHA-256 of the text, Unicode-normalised (NFC). A review is pinned to it. Editing a text changes the hash and invalidates the review. |

A phrase states nothing the registry does not declare. Where a document needs a fact the registry does not hold, the fix is a registry field, not a sentence.

### API

Exported from `@consent-kit/documents`:

| Export | What it does |
| --- | --- |
| `generateDocuments(registry, options)` | Returns `{ files, report }`. What `consent-kit docs` calls. |
| `changelogEntry(…)` | The "what changed" entry on its own. |
| `PHRASES`, `PHRASE_IDS`, `PHRASE_LOCALES` | The library, its ids, and `['en', 'de']`. |
| `PHRASE_REVIEWS` | The reviews shipped with the package. Empty as shipped. |
| `exportPhrases({ reviews? })` | The whole library as one Markdown document: the file to send to a lawyer. One row per phrase with both texts, the status per locale with the short content hash, and where the phrase appears. |
| `phraseContentHash(text)` | The hash a review is pinned to. |
| `phraseLibraryHash()` | One hash over the whole library. |
| `phraseStatus(id, locale, reviews?)` | `{ status, review?, staleReview? }`. A review whose hash no longer matches is reported as `staleReview`. |
| `recordReview(reviews, { id, locale, reviewer, date, expectedHash? })` | Returns a new list with the review recorded against the current text. Refuses when `expectedHash` (full or a prefix) no longer matches the text. |
| `renderReviewsModule(reviews)` | The source of `phrases/reviews.ts` for a list of reviews. |
| `checkOverrides(overrides)` | The overrides that cannot be applied. |
| `createPhraser(locale, options)` | A phrase source for one locale that records every phrase it hands out. |
| `phraseLocaleFor(locale)` | The library language that serves a registry locale: `de-AT` gives `de`. |

There is no CLI command for exporting phrases or recording a review. See [record a legal review](/docs/manual/guides/record-a-legal-review/) for the steps.
