---
title: "Multi-tenant"
description: "Require tenant ids on a shared database, or isolate each tenant with adapterFactory."
---

> Documentation Index
> Fetch the complete documentation index at: https://logbun-docs.abshahin.workers.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Multi-tenant

For multi-tenant SaaS on a shared destination, set `requireTenantId: true` (or spread `ENTERPRISE_DEFAULTS`). Leaving it false emits `limit` / `unsafe_default_require_tenant`.

```ts
import { AuditLogger, ENTERPRISE_DEFAULTS } from 'logbun';

const audit = new AuditLogger({
  ...ENTERPRISE_DEFAULTS,
  namespace: 'api',
  reliability,
  adapter,
});
```

`getTenantId` in plugins fills `tenantId` only when the handler omitted it. Resolve from an authenticated session or verified JWT — never a raw `x-tenant-id` header unless the gateway overwrites it.

## Isolated databases

`tenancy.mode: 'database_per_tenant'` forces `requireTenantId` and **requires** `adapterFactory`. See [Tenancy](/concepts/tenancy) for the full contract, `knownTenantIds`, and `pool_exhausted`.

Turso is the built-in adapter this mode is designed around. ClickHouse is a shared warehouse (`tenant_id` column), not one database per tenant.

Source: https://logbun-docs.abshahin.workers.dev/guides/multi-tenant/index.mdx
