Skip to content

Beta. consent-kit is at 0.x: expect breaking changes between releases, and treat everything it generates as a draft. Report a problem or share feedback.

Add a request form to the site, receive requests in a Cloudflare Worker on D1, and email each one to the controller’s mailbox. This guide follows examples/static-site (the form) and examples/cloudflare-receipts (the Worker). Read data subject requests first.

It assumes the site already keeps consent receipts in a Worker, as in deploy the receipt endpoint. The two share the HMAC key, the database and the Worker.

subjectRequests:
endpoint: /privacy/requests # site-relative: on the site's own domain
notify: privacy@example.com # every request is emailed here
types: [access, erasure]
retention: 3y # how long a closed request is kept; no default

Run consent-kit check. Adding the section is not material, so it asks for no version bump and nobody is asked for consent again. The documents gain the built-in purpose “Handling your data protection requests” and a link to the form in the rights section. Run consent-kit docs and have the new phrases reviewed.

To email the requester a confirmation link too, declare the provider as a processor and name it:

processors:
- id: resend
name: Resend
legalEntity: Resend, Inc.
country: US
transferMechanism: dpf
subjectRequests:
# …
requesterEmail:
processor: resend

consent-kit build writes subject-request-form.<locale>.html (a fragment) and subject-request-page.<locale>.html (a complete page). Embed the fragment in a page of the site and link that page from every page, for example next to the privacy policy. The static site example does it in src/build.ts:

.replace('{{SUBJECT_REQUEST_FORM}}', () => readFileSync(join(genDir, 'subject-request-form.en.html'), 'utf8'))

Style the form by its classes. Hide the honeypot, which people must never see:

.ck-subject-request .ck-hp { display: none; }

If the policy links the form somewhere other than the endpoint, say where in privacy.documents.json:

{ "subjectRequestFormLinks": { "en": "/privacy-request.html" } }

Without a page of your own, the handler serves the generated page at GET /privacy/requests.

The endpoint must be on the site’s zone, so that the browser sends cc_cookie with the form:

routes = [
{ pattern = "www.example.com/consent-receipts", zone_name = "example.com" },
{ pattern = "www.example.com/privacy/requests", zone_name = "example.com" },
]

src/worker.ts sends that path to createSubjectRequestHandler and passes the ExecutionContext, so the emails go out after the answer:

fetch(request, env, context) {
return new URL(request.url).pathname === requestsManifest.endpoint
? handlers.requests(request, context)
: handlers.receipts(request);
}

migrations/0002_subject_requests.sql creates the request table and the rate-limit table. It is a copy of the one @consent-kit/server ships:

Terminal window
pnpm exec wrangler d1 migrations apply DB --remote

Set up Cloudflare Email Service for the domain the emails are sent from. Then bind the mailbox and set the sender:

[vars]
REQUESTS_FROM = "Privacy requests <requests@example.com>"
[[send_email]]
name = "PRIVACY_EMAIL"
destination_address = "privacy@example.com"

The binding can send to that one address only, which is all the notification and the reminder need. With requesterEmail, also set the provider’s key: pnpm exec wrangler secret put RESEND_API_KEY.

[triggers]
crons = ["0 7 * * *"]

The Worker’s scheduled handler deletes closed requests past their retention (sweepClosedRequests) and sends one reminder of the open requests that are overdue, due within 7 days, or never notified (remindDueRequests). It sends nothing when there are none.

Add a Cloudflare rate-limiting rule for POST /privacy/requests. The handler limits confirmation emails per address and in all, but it stores no IP address, so it cannot limit per client itself.

Terminal window
pnpm run deploy
consent-kit audit https://www.example.com --page / --page /about.html

The audit’s “Subject requests reachable” check finds the form on a page or one link away, and checks that it posts to the site’s own origin. It then submits it from audit-…@consent-kit.invalid and expects the 303. Against the live site this files one real request, and the controller’s mailbox receives its notification. Close it as an audit test. The handler sends no confirmation email to .invalid addresses.

The notification carries the checklist. When you are done, close the request:

await store.close(id, { outcome: 'data sent', at: new Date().toISOString() });

For a complex request, record an extension and tell the requester why, within the first month:

await store.extend(id, { dueAt: addMonths(new Date(request.receivedAt), 3).toISOString(), reason: 'Many systems to search.' });

findReceipts(receiptStore, request.subjectHash) lists the consent receipts of the browser that sent the request. eraseReceipts deletes them, once you have decided that you no longer need them as proof of consent.

consent-kit

Generate your cookie banner and privacy-policy drafts from one registry, and audit what your site really does against it.

© 2026 consent-kit · Released under the MIT licence.