Sub topic 7
Recording proof of consent
This chapter assumes you have read the earlier chapters on valid consent, sign-up forms, and double opt-in. You should know the criteria for valid consent (freely given, specific, informed, unambiguous). You should also be able to read a short Python or JSON snippet. This is general education, not legal advice.
Why a record matters
Under GDPR and UK GDPR, the controller must be able to demonstrate that a person consented (Article 7(1)). If a regulator or a complaining subscriber questions your mailing, "they ticked the box" is a claim. A record is evidence.
CASL in Canada goes further in practice. If you rely on express consent, the burden of proving it is on the sender. CAN-SPAM in the US is not consent-based, but you still need records of opt-outs to honor them.
A consent record answers six questions:
- Who agreed?
- What exactly did they agree to?
- Which wording did they see?
- Where and how did they agree?
- When did they agree, and when did they confirm?
- Has anything changed since?
A row in your mailing tool that says subscribed = true answers only the first. It cannot show what the person saw.
What to store
Here is a record that answers all six questions. It matches the form from the sign-up chapter.
{
"email": "[email protected]",
"purpose": "monthly_newsletter",
"consent_text_version": "2026-11-v3",
"consent_text": "Email me the monthly Example Co. product newsletter. You can unsubscribe at any time.",
"source_url": "https://example.com/newsletter",
"method": "unticked_checkbox",
"collected_at": "2026-11-26T13:56:57Z",
"confirmed_at": "2026-11-26T14:02:10Z",
"withdrawn_at": null
}Each field has a job.
| Field | What it proves |
|---|---|
| `email` | Who the record belongs to |
| `purpose` | The specific use consented to, not a vague "marketing" |
| `consent_text_version` | Which version of the wording was live |
| `consent_text` | The exact words shown, copied into the record |
| `source_url` | The page or form where consent was collected |
| `method` | How the person acted, for example an unticked checkbox they ticked |
| `collected_at` | When the form was submitted |
| `confirmed_at` | When the owner clicked the double opt-in link |
| `withdrawn_at` | When consent ended, or `null` if it has not |
Store the wording, not just a version label
A version ID such as 2026-11-v3 is useful for grouping. It is worthless if the page that used it has since changed and you kept no copy. Store the full text in the record, or keep an immutable archive of each version. The example does both.
Consider adding technical context
Many teams also store the IP address, user agent, and form identifier. These help show that a submission came from a real browser session. They are personal data too, so keep them only if you have a reason and a retention period. They are supporting evidence. They are not proof that the owner of the mailbox consented, because anyone can type someone else's address into a form.
Why double opt-in strengthens the record
A form submission shows that someone entered an address. It does not show that the address owner did. Confirmation closes that gap. When the owner clicks a link sent to the mailbox, confirmed_at records that control of the address was demonstrated.
The token in the confirmation link must be tamper-proof, or anyone could forge a confirmation. The code below signs the address and issue time with an HMAC and rejects expired tokens.
import hashlib
import hmac
SECRET_KEY = b"load-this-from-an-environment-variable"
MAX_AGE_SECONDS = 48 * 60 * 60
def make_token(email: str, issued_at: int) -> str:
message = f"{email}|{issued_at}".encode()
signature = hmac.new(SECRET_KEY, message, hashlib.sha256).hexdigest()
return f"{issued_at}.{signature}"
def verify_token(email: str, token: str, now: int) -> bool:
try:
issued_text, signature = token.split(".", 1)
issued_at = int(issued_text)
except ValueError:
return False
if now - issued_at > MAX_AGE_SECONDS:
return False
message = f"{email}|{issued_at}".encode()
expected = hmac.new(SECRET_KEY, message, hashlib.sha256).hexdigest()
return hmac.compare_digest(signature, expected)Two details matter. hmac.compare_digest compares in constant time, which avoids leaking information about the signature. The secret key must come from an environment variable or a secrets manager, as the placeholder says, and never from source code.
Only when verify_token returns True should you set confirmed_at and begin sending. Until then, the record exists but the address is pending.
Recording withdrawal
Consent evidence covers the whole life cycle. When someone unsubscribes, set withdrawn_at and stop sending to that purpose. Do not delete the whole record. You need to show that you honored the withdrawal, and you need to remember not to email the person again.
This creates a tension with data minimization. The usual answer is to keep a minimal suppression entry (the address or a hash of it, the purpose, and the date) for as long as you need to prevent re-adding the person. Delete the richer data, such as IP address and full form content, on your normal retention schedule.
Designing the storage
Keep history instead of overwriting
If the same person consents, withdraws, then consents again, a single row with changing fields loses history. Prefer an append-only log of events, with a current-state view derived from it.
from dataclasses import dataclass
from datetime import datetime, timezone
@dataclass(frozen=True)
class ConsentEvent:
email: str
purpose: str
event: str # "collected", "confirmed", or "withdrawn"
text_version: str
source_url: str
at: datetime
def current_status(events: list[ConsentEvent], email: str, purpose: str) -> str:
relevant = [e for e in events if e.email == email and e.purpose == purpose]
if not relevant:
return "none"
latest = max(relevant, key=lambda e: e.at)
return {
"collected": "pending",
"confirmed": "active",
"withdrawn": "withdrawn",
}[latest.event]
log = [
ConsentEvent("[email protected]", "monthly_newsletter", "collected",
"2026-11-v3", "https://example.com/newsletter",
datetime(2026, 11, 26, 13, 56, 57, tzinfo=timezone.utc)),
ConsentEvent("[email protected]", "monthly_newsletter", "confirmed",
"2026-11-v3", "https://example.com/newsletter",
datetime(2026, 11, 26, 14, 2, 10, tzinfo=timezone.utc)),
]
print(current_status(log, "[email protected]", "monthly_newsletter"))Running this prints active. Adding a withdrawn event with a later timestamp would change the result to withdrawn while keeping the full history.
Use UTC timestamps
Store times in UTC in ISO 8601 form, as in the examples. Mixed time zones make it hard to order events and to defend the sequence later.
Make records hard to alter
Evidence is weaker if anyone can edit it silently. Limit write access, log changes, and back the data up. For higher-risk lists, consider write-once storage or hash chaining. These measures are not legally required in most places. They make your evidence more credible.
Common errors
- Storing only a boolean.
opted_in = trueshows nothing about wording, source, or time. - Losing the text. The consent page is edited, and no copy of the old wording exists.
- One field for all purposes. A single
marketing_consentflag cannot show consent to a newsletter versus partner offers. The purposes chapter explains why these must be separate. - Overwriting on re-subscribe. The earlier withdrawal vanishes, and you cannot show your history.
- Trusting imports. Migrating a list into a new tool and stamping every row with the import date creates false evidence. Preserve the original collection date and source, or mark the consent as unproven.
- Keeping everything forever. Records need a retention rule. Keep them while the consent is active and for a defined period afterward, set with your legal adviser.
- Hiding evidence in a vendor tool. If your email platform holds the only copy and you cannot export it, you cannot produce it on request.
Producing records on request
Test that you can answer these requests quickly:
- A regulator asks you to demonstrate consent for one named address.
- A subscriber asks what data you hold about them (a subject access request).
- A subscriber claims they never signed up.
For each, you should be able to pull the record, show the wording, the source, the confirmation time, and any withdrawal. Run this as a drill once, with a real address, before you need it. The gaps you find are usually fields you assumed were saved.
Quick checklist
- Each record names one purpose.
- The exact consent text is stored or archived by version.
- Source, method, and UTC timestamps are present.
- Double opt-in confirmation is stored as a separate timestamp or event.
- Withdrawals are recorded and kept in a suppression list.
- History is append-only or otherwise preserved.
- Retention periods are defined and enforced.
- You have tested producing a record on request.
Exercise
A colleague proposes migrating an old list into a new platform and setting collected_at to the migration date and source_url to the new newsletter page for all 40,000 rows. What is wrong with this, and what should be done instead?
Show answer
It creates false evidence. The migration date is not when people consented, and the new page is not where they consented, so the records would misstate how consent was obtained. Instead, import the original collection date, source, and wording where they exist. Mark contacts without proof as unproven (for example, a status such as "legacy_unverified"), and plan a re-permission campaign for them. Do not email them as if consent were documented.
Exercise
Name three fields from the consent record that you would need in order to show that a subscriber saw the exact wording and confirmed their address, and say why a version label alone is not enough.
Show answer
consent_text (or an archived copy by version), collected_at, and confirmed_at. A version label is only a pointer. If you kept no copy of the text it refers to, you cannot show what the person actually saw.
Exercise
A subscriber withdraws consent. Why should you not simply delete their entire consent record?
Show answer
You need to prove that you honored the withdrawal, and you need to avoid re-adding or emailing the person by mistake. Keep a minimal suppression entry (address or hash, purpose, withdrawal date) and delete the richer data, such as IP address, on your retention schedule.