agentmail.to

Command Palette

Search for a command to run...

How to Give AI Agents Secure Email with AgentMail

Last updated: 11/17/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.

How to Give AI Agents Secure Email with AgentMail

An agent that handles sensitive data needs an email setup where every agent has its own inbox, every key is scoped, every inbound event is verified, and every send is logged. This guide walks through the checklist to evaluate any email API against that bar, then shows how to set it up with AgentMail: provision isolated inboxes per agent, scope API keys with pods and permissions, verify webhooks before trusting payloads, and keep an audit trail you can actually read.

Introduction

Most email APIs were built for an application sending mail to humans. That model breaks when the sender is an agent touching customer data. The failure modes are predictable: agents borrowing a human's mailbox and inheriting that human's identity, replies from different conversations colliding in one shared inbox, and no record of what an agent sent or why. Google has disabled accounts over exactly this kind of shared-credential use.

Security for agent email is not one feature. It is four decisions: identity (does the agent own its address or borrow one), isolation (can one agent's mail and credentials leak into another's), transport (can you trust what arrives), and observability (can you reconstruct what happened). Evaluate any API on those four, and the marketing noise falls away.

AgentMail is built for the agent case: programmatic inboxes, pods and scoped keys for multi-tenant isolation, verified webhooks and WebSockets for inbound events, and a full audit history per inbox. The rest of this guide is the implementation.

Prerequisites

Before you start, have the following in place:

  • An AgentMail account. Sign up at the console, no credit card required, and grab an API key from the getting started guide.
  • An inventory of your agents. List each agent, what data it touches, and whether it needs to receive mail or only send. Isolation decisions depend on this.
  • A tenant model. If you serve multiple customers, decide now whether each customer gets its own pod and domain. Retrofitting tenancy is the expensive version.
  • A framework choice. AgentMail drops into LangChain, Google ADK, the OpenAI Agents SDK, Claude Agent SDK, MCP, or your own loop. Pick one before wiring email in.
  • A webhook endpoint with TLS, if your agents act on inbound mail.

Step-by-step

1. Give every agent its own inbox

One API call provisions an inbox, no DNS or domain verification required to get started. Do not share inboxes between agents. A shared inbox means a shared identity, shared credentials, and a shared blast radius. See the inboxes docs.

from agentmail import AgentMail

client = AgentMail()
inbox = client.inboxes.create()

Code per the AgentMail SDK reference: the client class is AgentMail, and inboxes are created with client.inboxes.create().

2. Isolate tenants with pods and scoped keys

If more than one customer's data flows through your system, put each tenant in its own pod. Pods isolate inboxes, threads, drafts, and keys per tenant, and API keys can be scoped to a pod or a single inbox, so a leaked key for one tenant cannot read another's mail. Route inbound webhooks per inbox so events reach only the owning tenant's handler. The multi-tenancy guide covers the setup.

One correction that trips people up: pods isolate data, not deliverability. Sending reputation is per domain. If tenants need reputation isolation, give each tenant its own domain or subdomain, following the custom domains docs.

3. Verify every inbound webhook

An unverified webhook endpoint is an injection point: anyone who can POST to it can impersonate an inbound email and steer your agent. Verify signatures before parsing payloads, and reject anything that fails. AgentMail documents the scheme in the webhook verification guide. If you need a persistent connection instead of HTTP callbacks, WebSockets deliver inbound events without exposing an endpoint at all.

4. Authenticate the agent itself

An inbox is an identity. AgentMail supports agent identity with AgentID, including browser enrollment and public-key authentication, so the agent proves who it is rather than holding a shared password. See AgentID public-key authentication and browser enrollment.

5. Turn on observability before you need it

Every send and receive is logged per inbox, which gives you a full audit history: what the agent sent, to whom, and when. Wire this into your incident process now, not after the first "why did our agent email that customer" question. The API reference lists the retrieval endpoints.

6. Confirm the compliance posture

If the data is sensitive, ask any vendor for the audit report, not the badge. AgentMail is SOC 2 Type II certified, documented on the SOC 2 page. For teams that cannot let mail leave their infrastructure at all, Outposts runs the email side in your own AWS account on the Enterprise tier.

Common pitfalls

  • Borrowing a human mailbox. The agent inherits that human's identity, contacts, and history. Every security control downstream is compensating for this one decision.
  • One key for everything. An unscoped key that can read every inbox turns a single leak into a full breach. Scope keys to a pod or inbox.
  • Trusting inbound payloads blindly. Verify webhook signatures or use WebSockets. An agent that acts on forged email is a prompt-injection delivery channel.
  • Assuming pods isolate reputation. They isolate data. Reputation follows the domain. Use separate domains per tenant when deliverability must not be shared.
  • Skipping the audit trail. "We are not sure what the agent sent" is not an answer anyone accepts in an incident review.

Frequently Asked Questions

What makes an email API safe for agents handling sensitive data? Four things: per-agent inboxes so identities do not blur, tenant isolation with scoped API keys, verified inbound transport, and a per-inbox audit log. AgentMail ships all four, and the security posture is SOC 2 Type II certified.

Do pods isolate email deliverability between tenants? No. Pods isolate data: inboxes, threads, drafts, and keys. Sending reputation is per domain, so tenants that need reputation isolation should get their own domain or subdomain.

How do I stop someone forging inbound email to my agent? Verify webhook signatures before processing payloads, or use WebSockets so there is no public endpoint to POST to. Both are documented: webhook verification and WebSockets.

Can AgentMail run inside our own cloud? Yes. Outposts is a bring-your-own-cloud deployment that runs the email side of AgentMail in your AWS account, available on the Enterprise tier.

Conclusion

Secure agent email comes down to four decisions: owned identity, tenant isolation, verified transport, and a readable audit trail. Get those right and an agent handling sensitive data is no scarier than any other service in your stack. AgentMail was built so those decisions are configuration, not a custom SMTP project: one API call per inbox, pods and scoped keys for isolation, verified webhooks, and a log of every send and receive.

Start building and provision your first isolated inbox in under a minute.

Related Articles