How to Implement GDPR Right to Erasure in a Multi-Tenant SaaS
How to implement GDPR right to erasure in a multi-tenant SaaS: PII inventory, hard vs. soft delete, cascading deletions, and handling backups and audit logs.
GDPR Article 17 — the right to erasure, often called the right to be forgotten — is one of the most technically demanding compliance requirements a SaaS team will encounter. When a user or customer submits a deletion request, the obligation is not to flip a deleted_at flag on a users table. It is to identify and remove every piece of personal data tied to that subject across your entire data estate: application databases, backups, analytics pipelines, third-party integrations, audit logs, and cold storage.
In a multi-tenant SaaS where row-level data is mixed across shared tables, that scope is wider than it looks. This guide covers the full engineering implementation: mapping your PII surface, designing a deletion model that is both compliant and operationally safe, handling cascading deletes across relationships and external systems, and managing the data stores that most teams miss. For the complementary topic of multi-tenant data architecture, see multi-tenant SaaS architecture patterns.
One caveat before diving in: GDPR right to erasure applies in a B2B SaaS context primarily when the end users of your platform are individuals whose personal data you process directly. If your customers are companies, your customer is the data controller and you are the data processor — deletion requests flow through them. Either way, the engineering implementation is identical: you need a reliable, auditable mechanism to remove personal data on request.
What GDPR Article 17 Actually Requires From a SaaS
Article 17 requires you to erase personal data without undue delay when a subject requests it, subject to limited exceptions: legal obligation to retain data, a legitimate interest override, or a pending contract. 'Undue delay' in practice means within one month — Article 12 sets that bound. The regulation does not define 'erase' technically, but supervisory authorities and enforcement decisions have consistently interpreted it to mean the data can no longer be recovered, not simply that it is hidden.
- →Personal data means any information that can identify a natural person: email address, name, IP address, device identifiers, and any derived identifier. A hashed email is still personal data under most interpretations because it can be re-identified if you have the original list.
- →The obligation is not limited to your primary database. It covers every system that processes that person's data: backups, data warehouses, analytics tools, support ticketing systems, error tracking (Sentry, Datadog), email marketing platforms, and anything you sync to a data lake.
- →Legal retention exceptions: you are not required to delete data you are legally obligated to retain. Financial transaction records are typically retained for 7 years under tax and accounting rules. Audit log entries are protected under GDPR Art. 17(3)(b) where retention is necessary for a legal obligation — but only the event metadata, not the personal identifiers embedded inline. Document these exceptions in your privacy policy and retention schedule.
- →Proof of compliance: when you complete an erasure, you are permitted to retain a minimal record — a pseudonymous user identifier, the request date, and the completion date. This record defends you in a complaint. It does not contain personal data and therefore does not itself require erasure.
Mapping Every Table That Contains Personal Data: The PII Inventory
The first implementation step is a PII inventory — a complete map of every table, column, and external system that stores data attributable to a user or end customer. Most teams skip this step, attempt to implement deletion, and later discover that event logs, analytics events, or a third-party integration still hold data they believed was deleted.
- →Schema scan: for each database table, identify every column that contains personal data. The obvious ones are the users table (email, name, phone, avatar_url) but the non-obvious ones accumulate over time: orders.shipping_address, comments.ip_address, audit_events.actor_email, support_tickets.description, activity_logs.user_agent. Create a matrix that maps each column to a retention category: delete-on-request, anonymize-on-request, or retain-with-documented-exception.
- →Event stores: if you use event sourcing, every domain event that ever referenced a user potentially contains personal data. Event sourcing and GDPR have a fundamental tension — you cannot change immutable events. The practical resolution is indirection: store the event with a subject_id key, and in a separate encryption key store map each subject_id to the actual personal data fields. On erasure, delete the encryption key — the event still exists but the personal fields are unrecoverable. This is cryptographic erasure.
- →Analytics and telemetry: every product analytics event (Mixpanel, Amplitude, PostHog) that you tagged with a user ID or email address is in scope. All three tools have deletion APIs. Trigger them as part of your deletion job. Segment Protocols also has a user deletion endpoint that propagates to connected downstream destinations.
- →Third-party integrations: list every external system you sync user data to — Intercom, HubSpot, Stripe (contact data), Mailchimp, Jira, Zendesk. Each has a contact or user deletion API. Build a checklist and automate the calls; manual processes fail under any significant volume.
- →Backups: point-in-time backups contain personal data, and you cannot feasibly modify them record by record. The standard approach is to document a backup retention period in your privacy policy (typically 30 to 90 days) and honor it. Encryption-at-rest with per-subject key rotation allows cryptographic erasure of backup slices by discarding the subject's key.
The Multi-Tenant Problem: Shared Tables and Row-Level Personal Data
In a shared-schema multi-tenant SaaS — the most common architecture for cost efficiency — personal data from all tenants lives in the same tables. A deletion request from a user at tenant A must remove their rows without affecting tenant B's data, without breaking foreign key relationships, and without leaving orphaned references that corrupt reports.
- →Tenant isolation check: before executing any deletion, verify that the user being deleted belongs to the tenant that submitted the request. An unscoped deletion endpoint that accepts any user_id is a data breach waiting to happen. Always join through the tenant's own records to confirm ownership: DELETE FROM users WHERE id = $1 AND organization_id = $2.
- →Foreign key cascades vs. application-level deletion: PostgreSQL ON DELETE CASCADE handles child rows automatically but requires you to map every FK relationship in advance. Application-level deletion lets you control the order and log each step, which is better for auditability and idempotent retry. Use a database transaction that wraps the full sequence — if any step fails, the deletion rolls back atomically.
- →Anonymization as an alternative to hard delete: for records you cannot remove — an order that an accountant's ledger depends on, a subscription tied to revenue reporting — replace the personal data columns with pseudonymous placeholders. Replace the customer name with 'Deleted User', the email with 'deleted@placeholder.invalid', and clear address fields. The row's numeric identifiers stay intact so reports and aggregations do not break. Document which fields are anonymized versus deleted in your PII inventory.
- →Shared organization data: in B2B SaaS, some data belongs to the organization rather than the individual user. When a user leaves the team, their content (documents, comments, tasks) may remain visible to the team under a 'Former Member' attribution. This is legitimate — the content belongs to the organization as data controller. The personal data to erase is the user's direct identifiers: name, email, profile photo, and any fields stored against their user record.
Hard Delete vs. Soft Delete: Why Most SaaS Teams Get This Wrong
Most SaaS applications use soft delete — a deleted_at column that hides records from queries without removing them from the database. Soft delete is excellent for accidental deletion recovery and referential integrity. It is not compliant with GDPR right to erasure on its own, because the personal data remains present in the database and in every backup that was taken while the record was live.
- →Soft delete is a business logic tool, not a compliance tool. Use it for the grace period — the window between a user clicking 'Delete account' and the final erasure. A 7 to 30-day grace period lets a user recover their account if they changed their mind. After the grace period, a background job runs the actual erasure.
- →Hard delete the personal data columns, not necessarily the row. You often need to retain the row for financial and reporting integrity (order counts, revenue figures, referential keys) but can erase the personal data fields. This is 'selective erasure' and it is explicitly recognized in GDPR guidance from the ICO and CNIL.
- →Password and authentication data: credential records — password hashes, MFA secrets, OAuth tokens, session tokens, API keys — must all be hard deleted when the account is erased. These are personal data under GDPR because they can be used to authenticate as that person. Failing to delete password hashes leaves a credential that can be cracked offline.
- →Tombstone table: for each erased user, insert a row in a user_erasures table that records only the pseudonymous user_id (not any personal data), the erasure date, and the legal basis. This lets you answer whether a user's data was erased without retaining personal data — useful for support tickets, compliance audits, and regulatory inspections.
Building the Deletion Pipeline: Idempotent Jobs Across All Systems
Reliable erasure requires treating data deletion as an event that propagates across systems, not a single database operation. The pattern that works at scale is a deletion job queue: when an erasure is triggered, enqueue a job that walks through every data store in a defined order. For related infrastructure patterns, see how to implement SaaS audit logs.
- →Define a deletion checklist per entity type: for a user erasure, the checklist might be — (1) erase primary user record PII columns, (2) erase or anonymize child records per the PII inventory, (3) delete session tokens and API keys, (4) call third-party deletion APIs (Intercom, HubSpot, analytics platforms), (5) remove files from object storage (S3 or GCS — profile photos, uploaded documents), (6) insert row into user_erasures log, (7) mark the deletion job complete.
- →Idempotency: deletion jobs can fail mid-way and must be retried. Each step in the checklist must be idempotent — safe to retry without double-deleting something or leaving a corrupted intermediate state. Use a step-completion log in a job_steps table or in the queue metadata, and verify whether each step already succeeded before executing it again.
- →Object storage: profile photos, exported files, and user-uploaded documents live in S3 or GCS, not in the database. Your deletion job must list and delete these objects by the user's identifier prefix. Use a lifecycle rule as a belt-and-suspenders measure: tag objects with the user_id and configure a tag-based expiry policy.
- →Stripe customer objects: Stripe stores card data, billing addresses, and subscription metadata against a customer object. GDPR erasure applies to this. Stripe provides a customer deletion endpoint that removes payment methods and customer data. If you retain the subscription record for accounting, replace the stripe_customer_id column with null. Note that Stripe does not delete charges, payment intents, or payouts from your account — those belong to your financial records and are covered by retention exceptions.
- →Error tracking and logs: Sentry and Datadog ingest stack traces and event metadata that may contain personal data embedded in context (user IDs, emails in breadcrumbs). Sentry has a data scrubbing feature and an event deletion API. For structured application logs in CloudWatch or Elasticsearch, set a log retention period shorter than your erasure grace period, or use log field-level scrubbing to redact PII before logs are written.
Backups, Logs, and Analytics: The Three Hidden Data Stores
Backups, structured logs, and analytics events are the three stores that consistently appear in GDPR audits as sources of retained personal data after a claimed erasure. Each requires a different technical strategy.
- →Database backups: you cannot feasibly modify individual records in a point-in-time backup. The two compliant approaches are: (a) retain backups for no longer than stated in your privacy policy — if your policy says 30-day backup retention, all personal data in backups older than that is gone; (b) encrypt backups with per-user or per-tenant envelope keys and discard the encryption key on erasure. Cryptographic erasure is accepted as equivalent to physical deletion by most supervisory authorities, though not all — verify your jurisdiction's guidance.
- →Application logs: logs often contain personal data developers did not intentionally store there: user IDs in URL paths, emails in error messages, IP addresses in access logs. Audit a sample of your log output for PII before shipping to production. Set an aggressive log retention period — 90 days is reasonable for most SaaS — and do not forward raw logs to your data warehouse without scrubbing identifiable fields first.
- →Analytics: PostHog, Amplitude, Mixpanel, and Segment all expose user deletion APIs specifically for GDPR compliance. Call them inside your deletion job. For a data warehouse (BigQuery, Snowflake, Redshift), you need a process to DELETE FROM your event tables WHERE user_id = $1. If you use an append-only event model and cannot delete from the warehouse, apply cryptographic erasure: encrypt every event row's personal identifiers with a per-user key and discard the key on request.
Frequently Asked Questions
Does GDPR right to erasure apply to B2B SaaS where customers are companies, not individuals?
In a pure B2B SaaS where your direct customers are organizations, your customer is the data controller and you are the data processor. Erasure rights run from individuals to the data controller — your customer's end users exercise those rights with your customer, who then passes the deletion request to you. Your obligation is to your Data Processing Agreement (DPA) with that customer. The engineering implementation is the same; the trigger comes from your customer rather than directly from an end user.
How do I delete user data without breaking referential integrity in my database?
Use selective erasure: retain the row but hard-delete the personal data columns, replacing them with anonymized placeholders — 'Deleted User' for name fields, 'deleted@placeholder.invalid' for email. Foreign keys that reference the row remain valid, so reports and aggregations that count rows continue to work correctly. Document which columns are anonymized versus deleted in your PII inventory and reflect this approach in your privacy policy.
What is the deadline for responding to a GDPR right to erasure request?
Article 12 requires a response within one month of receiving the request. If the erasure itself cannot be completed within one month due to complexity or volume, you must inform the subject and complete it within two months from the original request date. Failing to respond at all is treated more seriously by supervisory authorities than completing the erasure slightly late — build a workflow that acknowledges the request within 72 hours and executes the technical erasure within 30 days.
Do I need to delete personal data from database backups?
You are not required to modify individual backups. The compliant approaches are: enforce a short backup retention period in your privacy policy and honor it — once the backup ages out, the data is no longer held; or use cryptographic erasure — encrypt personal data with per-subject keys and discard the key on erasure, making the data unrecoverable even if the backup file still exists. Document whichever approach you choose in your ROPA (Record of Processing Activities) and privacy policy.
Should I keep any record after deleting a user's data?
Yes — a minimal erasure record. Store only the pseudonymous user identifier (a UUID, not an email), the erasure request date, the completion date, and the legal basis. This record does not contain personal data and therefore does not itself require erasure. It is evidence of compliance if the user, a regulator, or an auditor later asks whether the erasure was completed. Keep it in a separate erasure_log table with restricted access.
How Belsoft Helps SaaS Teams Implement Production-Grade GDPR Compliance
GDPR right to erasure is an engineering problem, not a legal checkbox — but most SaaS teams discover that only when a deletion request arrives and they cannot answer 'where is all of this person's data?' with confidence. Belsoft's SaaS platform engineering partnerships start with a data architecture review: we map your PII surface, identify the stores teams consistently miss (backups, analytics, error trackers), and build the deletion pipeline as a first-class production system — job queue, idempotency, third-party API calls, and the erasure log — not an afterthought bolted on before an enterprise deal.
If you are preparing for enterprise customers, a security questionnaire, or a formal audit, our security and compliance audit covers your data handling practices alongside your technical security posture — authentication, authorization, RLS, and the data lifecycle questions that enterprise procurement teams ask. When both are needed, the audit and the build happen in the same partnership so findings feed directly into remediation. Book a call to scope what yours would involve.
“GDPR erasure is not a legal problem. It is a data inventory problem — teams that cannot delete cleanly do not know where their data lives.”
Written by
Belal Hisham
Founder & Lead Engineer, Belsoft Solutions
More from the blog
Ready to partner?
Let's talk about your company.
30 minutes. No pitch. We talk through how you run today and where AI and automation would help.
Book a free audit
