AI agents

Give an AI agent one mailbox, not your whole inbox

Create a mailbox for the agent on your own domain and give it an API key that can reach only that mailbox — instead of an OAuth grant to your entire Gmail account.

Facts checked

In short

To give an AI agent email without handing over your whole inbox, give it a mailbox of its own. Create agent@yourdomain.com in MarkRelay, create an API key scoped to that one mailbox, and install the MarkRelay skill in Claude Code, Codex, OpenClaw, Hermes Agent or Pi. Every other mailbox is invisible to that key. Gmail's API scopes, by contrast, cover the whole Gmail account. To cut the agent off, delete or disable the key. The agent's mail is stored in your own Cloudflare account: your own cloud account, not an agent-inbox vendor's.

A Gmail OAuth grant vs a mailbox-scoped key

Which mail it can reach

MarkRelay key
Only the mailboxes granted to the key
Gmail OAuth grant
The whole Gmail account the scope covers, e.g. gmail.readonly: “View your email messages and settings”

Limit it to one address

MarkRelay key
Yes: Specific mailboxes scope
Gmail OAuth grant
Google's Gmail API scopes page lists no scope limited to one address or label

Can it send?

MarkRelay key
From its granted mailboxes only
Gmail OAuth grant
With gmail.send or a broader scope, as you

How to cut it off

MarkRelay key
Disable or delete the key; removing the owner's access to the mailbox also removes it from the key
Gmail OAuth grant
Remove the app's access in your Google account

Where the mail is stored

MarkRelay key
Your own Cloudflare D1 and R2
Gmail OAuth grant
Google

Whose address it sends from

MarkRelay key
The agent's own address, e.g. agent@yourdomain.com
Gmail OAuth grant
Yours

Gmail scope descriptions are quoted from Google's Gmail API scopes page.

Its own mailbox

agent@yourdomain.com, not your personal inbox.

One mailbox, one key

The key reaches that mailbox and nothing else.

Revoke in one click

Delete or disable the key.

In your own account

The agent's mail stays in your Cloudflare D1 and R2.

How it works

1. Create a mailbox for the agent, such as agent@yourdomain.com. 2. In Developer → API keys, create a key with Specific mailboxes scope and pick only that mailbox. 3. Install the skill your deployment serves at /skills/SKILL.md in Claude Code, Codex, OpenClaw, Hermes Agent or Pi, and give it the API URL and the key. 4. To revoke access, delete the key.

A key reaches only what its owner can open, narrowed to the scope chosen for it. With Specific mailboxes scope, every other mailbox simply does not exist for the agent, in any call.

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.

Install it in your agent

Every deployment serves one Agent Skills file that Claude Code, Codex, OpenClaw, Hermes Agent and Pi all load. Paste one message 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.

Keep the agent careful

The skill treats sending, replying, forwarding and deleting as real actions: the agent resolves an unclear recipient or intent before acting, never automatically retries a send that may have gone out, and moves mail to trash rather than deleting it unless you ask. To review every message first, tell the agent to draft and wait for your approval before it sends.

Everything the agent sends appears in MarkRelay's webmail with an API badge, so a person can review a thread, take over or reply by hand.

  • One dedicated key and mailbox per agent
  • Keep the key out of repositories
  • Ask for a draft before anything sensitive
  • Rotate keys and review access regularly
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.

Common questions

How can I give my AI agent access to email without giving it my whole Gmail inbox?

Give the agent a mailbox of its own instead. Create agent@yourdomain.com in MarkRelay, create an API key scoped to that mailbox only, and install the MarkRelay skill in your agent. The key cannot reach any other mailbox.

Can the agent read my other mailboxes?

No. A key reaches only what its owner can open, narrowed to the scope chosen for it. A key scoped to agent@ sees no other mailbox, in any call.

How do I revoke the agent's access?

Delete or disable its API key in Developer → API keys. Removing the key owner's access to the mailbox also removes it from the key.

Will the agent send email without asking me?

The skill tells the agent to resolve unclear recipients or intent before sending and never to retry a send blindly. If you want to approve every message, tell the agent to draft and wait for your approval before it sends.

Where is the agent's mail stored?

In the D1 database and R2 bucket in your own Cloudflare account. MarkRelay never receives your email, attachments or contacts.

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.