inbox_id. For LangChain or Vercel AI SDK, see Agent frameworks for ready-made tool definitions. For OpenClaw, use the channel plugin instead; a pod account covers every inbox you create.
Prerequisites
- OpenMail account with API key
- An AI agent or agent framework (e.g. LangChain, n8n)
Use this pre-built prompt to get started faster.
Step 1: Create an inbox and its key
Two API calls. Create the inbox, then mint an inbox-scoped key for it. The agent gets only that key, so a compromised container can reach nothing but its own inbox. Mapinbox_id to your user/container in your app for routing.
Step 2: Write env vars into the container
Three variables per container, all unique to it. Your account or pod key never enters the container.--env-file).
Step 3: Add the skill file
This file teaches the agent how to send and receive email. Most frameworks load it into the system prompt or expose it as a tool description. The agent calls the API viacurl—no CLI binary needed.
Place it in your agent’s skills directory (for Claude Code, ~/.claude/skills/openmail/SKILL.md) or pre-bake it into your Docker image. The content is the same for every framework.
SKILL.md
Step 4: Handle inbound email
Choose your delivery method. WebSockets are recommended for agents - no public URL needed, instant delivery. Webhooks work for traditional server-to-server integrations. The event payload is identical for both methods:Event payload
- WebSocket (recommended)
- Webhook
Connect to Subscribe options:
wss://api.openmail.sh/v1/ws from your backend with your account or pod key, so one connection covers every inbox. No public URL, no signature verification needed - the connection itself is authenticated.Verify the integration
- Create inbox - confirm
OPENMAIL_INBOX_IDandOPENMAIL_ADDRESSappear in the container’s env - Send - tell the agent “send an email to your-test@email.com” - confirm it arrives
- Inbound - reply to that email; confirm the event arrives over your WebSocket connection (or webhook) and routes to the container
- Thread - tell the agent “reply to the last email” - confirm the reply threads correctly in the recipient’s client
Reference
Email deliverability
Warm-up schedules, inbox distribution, and content best practices to stay out of spam.
WebSockets
Real-time event streaming, subscribe protocol, reconnection.
Webhooks
Signature verification, payload format, retries.
API reference
Full endpoint documentation.