---
title: "Pin each tenant's data to its region · Agent Wranglers"
url: https://agentwranglers.se/playbook/data/multi-tenancy/tenant-region-pinning
id: DAT-75
level: Optional
applies: eu-users
updated: 2026-10-22
tokens: 801
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Pin each tenant's data to its region

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-75
- Level: Optional
- Chapter: [Multi-tenancy](https://agentwranglers.se/playbook/data/multi-tenancy.md)
- Rule: 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.
- Check: A script lists every store that holds tenant data, with its region, and finds 0 pinned tenants with data outside their region. A test creates a tenant pinned to an EU region and uploads a file, and the object's bucket reports an EU location.
- Applies when: The project has users in the EU.
- How: Some customers, often in the public sector or health, require data to stay in the EU or one country. Choose regions as [Choose regions from users and data rules](https://agentwranglers.se/playbook/infrastructure/hosting-platforms/region-choice.md) explains, then route by tenant. Keep a small global directory that maps the tenant to its region, and nothing else. Send each request to that region's app and database. Background jobs, backups, log shipping and model calls for that tenant run in the same region. A pinned tenant usually lives in its own database or in a regional copy of the shared tables.

## 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
export function regionalDatabase(tenant) {
  const database = databasesByRegion[tenant.region];
  if (!database) throw new Error(`no database for region ${tenant.region}`);
  return database;
}
```

### Python example

```python
def regional_database(tenant):
    database = databases_by_region.get(tenant.region)
    if database is None:
        raise LookupError(f"no database for region {tenant.region}")
    return database
```

## Sources

- [GDPR Article 28 on processors](https://eur-lex.europa.eu/eli/reg/2016/679/oj)
- [GDPR Chapter V on transfers to third countries](https://eur-lex.europa.eu/eli/reg/2016/679/oj)

## Related rules

- INF-65 [Choose regions from users and data rules](https://agentwranglers.se/playbook/infrastructure/hosting-platforms/region-choice.md) in Infrastructure and environments

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

- Previous: [Give each tenant its own encryption key when customers ask to hold it](https://agentwranglers.se/playbook/data/multi-tenancy/tenant-encryption-keys.md)
- [Multi-tenancy](https://agentwranglers.se/playbook/data/multi-tenancy.md)
