Create and manage inboxes via API. For multi-tenant apps and agent frameworks.
For developers building AI agents with OpenClaw, LangChain, n8n, Make, Vercel AI SDK, or any agent framework. This guide uses OpenClaw as the example—the same pattern (create inbox, inject env vars, route inbound by inbox_id) works with other frameworks.
For OpenClaw, set these in ~/.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).
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 via curl—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
Copy
---name: openmaildescription: Send and receive email via OpenMailrequires: env: - OPENMAIL_API_KEY - OPENMAIL_INBOX_ID - OPENMAIL_ADDRESS---# OpenMailYour email address is $OPENMAIL_ADDRESS. Use it when introducing yourself or sharing contact info.## Send an email```bashcurl -s -X POST "https://api.openmail.sh/v1/inboxes/$OPENMAIL_INBOX_ID/send" \ -H "Authorization: Bearer $OPENMAIL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "to": "recipient@example.com", "subject": "Subject", "body": "Message body" }'```Save the `threadId` from the response to reply in the same thread later.## Reply in a thread```bashcurl -s -X POST "https://api.openmail.sh/v1/inboxes/$OPENMAIL_INBOX_ID/send" \ -H "Authorization: Bearer $OPENMAIL_API_KEY" \ -H "Content-Type: application/json" \ -H "Idempotency-Key: $(uuidgen)" \ -d '{ "to": "recipient@example.com", "subject": "Re: Original subject", "body": "Reply body", "threadId": "thr_..." }'```## Check for new messages```bashcurl -s "https://api.openmail.sh/v1/inboxes/$OPENMAIL_INBOX_ID/messages?direction=inbound&limit=10" \ -H "Authorization: Bearer $OPENMAIL_API_KEY"```## List threads```bashcurl -s "https://api.openmail.sh/v1/inboxes/$OPENMAIL_INBOX_ID/threads?limit=10" \ -H "Authorization: Bearer $OPENMAIL_API_KEY"```## Read a thread```bashcurl -s "https://api.openmail.sh/v1/threads/{thread_id}/messages" \ -H "Authorization: Bearer $OPENMAIL_API_KEY"```## Notes- Always include `Idempotency-Key` when sending (prevents duplicates on retry)- Use `threadId` when replying so the email threads correctly in the recipient's client- `$OPENMAIL_*` variables are read from the container environment at runtime
Pre-bake into Docker - the skill file is identical for every agent. Only the env vars differ per container. For OpenClaw: COPY skills/openmail/SKILL.md /root/.openclaw/skills/openmail/SKILL.md
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: