---
title: "Delete every copy of a tenant when the · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/multi-tenancy/tenant-offboarding
id: DAT-72
level: Required
applies: accounts
risk: law
updated: 2026-10-22
tokens: 1116
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Delete every copy of a tenant when the contract ends

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Multi-tenancy](https://agentwranglers.se/playbook/data/multi-tenancy.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: DAT-72
- Level: Required
- Chapter: [Multi-tenancy](https://agentwranglers.se/playbook/data/multi-tenancy.md)
- Rule: When a customer leaves, return or delete their data in every store within the period your contract states. Backups holding it expire on their normal schedule.
- Check: An end-to-end test creates a tenant with data in every store and runs offboarding. It then finds 0 rows, 0 objects and 0 index hits for that tenant ID. Restore a backup taken before the deletion into staging, run the restore script with its deletion list step, and the tenant is gone again.
- Risk: A law broken
- Applies when: The project has user accounts.
- How: You often process personal data for a business customer. GDPR Article 28(3)(g) then makes you delete or return it when the service ends, as the customer chooses. Build one offboarding job that walks the same store list as the export. It covers database rows, files under the tenant's prefix, search and vector indexes, caches, queues and analytics. Drop a tenant's schema or database whole. Send the customer a final export first when they ask for one. Record the deletion, with counts per store, as evidence. Backups are not edited. They age out as [backup retention](https://agentwranglers.se/playbook/operations/disaster-recovery/backup-retention.md) sets. Keep the deleted tenant IDs in a deletion list, and re-run offboarding for each one after any restore. Other personal data follows [Delete old data automatically](https://agentwranglers.se/playbook/data/personal-data/retention-jobs.md). Fine-tuned models trained on that customer's data are deleted too, as [Keep each customer's data in its own fine-tuned model](https://agentwranglers.se/playbook/ai-features/logs-privacy-and-feedback/tenant-fine-tunes.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### JavaScript example

```js
const TENANT_STORES = [deleteRows, deleteFiles, deleteSearchDocuments, deleteVectors, deleteCacheKeys, deleteAnalytics];

export async function offboardTenant(tenantId) {
  const counts = {};
  for (const deleteFrom of TENANT_STORES) counts[deleteFrom.name] = await deleteFrom(tenantId);
  await deletionLog.insert({ tenantId, counts, deletedAt: new Date() });
  return counts;
}
```

### Python example

```python
TENANT_STORES = [delete_rows, delete_files, delete_search_documents, delete_vectors, delete_cache_keys, delete_analytics]

def offboard_tenant(tenant_id: int) -> dict[str, int]:
    counts = {delete_from.__name__: delete_from(tenant_id) for delete_from in TENANT_STORES}
    deletion_log.insert(tenant_id=tenant_id, counts=counts, deleted_at=datetime.now(timezone.utc))
    return counts
```

## Sources

- [GDPR Article 28 on processors](https://eur-lex.europa.eu/eli/reg/2016/679/oj)

## Related rules

- OPS-46 [Keep backups for a set time](https://agentwranglers.se/playbook/operations/disaster-recovery/backup-retention.md) in Operations and observability
- DAT-31 [Delete old data automatically](https://agentwranglers.se/playbook/data/personal-data/retention-jobs.md) in Data and databases
- AIF-58 [Keep each customer's data in its own fine-tuned model](https://agentwranglers.se/playbook/ai-features/logs-privacy-and-feedback/tenant-fine-tunes.md) in AI features

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/data/multi-tenancy/tenant-offboarding">Agent Wranglers data and databases playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Restore and export one tenant alone](https://agentwranglers.se/playbook/data/multi-tenancy/per-tenant-restore.md)
- Next: [Find and contain noisy neighbours](https://agentwranglers.se/playbook/data/multi-tenancy/noisy-neighbours.md)
- [Multi-tenancy](https://agentwranglers.se/playbook/data/multi-tenancy.md)
