Skip to main content
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.

Prerequisites

Use this pre-built prompt to get started faster.

Open in Cursor

Step 1: Create an inbox

One API call. Create an inbox and map inbox_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.
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).

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 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
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

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

Verify the integration

  1. Create inbox - confirm OPENMAIL_INBOX_ID and OPENMAIL_ADDRESS appear in the container’s env
  2. Send - tell the agent “send an email to your-test@email.com” - confirm it arrives
  3. Inbound - reply to that email; confirm the event arrives over your WebSocket connection (or webhook) and routes to the container
  4. 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.