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
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.
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
| Approach | Own inbox per user | Created by API | What you still build |
|---|---|---|---|
| One shared mailbox with aliases | No. Every user's mail lands in one place | Aliases, on some providers | Routing, separation, and keeping one agent out of another's mail |
| A Gmail or Workspace account per agent | Yes | Through Google's Admin SDK, as a paid user per agent | Sign-in per account, plus your own receiving and threading code |
| Catch-all domain and your own code | Any address works, but nothing is stored per address | No call needed | Receiving, parsing, storage, threads, sending and keys |
| Inbox API (OpenMail) | Yes | Yes, one POST | A 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.
