Create and manage inboxes via API. For multi-tenant apps and agent frameworks.
For developers building AI agents with OpenClaw, n8n, Make, or any agent framework. This guide covers the multi-tenant pattern: create inbox, inject env vars, route inbound by inbox_id. For LangChain or Vercel AI SDK, see Agent frameworks for ready-made tool definitions.
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
---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"```## Send with attachmentsUse multipart/form-data to attach files:```bashcurl -s -X POST "https://api.openmail.sh/v1/inboxes/$OPENMAIL_INBOX_ID/send" \ -H "Authorization: Bearer $OPENMAIL_API_KEY" \ -H "Idempotency-Key: $(uuidgen)" \ -F "to=recipient@example.com" \ -F "subject=Report attached" \ -F "body=See the attached file." \ -F "attachments=@/path/to/report.pdf"```Multiple files: repeat the `-F "attachments=@..."` flag. Max 25 MB total per email.## 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- For attachments, use `multipart/form-data` with `-F` flags instead of `-d` JSON- `$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: