API Maker

The backend engine for the AI era

Multi-tenantEpisode 33 5:21 10 chapters November 2026

Multi-Tenant APIs: One Set of APIs, a Database per Tenant

One set of APIs for every customer, each with a database of its own. Keep tenants in a table named by the secret, build a multi-tenant instance with one structure for many databases, pick the tenant by path or header, refuse suspended tenants, and move a tenant with one call.

In the playlists The complete course Migrations & tenants

Chapters

What you will learn

  • Where the tenants are: a table, named by the secret
  • A multi-tenant instance
  • One structure, many databases
  • The same URL for two tenants: path or header
  • Suspended tenants, refused
  • A tenant that moves, told in one call
In the docsMulti-tenant
Transcript680 words · click a time to play from there

Intro

One set of APIs can serve every customer, and each customer has its own database. In this video, we build multi tenant APIs with API Maker.

Multi-tenant, the usual way

Serving many customers is usually hard. You keep a branch of code, or a deployment, for each customer. Or you share one database, with a tenant id in every table and every query. Then one forgotten filter shows a customer the data of another. With API Maker, one instance serves every tenant, each with its own database. The request names its tenant, in the path or in a header. And a new customer is just a row, not a deploy.

In this video: where the tenants are, a multi tenant instance, the same address for two tenants, the tenant in the path, in a header, or suspended, and a tenant that moves.

Where the tenants are

Here is Calm Home for Business. Interior studios work on Calm Home, and each one has its own PostgreSQL database, with the same table of projects. The studios are rows of a table, crm dot public dot studios. Each row has a username, a name, the connection string of its database, and active. An entry of the default secret names that table, and finds only the active studios. Pine Studio is suspended, so active is false.

A multi-tenant instance

Open Instance API, and click Add New. Pick PostgreSQL, name it studios, and set its connection. Pick the key of the PostgreSQL server in the secret. The panel shows key names, never their values. Below, turn on Is Multi Tenant Structure Instance, and pick its entry, multiTenant.studios. The hint says how a request names its tenant. In the path, it is studios colon colon tenant. Or with the header x-am-tenant-username.

Click Test. It is connected. Save it. Pick the instance studios. Its structure database, also named studios, holds the table that every studio has. Open Bulk Schema Creation. One schema is made for every studio at once. Here are the tenants it offers: oakwood and linen. Pine is not here, because it is suspended.

The same URL for two tenants

In API Testing, pick studios, the tenant oakwood, the database studios, projects, and Get all. Send. We get the three projects of Oakwood Interiors. Now pick the tenant linen. The database, the table, and the API stay picked. Send. We get the two projects of Linen and Loft. It is the same address, but another database.

Path, header, or suspended

From an app, the tenant can be in the path: studios colon colon oakwood. Or in a header: x-am-tenant-username, set to linen. With no tenant, the structure database answers, with its template row. Pine gets four hundred: unable to find a tenant named pine. Now we save a project for Oakwood, and PostgreSQL itself counts the rows. Oakwood has four projects now, and the others are unchanged.

A tenant which moves

Now a studio moves to another database server, so its row gets the new connection string. Then, in System APIs, pick Multi tenant instance updated. In its body, name the instance and the studio. Send. Every server connects again to that studio, and the answers kept for the instance are cleared.

Good to know

Good to know. A person token made for one tenant is refused for another. Custom APIs read the tenant of the request in g.req.params.tenantUsername. The tenants table can be on any engine, and its connection strings can be encrypted with the secret. To add a customer, you add a database and a row. There is no restart.

Built on standards

Each tenant has its own database. So the data is kept apart by design, not by a filter in every query. All of them share one set of APIs, schemas, hooks, and permissions. So code written by an AI assistant cannot forget a tenant id. There is none to forget.

Recap

To sum up. Tenants live in a table, named by the secret. One instance serves a database for each tenant. The tenant is in the path, or in a header. Suspended tenants are refused. And when a tenant moves, one call tells every server. Next: error messages in the language of each caller. API Maker. Build faster, spend smarter, deliver better.