Building an agent startup? Apply now →
Back to Blog

Create an email inbox for every user or agent with one API call

November 30, 2026

AI AgentsEmail InfrastructureGuide+1

With OpenMail, one POST /v1/inboxes creates a working email address for a user or an AI agent, ready to send and receive at once. Call it from your signup handler or wherever your platform starts a new agent, save the inbox ID next to the user, and every user gets an inbox without anyone opening a dashboard.

This guide is for products that create inboxes in code, one per user, tenant or agent, often hundreds of them. If you're setting up a single agent by hand, start with how to give your AI agent its own email address.

The call

create-inbox.sh
curl -X POST https://api.openmail.sh/v1/inboxes \
  -H "Authorization: Bearer $OPENMAIL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"mailboxName": "jane", "displayName": "Jane from Acme"}'

# 201 -> { "id": "inb_8f3a1b2c", "address": "jane@omail.sh", "podId": "...", ... }

Every field is optional. mailboxName sets the part before the @; leave it out and you get a random 8-character name. Addresses default to the shared omail.sh domain, or pass domain to use a verified domain of your own. displayName is what recipients see in the From line.

Run it when a user signs up

The pattern from the docs: create the inbox, then mint a key that only opens that inbox, and store both on the user record.

provision.js
const OPENMAIL_API_KEY = process.env.OPENMAIL_API_KEY; // stays on your backend

async function api(path, body) {
  const res = await fetch(`https://api.openmail.sh${path}`, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${OPENMAIL_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(body),
  });
  if (!res.ok) throw new Error(`OpenMail: ${res.status}`);
  return res.json();
}

// Call this when a user signs up or your platform spawns an agent
async function provisionInbox(user) {
  const inbox = await api("/v1/inboxes", { mailboxName: user.handle });
  const key = await api(`/v1/inboxes/${inbox.id}/api-keys`, { name: user.id });

  await db.users.update(user.id, {
    inboxId: inbox.id,         // route inbound events by this
    emailAddress: inbox.address,
    agentKey: key.token,       // shown once; store it as a secret
  });
}

Two things to handle. A chosen name that's already taken returns 409, so retry with a suffix or drop mailboxName. And the key's token comes back once, in this response, and can't be fetched again.

Give each agent only its own inbox

Your account key reaches every inbox, so it stays on your backend. The agent gets the inbox-scoped key instead. It can read and send from that one inbox and nothing else: it can't see other inboxes, create or delete any, mint keys or change sender rules. If a prompt injection takes over one agent, the damage stops at one mailbox.

One listener for every inbox

Every inbound event carries the inbox_id it arrived on. Open one WebSocket with your account key, or add one webhook endpoint, and look up the user by that ID. You don't need a webhook per inbox. How agents receive and reply shows the handler and the reply call.

Tenants with several inboxes: pods

If each of your customers runs several agents, create a pod per customer with POST /v1/pods, using your own tenant ID as its clientId. Then pass podId in the create call. A pod-scoped key can create and delete inboxes in that pod only, and billing stays on your one account. Pods are included on every plan.

Ways to give every user an address

Four ways to give each user or AI agent an email address, compared on separate inboxes, API creation and what you build yourself.
ApproachOwn inbox per userCreated by APIWhat you still build
One shared mailbox with aliasesNo. Every user's mail lands in one placeAliases, on some providersRouting, separation, and keeping one agent out of another's mail
A Gmail or Workspace account per agentYesThrough Google's Admin SDK, as a paid user per agentSign-in per account, plus your own receiving and threading code
Catch-all domain and your own codeAny address works, but nothing is stored per addressNo call neededReceiving, parsing, storage, threads, sending and keys
Inbox API (OpenMail)YesYes, one POSTA row in your database mapping inbox_id to the user

A catch-all is the cheapest start and fine for receiving one-time codes. It gets harder once agents need to reply in threads or you need to keep one user's mail away from another's agent.

Limits to plan for

An account can create 100 inboxes a day. The free plan stops at 3 inboxes; Pro includes 10 and then charges EUR 1 per inbox a month with no cap. New inboxes start at 10 sends a minute and 200 recipients a day, and on Pro both rise as the inbox ages and sends more. The full numbers are on the pricing page. If your users' agents run in ChatGPT, Claude or Cursor rather than your own code, the OpenMail MCP server gives them an inbox through one hosted URL.

Frequently asked questions

How much do 100 or 1,000 agent inboxes cost?

On OpenMail Pro, EUR 9 a month covers 10 inboxes and 10,000 emails. Each extra inbox is EUR 1 a month, so 100 inboxes come to EUR 99 and 1,000 to EUR 999, plus EUR 0.001 per email past 10,000. The free plan has 3 inboxes.

Can each inbox use my own domain?

Yes, on Pro, where custom domains are unlimited. Add the domain, publish the DNS records OpenMail returns, and pass it as domain in the create call once it shows verified. For white-label tenants, scope the domain to the tenant's pod.

What happens when I delete an inbox?

DELETE /v1/inboxes/{id} removes the inbox with its messages, threads and attachments, stops delivery to the address and revokes its keys. It can't be undone. Your account key or the pod's key can delete it; the agent's inbox key can't.

Is there a limit on how many inboxes I can create?

Free has a hard cap of 3. Pro includes 10 and has no cap after that. Any account can create 100 inboxes a day; past that the API returns 429. Plan bulk imports around it.

Can I choose the address, or is it random?

Either. Pass mailboxName (3 to 30 characters: lowercase letters, numbers, dots and hyphens) to pick the part before the @. Leave it out and OpenMail generates a random 8-character name.

Every AI agent deserves its own inbox.

Install the CLI, run setup, and you're sending email from your agent in minutes.

From the blog

Latest posts

All posts →
Developer5 min read

Multi-tenant email for AI agents: keep each customer apart

How to keep each customer's agents and email apart in a multi-tenant product: one pod per customer, scoped API keys, a domain per tenant, and what a pod doesn't separate.

Dec 2, 2026Read →
Developer4 min read

How to keep prompt injection out of an AI agent's inbox

How to protect an AI agent that reads email from prompt injection and malicious attachments: what can go wrong, what to build in your agent, and what OpenMail handles for you.

Nov 30, 2026Read →
Analysis5 min read

Email for AI agents that keeps data in the EU

Which email API for AI agents keeps data in the EU? What runs where on OpenMail, how eight providers compare, and where agent email can still leave the EU.

Nov 10, 2026Read →
Analysis8 min read

Email for AI agent platforms: what 1,000 inboxes really cost

Twelve ways to run 1,000 agent inboxes, from a few dollars to $14,000 a month, and what each leaves you to build.

Nov 5, 2026Read →
Developer5 min read

Inbound email with attachment text, ready for an LLM

An inbound email API that puts the text of PDFs, scans, Office files and CSVs into the webhook, ready for a model. What gets extracted, the limits, and the code to pass it to an LLM.

Nov 2, 2026Read →