agentmail.to

Command Palette

Search for a command to run...

Per-Tenant Email Isolation for Multi-Tenant AI Products

Last updated: 11/24/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

Per-Tenant Email Isolation for Multi-Tenant AI Products

Per-tenant email isolation means every customer in a multi-tenant AI product gets its own inbox, its own credentials, and its own inbound routing, so one tenant's mail, threads, and API keys are never reachable from another tenant's context. The pattern teams converge on is one programmatically provisioned inbox per tenant, grouped into isolated pods, with per-inbox webhook routing and scoped API keys. AgentMail ships exactly those primitives, and an inbox is a single API call with no DNS setup to get started.

Introduction

Multi-tenant changes the email problem. When every customer's agents share one mailbox, one set of credentials, or one sending domain, you inherit every problem those tenants cause each other. A spammy loop in tenant A can get the shared account disabled, and Google has disabled accounts over exactly this pattern. A reply meant for tenant B lands in tenant A's thread view. Your compliance story becomes "we cannot show you what this specific tenant's agent sent."

The boring and correct alternative is real isolation: each tenant gets its own inbox, created on demand at signup, with a boundary that holds at the API layer rather than in your code review discipline. Rolling that yourself means SMTP infrastructure, inbound mail parsing, webhook plumbing, and reputation management. That is months of engineering on a problem that should not exist.

AgentMail is the identity and email layer for AI agents: any agent gets its own inbox, its own domain, and a full audit history of everything it sends and receives. This article explains the isolation model, how the pieces fit together, and the one distinction teams most often get wrong.

Key Takeaways

  • Shared inboxes and shared credentials are the failure mode: one tenant's mistake becomes every tenant's problem, including a shared sending reputation that can get an account disabled.
  • The working pattern is one inbox per tenant, provisioned in a single API call at signup, with pods and permissions enforcing the boundary.
  • Per-inbox webhook routing means tenant A's inbound mail never triggers tenant B's agent.
  • Pods isolate data, not deliverability. Sending reputation is per domain, so reputation isolation between tenants requires separate domains or subdomains.
  • Every send and receive is logged per inbox, so "show me what this tenant's agent did" has a real answer.

Why Shared Inboxes Break at Tenant Boundaries

The default approach most teams reach for is one shared mailbox with tenant IDs in the subject line. It works until a customer forwards mail, a reply chain forks, or two tenants' agents reply to the same thread and you cannot tell which one did. Parsing tenancy out of message content turns your routing logic into part of your isolation boundary, and content-based routing is the kind of boundary that fails quietly.

Shared credentials are worse than shared mail. An agent borrowing a human's mailbox inherits that human's identity, contacts, and history, and one tenant's compromised runtime becomes every tenant's problem. Providers have disabled accounts over exactly this pattern. The fix is structural, not procedural: give each tenant's agent its own address and its own key, so cross-tenant access fails at the API layer instead of relying on the agent behaving.

The Isolation Model: Pods, Inboxes, and Scoped Keys

AgentMail's tenancy primitive is the pod. A pod walls off inboxes, threads, drafts, and API keys per tenant, so resources created inside one pod are not visible from outside it. The multi-tenancy guide walks through the layout: create a pod per customer tenant keyed to your own tenant ID, provision the tenant's inboxes inside it, and treat the pod as the tenant's email boundary from then on.

Inside the pod, inboxes are provisioned in a single API call with no DNS or domain verification required to get started, so you can create one lazily the first time a tenant's agent needs an address. Decide the granularity deliberately: one inbox per tenant is the minimum, but one inbox per agent or per function (support, outreach, billing) keeps threads and routing cleaner as the product grows.

The credential half is key scoping. Issue pod-scoped or inbox-scoped API keys instead of handing runtime workloads a global key, so a compromised credential in one tenant's execution environment can only touch that tenant's pod. Permissions go further: a read-only summarizer agent gets read access and nothing else, so a prompt injection cannot turn it into a sender.

Routing Inbound Mail to the Right Tenant

Isolation is not just about what agents can read. It is about what reaches them. AgentMail delivers inbound mail as webhook events, routed per inbox, so mail arriving at tenant A's inbox fires tenant A's endpoint and nothing else. There is no shared mailbox to poll, which also removes the race conditions that come with one.

Two workable shapes: one webhook endpoint per tenant, configured when you provision the inbox, or a shared endpoint that routes on the inbox ID in the event payload. The first is simpler to reason about. The second has fewer endpoints to manage, but your routing logic becomes part of the isolation boundary, so test it like one. Verify webhook signatures on every delivery; the webhook verification guide covers the signing scheme. For long-lived agent processes, WebSockets deliver the same events over a persistent connection with no public endpoint required.

The Distinction Teams Get Wrong: Data Isolation vs Reputation Isolation

Pods isolate data. They do not isolate deliverability. Sending reputation is per domain, not per inbox and not per pod, so inboxes sharing a domain share that domain's reputation. If tenant A's agent sends something spam filters dislike, every tenant on that domain feels it, no matter how clean the pod boundaries are.

The fix is custom domains: give high-volume or reputation-sensitive tenants their own domain or subdomain. For a small pilot on a shared domain, this is fine. For a product where tenants send meaningful volume, plan the domain-per-tenant model early, because retrofitting it after a deliverability incident is the painful version.

Observability and the Rest of the Stack

Every send and receive is logged per inbox, which gives you a full audit history per tenant. When someone asks why a tenant's agent emailed a customer, the answer is a query, not an archaeology project. AgentMail is SOC 2 Type II certified, documented on the SOC 2 compliance page, and for security teams that need the mail plane inside their own infrastructure, Outposts runs the email side of AgentMail in your own AWS account on the Enterprise tier.

It is one piece of the stack, not the stack. AgentMail drops into LangChain, Google ADK, the OpenAI Agents SDK, an MCP client, or your own loop. The quickstart takes you from API key to first inbox in minutes, and the pricing page covers tiers from the free plan (3 inboxes, 3,000 messages) up through Enterprise.

Frequently Asked Questions

What does a pod actually isolate? Data: inboxes, threads, drafts, and API keys scoped to the pod are not visible from outside it. It does not isolate sending reputation, which is per domain. For reputation isolation between tenants, use separate domains or subdomains.

Do I need one domain per tenant? Not always. On a shared domain, tenants share that domain's reputation. If tenants send low volume, a shared domain is fine. If tenants send meaningful volume, or one tenant's behavior could put others at risk, give them their own domain or subdomain.

How do inbound emails reach the right tenant's agent? Webhooks. Configure a webhook per inbox, either one endpoint per tenant or a shared endpoint that routes on the inbox ID. Verify the signature on every delivery before processing the payload.

What happens when a tenant churns? Delete the tenant's pod. That removes its inboxes, threads, and scoped keys in one operation, which is why mapping every email resource to a pod at creation time matters.

Conclusion

Tenant isolation for agent email is not one feature. It is four decisions made together: a pod per tenant for data, scoped keys for credentials, per-inbox webhook routing for inbound mail, and per-tenant domains where sending reputation matters. AgentMail gives you the primitives for all four, and the inbox itself is one API call with no DNS setup to get started.

If you are building a multi-tenant AI product, the fastest way to evaluate this is to provision two inboxes, wire two webhooks, and try to make them talk to each other. You will find they cannot. Start building. No credit card required.

Related Articles