---
title: "Multi-tenancy · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/multi-tenancy
parts: 9
tokens_total: 8043
updated: 2026-10-22
tokens: 993
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Multi-tenancy

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

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

> Pick how far apart customers' data lives, carry the tenant into every job, file and log, and restore, export or delete one tenant alone.

**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">Agent Wranglers data and databases playbook</a>`. In code you write, add a comment next to it with the same link.

## Required

- DAT-68 [Run every background job inside its tenant](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-context-in-jobs.md) · 1,002 tokens · updated 2026-10-22
  Put the tenant ID in every job's payload, and make the worker set the tenant context before it touches data. A job without a tenant ID fails at once.
- DAT-72 [Delete every copy of a tenant when the contract ends](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-offboarding.md) · 1,064 tokens · updated 2026-10-22
  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.

## Recommended

- DAT-67 [Choose the isolation model before the first customer](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-isolation-model.md) · 942 tokens · updated 2026-10-22
  Write down where each customer's data lives, in shared tables, a schema per tenant or a database per tenant. Record the reason and the tenant count it must reach.
- DAT-69 [Keep files and search indexes apart by tenant](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-scoped-storage.md) · 925 tokens · updated 2026-10-22
  Store each tenant's files under a path that starts with its tenant ID. Filter every search and vector query by tenant on the server, inside the query.
- DAT-70 [Put the tenant on every log line and trace](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-in-logs.md) · 857 tokens · updated 2026-10-22
  Add the tenant ID as a field to every log entry, trace and metric written while serving a tenant. Never put the tenant's name or data in that field.
- DAT-71 [Restore and export one tenant alone](https://agentwranglers.se/playbook/data/multi-tenancy/per-tenant-restore.md) · 813 tokens · updated 2026-10-22
  Keep a tested script that exports one tenant's data from every store, and one that restores a single tenant from backup without changing other tenants.
- DAT-73 [Find and contain noisy neighbours](https://agentwranglers.se/playbook/data/multi-tenancy/noisy-neighbours.md) · 924 tokens · updated 2026-10-22
  Measure database time per tenant, and give each tenant its own query time limit and job share. Move a tenant that uses more than a quarter of the database time to its own resources.

## Optional

- DAT-74 [Give each tenant its own encryption key when customers ask to hold it](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-encryption-keys.md) · 749 tokens · updated 2026-10-22
  When customers ask to hold their own key, encrypt each tenant's sensitive data with a data key wrapped by a key per tenant. Let a customer's key live in their own key service account.
- DAT-75 [Pin each tenant's data to its region](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-region-pinning.md) · 767 tokens · updated 2026-10-22
  When a customer's contract names a region, store the region on the tenant and keep its database rows, files, backups, logs and search indexes there.

- Previous: [Search](https://agentwranglers.se/playbook/data/search.md)
- [All chapters](https://agentwranglers.se/playbook/data.md)
