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

  1. 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.
  2. Always ask about data.delete_bulk, two peopleA retention clean-up across many people needs two different people to approve the same list.
  3. Never allow data.*, for support-botThe support agent hands erasure requests to the privacy agent. It never deletes anything itself.
  4. 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`;
    }
  );
}

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

2 d left

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

How this request looks in the inbox, with example values.
  • 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

  1. Start with no allow rules. Write the routed ask rule and the deny for the support agent; every erasure waits for a person.
  2. Check the sorting. For a few weeks, look at every request the agent named data.erase.subscriber. Was there really nothing to keep?
  3. Then allow subscriber erasures for the privacy agent’s key. Customer erasures stay with a person.
  4. 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.

Sources

  1. Regulation (EU) 2016/679 (GDPR), Article 12(3) on the time limit and Article 17 on the right to erasure, EUR-Lex