inbox_id. For LangChain or Vercel AI SDK, see Agent frameworks for ready-made tool definitions.
Prerequisites
- OpenMail account with API key
- An AI agent or agent framework (e.g. OpenClaw, LangChain, n8n)
Use this pre-built prompt to get started faster.
Step 1: Create an inbox
One API call. Create an inbox and mapinbox_id to your user/container in your app for routing.
Step 2: Write env vars into the container
Three variables per container. The API key is shared across all agents; the inbox ID and address are unique.~/.openclaw/.env or in ~/.openclaw/openclaw.json under skills.entries.openmail.env. For other frameworks, inject them into your agent’s environment (e.g. LangChain tool config, n8n node credentials).
Step 3: Add the skill file
This file teaches the agent how to send and receive email. OpenClaw loads it into the LLM’s system prompt; other frameworks use similar patterns (system prompts, tool descriptions). The agent calls the API viacurl—no CLI binary needed.
For OpenClaw, place at ~/.openclaw/skills/openmail/SKILL.md or pre-bake into your Docker image. For other frameworks, adapt the path—the skill content is the same.
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 with your API key. 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.