Sub topic 7
Recording proof of consent
This chapter assumes you know what valid consent means (freely given, specific, informed, unambiguous), can read short HTML and Python snippets, and have seen how a double opt-in flow works. It covers what to store, how to store it, and the mistakes that make records useless. This is general education, not legal advice.
Why records matter
Under GDPR and UK GDPR, the controller must be able to demonstrate that a person consented. Under CASL, the sender carries the burden of proving consent. CAN-SPAM does not require opt-in, but records of opt-outs matter there. In practice, a regulator, a complaint, or a email provider's abuse team may ask: "Show me how you got this address." A row in a list that says only [email protected] cannot answer that.
What a consent record contains
A useful record answers who, what, where, how, and when.
| Field | Question it answers | Example |
|---|---|---|
| `email` | Who agreed | [email protected] |
| `purpose` | What they agreed to | monthly_newsletter |
| `consent_text` and `consent_text_version` | The exact wording they saw | 2026-11-v3 |
| `source_url` | Where they agreed | https://example.com/newsletter |
| `method` | How they agreed | unticked_checkbox |
| `collected_at` | When they ticked the box | 2026-11-26T13:56:57Z |
| `confirmed_at` | When they clicked the confirmation link | 2026-11-26T14:02:10Z |
| `withdrawn_at` | When they withdrew, if ever | null |
Here is one record in JSON.
{
"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
}The record stores the wording itself, not just a version label. If your version table is lost or edited later, the record still shows what the person saw. Keep the version label as well, so you can find everyone who saw the same text.
Where the timestamps come from
Each timestamp should be written by your server when the event happens. Do not accept a time sent by the browser. Store times in UTC.
Two moments matter with double opt-in. collected_at is when the form was submitted. confirmed_at is when the link was clicked. Only the second proves the address owner agreed, so mailing should depend on confirmed_at, not collected_at.
The signed token from the confirmation flow helps here. Your confirmation handler can verify the token and then set the timestamp.
import hashlib
import hmac
from datetime import datetime, timezone
SECRET_KEY = b"load-this-from-an-environment-variable"
MAX_AGE_SECONDS = 48 * 60 * 60
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)
def confirm(record: dict, token: str) -> dict:
now = datetime.now(timezone.utc)
if not verify_token(record["email"], token, int(now.timestamp())):
raise ValueError("Invalid or expired token")
record["confirmed_at"] = now.strftime("%Y-%m-%dT%H:%M:%SZ")
return record
if __name__ == "__main__":
record = {"email": "[email protected]", "confirmed_at": None}
issued = int(datetime.now(timezone.utc).timestamp())
message = f"{record['email']}|{issued}".encode()
sig = hmac.new(SECRET_KEY, message, hashlib.sha256).hexdigest()
print(confirm(record, f"{issued}.{sig}"))Common errors
- Overwriting history. When someone withdraws and later re-subscribes, do not edit the old row. Add a new record, or keep an append-only event log. Otherwise the proof for the first consent disappears.
- Storing only a boolean. A column
opted_in = trueshows nothing about wording, source, or time. - Importing without evidence. Lists moved from another tool often lose their metadata. Keep the original export, or mark those rows as "no proof" so you can find them during an audit.
- Keeping too much. Records are personal data too. Store what proves consent, such as the text, source, and times. Do not store extras like full browser fingerprints without a reason.
- Deleting evidence after withdrawal. You must stop emailing, but you should keep a minimal record that the person withdrew. A suppression list does this job.
Keeping the records usable
Store records in a system you can query by email address, so you can answer a single person's request quickly. Restrict write access, and log changes. Keep the records for as long as you may need to defend the mailing, and set a retention period you can explain.
Exercise
A subscriber's row shows only an email address and opted_in = true, imported from an old tool. List three fields you would need to add to turn it into usable proof, and say what you should do with existing rows that cannot be filled in.
Show answer
Any three of: the exact consent text (or its version), the source URL, the method (such as unticked checkbox), the collected time, and the confirmed time. Rows that cannot be filled in should be flagged as having no proof, and treated as candidates for a re-permission campaign or removal rather than being mailed as if they were consented.