AI agents

Email for AI agents, on your own domain

Let agents send and receive email over a clean, predictable HTTP API — ideal for automated workflows, tool use, and human-in-the-loop email.

In short

Give each AI agent its own mailbox, such as agent@yourdomain.com, inside your Cloudflare account. Claude Code, Codex, OpenClaw, Hermes Agent and Pi install the skill your deployment serves and then check, read, send and reply to email when you ask; other agents use the same plain HTTP API. Each agent holds a key that reaches only its own mailbox, gets a signed webhook when mail arrives, and costs nothing per inbox.

Works in your coding agent

Claude Code, Codex, OpenClaw, Hermes and Pi install the same skill file and use your mailboxes when you ask.

Machine-readable discovery

OpenAPI 3.1, interactive docs, llms.txt, and an installable agent skill ship with every deployment.

Per-agent keys

Give each agent a personal key narrowed to a domain or selected mailboxes.

Send, read, reply

Full inbound + outbound, so agents can hold real conversations.

Ask your agent to handle email

Once the skill is installed, you talk to your agent in plain language: check a mailbox, summarize what came in, reply to the easy ones, leave the rest for you. The skill tells the agent which calls to make, how to page through results and what never to retry.

claude — ~/acme
›Check agent@acme.com for unread mail. Answer password-reset requests yourself and flag anything else for me.
●Using skill markrelay-mail
$curl -s -H "Authorization: Bearer $MARKRELAY_API_KEY" "$MARKRELAY_API_URL/emails?mailbox=agent@acme.com&read=false"
2 unread: “Reset my password please” (Sam Patel) · “Where is order #4830?” (Elena García)
$curl -s -X POST … "$MARKRELAY_API_URL/emails/b68419a2-…/reply" -d '{"text":"Hi Sam, I have sent a fresh reset link…"}'
{"id":"528a8469-74ee-4dc4-8023-0d3882699ad2"}
●Replied to Sam Patel with a fresh reset link. Elena García is asking about order #4830, which needs a tracking lookup, so I left it unread for you.
The API calls and answers are from a demo deployment; the conversation is illustrative.

Works with the agent you already use

Every deployment serves one Agent Skills file that Claude Code, Codex, OpenClaw, Hermes Agent and Pi all load. The quickest setup is a single message: paste it into your agent and it installs the skill, asks you for the key, stores it and checks the connection.

The address you open MarkRelay at. The prompts and commands below fill it in; until then the prompt asks your agent to ask you.

Install the MarkRelay skill in Claude Code

Fastest: paste this into Claude Code

It installs the skill, asks you for the key, stores it, and checks the connection.

prompt
Set up the MarkRelay email skill for yourself. First ask me for my MarkRelay address (for example https://mail.example.com); below it is called MARKRELAY_URL. Then, download MARKRELAY_URL/skills/SKILL.md to ~/.claude/skills/markrelay-mail/SKILL.md. Then save MARKRELAY_API_URL=MARKRELAY_URL/openapi/v1 and MARKRELAY_API_KEY in the env section of ~/.claude/settings.json. Ask me for the key; never put it in a repository. Finally, use the skill to list the mailboxes the key can reach. Tell me if I need to restart Claude Code.

Or do it yourself

1. Install the skill

terminal
mkdir -p ~/.claude/skills/markrelay-mail
curl -fsS https://<your-deployment>/skills/SKILL.md \
  -o ~/.claude/skills/markrelay-mail/SKILL.md

2. Give it the API URL and key

~/.claude/settings.json
{
  "env": {
    "MARKRELAY_API_URL": "https://<your-deployment>/openapi/v1",
    "MARKRELAY_API_KEY": "sk-..."
  }
}

Or export the two variables in your shell before starting claude.

3. Ask, or call /markrelay-mail

  • Claude loads the skill on its own when you ask about email, or you can call it with /markrelay-mail.
  • For one repository only, put the skill in .claude/skills/markrelay-mail instead.

One mailbox and one key per agent

Give each agent its own address, such as agent@yourdomain.com, and a key with Specific mailboxes scope. The agent can list, read and send only from that mailbox; every other address is invisible to it.

Need more agents? Add mailboxes. There is no per-inbox fee.

mail.yourdomain.com
The API keys page with the Create API key dialog open, its scope set to the agent@acme.com mailbox only
A key that reaches agent@acme.com and nothing else.

React the moment mail arrives

Point a signed webhook at your agent runner and it hears about new mail immediately. It reads the message, drafts an answer, waits for a person if the reply is sensitive, and responds in the same thread.

An agent's mailbox loop

Everything goes over plain HTTP with a key scoped to the agent's own mailbox.

  1. MarkRelayPOSTyour-agent/webhook

    Signed email.received event the moment mail arrives

  2. AgentGET/emails/{emailId}

    Reads the full message and attachments

  3. You, optionallyApprove the draft

    Keep a human in the loop for sensitive replies

  4. AgentPOST/emails/{emailId}/reply

    Replies in the same thread, from agent@yourdomain.com

People stay in the loop

Agents and teammates share the same mailboxes. Everything an agent sends appears in webmail with an API badge, so someone can review it, take over the thread or reply by hand.

mail.yourdomain.com
A reply sent by an AI agent through the API, shown in webmail with an API badge
The agent's reply in webmail, marked API.

Call it from your own code

example.ts
// Receive, then let your agent reply — all over plain HTTP.
const MARKRELAY_API_URL = process.env.MARKRELAY_API_URL; // https://mail.yourdomain.com/openapi/v1
const MARKRELAY_API_KEY = process.env.MARKRELAY_API_KEY;

const inbox = await fetch(
  `${MARKRELAY_API_URL}/emails?mailbox=agent@yourdomain.com&folder=inbox&read=false`,
  { headers: { Authorization: `Bearer ${MARKRELAY_API_KEY}` } },
).then((r) => r.json());

await fetch(`${MARKRELAY_API_URL}/emails/${inbox.items[0].id}/reply`, {
  method: "POST",
  headers: { Authorization: `Bearer ${MARKRELAY_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({ text: agentReply }),
});

Common questions

How do I give an AI agent its own email address?

Create a mailbox such as agent@yourdomain.com, create a personal API key scoped to that mailbox, and give the agent the key and your deployment's API URL. Claude Code, Codex, OpenClaw, Hermes and Pi then install the skill your deployment serves at /skills/SKILL.md.

Can the agent read other mailboxes?

No. A key reaches only what its owner can open, narrowed to the scope chosen for it, so a key scoped to agent@ sees nothing else.

Does it work with Claude Code, Codex, OpenClaw and Hermes?

Yes, and with Pi. All of them load the skill in the open Agent Skills format: Claude Code from ~/.claude/skills; Codex, OpenClaw and Pi from ~/.agents/skills; Hermes installs it from your deployment's URL. Any other agent that can make HTTP requests uses the same API through llms.txt or the OpenAPI document.

Is there an MCP server?

Yes. Every deployment is a remote MCP server at /mcp, for Claude, ChatGPT, Cursor and other MCP clients: add the URL, sign in, and pick the mailboxes it may use. Agents that run commands can use the skill and plain HTTP API instead.

How is this different from AgentMail?

AgentMail is a hosted service priced by inboxes and email volume. MarkRelay runs in your own Cloudflare account on your own domain, with no per-inbox fee. See the full MarkRelay vs AgentMail comparison.

Go deeper

Explore more of MarkRelay

Use cases

Own your email stack today

Buy MarkRelay once and run it in your Cloudflare account. MarkRelay adds no per-message or per-seat charge; Cloudflare usage and service limits remain separate.