Data deletion and GDPR erasure
Erasure cannot be undone and has a deadline. Let the agent prepare each deletion, a person approve it, and the record show who did.
Updated
An erasure request is the rare agent task where both doing too little and doing too much break the law. Under the GDPR, a person can ask you to erase their data, and you have to act without undue delay. But some of their data you must keep, and deleting it is its own mistake.
The risk
- Deleting what must stay. Article 17(3) lists when erasure does not apply, such as data you must keep to comply with a legal obligation. Invoices are the usual example.
- Deleting the wrong person. Two customers with the same name, or an email address shared by a family.
- Missing the deadline. Article 12(3) gives one month from receipt to tell the person what was done, extendable by two further months for complex or numerous requests.
- No proof. If a regulator asks how a request was handled, “the agent did it” is not an answer.
Let the code sort the request
The agent finds the person’s data and works out what would go and what must stay. Your code then names the action by how much judgement it needs:
data.erase.subscriber: only a mailing-list contact. Nothing to keep.data.erase.customer: an account, orders or tickets. Something may have to stay.data.delete_bulk: a scheduled retention clean-up across many people.
The rules
- Always ask about data.erase.customer, for Sara, anyone after a dayA customer has orders, invoices and tickets, and some of that must be kept. The privacy lead decides what goes.
- Always ask about data.delete_bulk, two peopleA retention clean-up across many people needs two different people to approve the same list.
- Never allow data.*, for support-botThe support agent hands erasure requests to the privacy agent. It never deletes anything itself.
- Always allow data.erase.subscriber, for privacy-agent (added later)Removing someone who is only on the mailing list, with nothing to keep. Add it once you have approved enough of them to trust the agent's sorting.
The same rules as API bodies
# POST /v1/workspaces/{workspace_id}/rules, one call per rule
{
"action": "data.erase.customer",
"deciders": [
"USER_ID_OF_SARA"
],
"effect": "ask",
"escalate_after_seconds": 86400
}
{
"action": "data.delete_bulk",
"approvals": 2,
"effect": "ask"
}
{
"action": "data.*",
"agent_key_id": "SUPPORT_BOT_KEY_ID",
"effect": "deny"
}
{
"action": "data.erase.subscriber",
"agent_key_id": "PRIVACY_AGENT_KEY_ID",
"effect": "allow"
}Owners write rules under Rules in the app, or post these bodies while signed in. Replace the ids in capitals with your own.
The agent’s side
import { ApprovalClient } from "@variantgate/agent";
const approvals = new ApprovalClient({
agent: "privacy-agent",
apiUrl: process.env.VARIANTGATE_API_URL ?? "https://api.variantgate.com",
key: process.env.VARIANTGATE_KEY ?? "",
});
export async function erase(dsr: SubjectRequest) {
const plan = await findPersonalData(dsr.subjectId);
return approvals.guard(
{
action: plan.hasAccount ? "data.erase.customer" : "data.erase.subscriber",
summary: `Erase ${dsr.reference}: ${plan.total} records in ${plan.systems.length} systems`,
details: { request: dsr.reference, "answer by": dsr.deadline, ...plan.counts, kept: plan.kept ?? "nothing" },
ttlSeconds: 3 * 24 * 60 * 60,
},
async () => {
const done = await plan.execute(); // exactly the plan that was approved
return `deleted ${done.total} records`;
}
);
}from variantgate import VariantGateError, require_approval
def erase(dsr) -> str:
"""Erases one data subject's records after a person approves the plan."""
plan = find_personal_data(dsr.subject_id) # what would go, and what must stay
action = "data.erase.customer" if plan.has_account else "data.erase.subscriber"
try:
with require_approval(
action,
# A reference, never the person's email: the record outlives the data.
f"Erase {dsr.reference}: {plan.total} records in {len(plan.systems)} systems",
agent="privacy-agent",
details={
"request": dsr.reference,
"answer by": dsr.deadline.isoformat(),
**{f"delete in {name}": count for name, count in plan.counts.items()},
"kept": plan.kept or "nothing",
},
ttl_seconds=3 * 24 * 60 * 60,
) as approval:
done = plan.execute()
approval.note = f"deleted {done.total} records"
return f"Erased {dsr.reference}."
except VariantGateError as refused:
return f"Not erased. {refused}"curl -X POST https://api.variantgate.com/v1/requests \
-H "authorization: Bearer $VARIANTGATE_KEY" \
-H 'content-type: application/json' \
-d '{
"action": "data.erase.customer",
"agent": "privacy-agent",
"details": {
"answer by": "2026-12-11",
"delete in billing": "0 (invoices kept)",
"delete in crm": "1 contact, 14 notes",
"delete in helpdesk": "6 tickets",
"kept": "3 invoices, kept as tax law requires",
"request": "DSR-2026-118"
},
"summary": "Erase DSR-2026-118: 21 records in 3 systems, 3 invoices kept",
"ttl_seconds": 259200
}'{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "request_approval",
"arguments": {
"action": "data.erase.customer",
"agent": "privacy-agent",
"details": {
"answer by": "2026-12-11",
"delete in billing": "0 (invoices kept)",
"delete in crm": "1 contact, 14 notes",
"delete in helpdesk": "6 tickets",
"kept": "3 invoices, kept as tax law requires",
"request": "DSR-2026-118"
},
"summary": "Erase DSR-2026-118: 21 records in 3 systems, 3 invoices kept",
"ttl_seconds": 259200
}
}
}Put a reference such as DSR-2026-118 in the request, never the person’s email or name. The record of decisions is kept, and its seal makes any later edit visible, so an address in it would outlive the erasure it records. Keep the link between reference and person in your request tracker, where it can be deleted when the case closes.
- The request stays open for three days, well inside the one-month limit. It goes to the privacy lead first, and to everyone after a day. Workspace owners can decide a routed request at any time, so if only the privacy lead may approve erasures, handle them in a workspace where the privacy lead is the only owner.
- The code runs exactly the plan the person approved. Finding the data again after the approval could delete things nobody saw.
- The outcome note records how many records were deleted, so the record holds both the decision and the result.
What the person approving sees
privacy-agent
data.erase.customer · asked just now
Erase DSR-2026-118: 21 records in 3 systems, 3 invoices kept
For sara@example.com
- answer by
2026-12-11
- delete in billing
0 (invoices kept)
- delete in crm
1 contact, 14 notes
- delete in helpdesk
6 tickets
- kept
3 invoices, kept as tax law requires
- request
DSR-2026-118
- Counts per system, the deadline, and what is kept and why. The “kept” line is the one to check.
- Deny with a note such as “Also keep the open ticket, it is part of a dispute”. The agent reads the note in
decision_note, changes the plan and asks again. - Approve, and the record shows who approved which plan, when, and the outcome the agent reported.
Rolling it out
- Start with no allow rules. Write the routed ask rule and the deny for the support agent; every erasure waits for a person.
- Check the sorting. For a few weeks, look at every request the agent named
data.erase.subscriber. Was there really nothing to keep? - Then allow subscriber erasures for the privacy agent’s key. Customer erasures stay with a person.
- Export the record when you need to show how requests were handled. The CSV has who decided and when, and leaves the details out.
Schema-level deletes and DELETE statements are in database migrations and destructive SQL. What a decision record should hold is in what an audit trail for AI agents should record. This guide describes a workflow; it is not legal advice.