# Email for AI agents: inboxes, MCP, CLI, SDKs · cloudmail

> Give each AI agent its own email inbox, token and send rules. Connect over MCP, the Agent Skill, the CLI, SDKs or REST. Sends wait for a person by default.

Canonical: https://trycloudmail.com/agents
Last updated: 2026-11-24

**Every agent gets its own mailbox. You keep the send button.** cloudmail is built for people and AI agents working side by side. Give an agent its own address, or connect Claude, Cursor, Codex or your own code over MCP, the Agent Skill, the CLI, the SDKs or REST. Agents work with exactly the permissions you give them, and anything they send waits for a person unless you decide otherwise.

## A mailbox for every agent, separate from yours

An agent shouldn't borrow a person's login. One command creates a real address for one agent, with a token confined to that mailbox, its own send mode, an optional webhook for new mail and an expiry. When it expires, the token is revoked and the mail is archived to your R2 bucket.

- **Its own address**: `agent-…@yourdomain.com`, or a local part you choose.
- **Its own rules**: `allowed_recipients` binds every send from that mailbox, whatever the mode.
- **Its own lifetime**: up to 90 days, or end it now from Settings → Agent inboxes.

[What an agent inbox comes with](https://trycloudmail.com/features/agent-inboxes), and [agent inboxes in the reference](https://github.com/cloudmail-hq/cloudmail/blob/main/docs/reference.md#agent-inboxes).

### Create an agent inbox: CLI

```bash
# A separate mailbox for one agent, with its own token
cloudmail agent-inbox create --domain yourdomain.com \
  --purpose 'Invoice triage' --send-mode approve \
  --allow @partner.com --ttl-hours 24

cloudmail agent-inbox list       # addresses, send modes, time left
```

### Create an agent inbox: REST

```bash
curl -X POST https://mail.yourdomain.com/api/v1/agent-inboxes \
  -H "Authorization: Bearer $CLOUDMAIL_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"domain":"yourdomain.com","purpose":"Invoice triage",
       "send_mode":"approve","ttl_hours":24,
       "allowed_recipients":["@partner.com"]}'
```

## Approval is the default

Anyone can email your mailbox, and an AI that reads that email can be steered by it. So the server, not the client, decides whether a send from an agent goes out. The rule covers every route an agent credential can send through: MCP tools, the REST API, scheduled sends, templates and sequence enrolment.

- **No agent approves its own send.** There is no MCP tool to approve, and a token can't decide a send it, its parent or its child asked for.
- **What you approve is what is sent.** The held message is fully composed, and an edit replaces it.
- **Suspicious reads hold sends.** If what an agent just read looks like a prompt injection, its sends are held for 30 minutes whatever the mode.
- **Exactly once.** An approved send is claimed before the provider is called, so a retry can't send it twice.

| Mode, per mailbox | Setting | What an agent send does |
| --- | --- | --- |
| Drafts only | `draft_only` | Agents can read and write drafts. Any send from an agent is refused. |
| Approve every send (default) | `approve` | Agent sends wait in Pending approval. The API answers 202 pending_approval with a link for the reviewer. |
| Send automatically | `auto` | Only for a credential you trusted with it: a token with mail:send:auto, or an app marked Send without approval. |

Only a signed-in person can change the mode. A per-mailbox recipient allowlist lets sends to known addresses skip the queue. [How send approval works](https://trycloudmail.com/features/agent-send-approval).

## MCP server

73 tools at `/mcp` over Streamable HTTP. Clients sign in through your browser with OAuth 2.1, so there's no token to paste, and you can disconnect each app from your account settings.

- **Read and search**: list_emails, get_thread, search_emails, semantic_search, ask_inbox, get_daily_brief, list_people
- **Organise**: apply_label, move_email, archive_email, snooze_email, bulk_update, create_rule, screen_sender
- **Draft and send**: draft_reply, create_draft, send_reply, send_email, forward_email, schedule_send, send_template
- **Held sends**: list_pending_sends, get_pending_send, revise_pending_send
- **Admin**: list_domains, get_domain_status, create_agent_inbox, list_webhooks, get_usage, get_analytics

Every tool carries read-only and destructive hints. No tool deletes mail permanently. Message bodies come back marked as untrusted content. [What an MCP client can do](https://trycloudmail.com/features/email-mcp-server), and the [full tool list and client setup](https://github.com/cloudmail-hq/cloudmail/blob/main/docs/mcp.md).

### Claude Code

```bash
# Signs in through your browser with OAuth
claude mcp add --transport http cloudmail \
  https://mail.yourdomain.com/mcp

# Headless agents use an API token instead
claude mcp add --transport http cloudmail \
  https://mail.yourdomain.com/mcp \
  --header "Authorization: Bearer ttk_..."
```

Claude Desktop and Cursor connect with the same URL.

## CLI

One tool for a person at a terminal and a script in a pipe: aligned tables when you're looking, JSON when you're not, exit codes that say what failed, and `--dry-run` on everything that changes state.

Prebuilt for macOS, Linux and Windows on [GitHub releases](https://github.com/cloudmail-hq/cloudmail/releases/latest), or build it from [cli/](https://github.com/cloudmail-hq/cloudmail/tree/main/cli) in the repo.

```bash
cloudmail config set base-url https://mail.yourdomain.com
cloudmail auth login            # paste a ttk_ token; input is hidden

cloudmail mail list --folder inbox --unread --limit 10
cloudmail mail send --to priya@example.org \
  --subject 'Pilot start' --text 'Monday works.' --dry-run
cloudmail approval list          # sends held for a person
cloudmail events tail --mailbox support@yourdomain.com
```

## Agent Skill

One install teaches Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot and other coding agents to work with your deployment: read, search and summarise mail, draft replies for you to review, send when you ask, and run an agent inbox of their own. It treats every email as data, never as instructions, and reports a held send to you instead of retrying it.

Works through the CLI or your MCP server. [cloudmail-hq/skills on GitHub](https://github.com/cloudmail-hq/skills).

```bash
# Claude Code
/plugin marketplace add cloudmail-hq/skills
/plugin install cloudmail@cloudmail

# Codex, Cursor, Gemini CLI, Copilot and others
npx skills add cloudmail-hq/skills
```

## TypeScript and Python SDKs

Both cover every REST operation a token can use, send an idempotency key with every send, and never retry a send on a server error. A held send comes back as a typed result your agent can revise or wait on. Both include webhook verification and a reconnecting event stream.

Install from [sdk/](https://github.com/cloudmail-hq/cloudmail/tree/main/sdk) in the repo.

### TypeScript

```ts
import { Cloudmail, isPendingApproval } from "@cloudmail/sdk";

const mail = new Cloudmail({
  baseUrl: "https://mail.yourdomain.com",
  token: process.env.CLOUDMAIL_TOKEN!,
});

const result = await mail.mail.send("support@yourdomain.com", {
  to: "priya@example.org",
  subject: "Pilot start date",
  text: "Monday works.",
});

if (isPendingApproval(result)) {
  // Nothing was sent. A person approves it in the app.
  console.log("held:", result.approval_url);
}
```

### Python

```python
from cloudmail import Cloudmail, is_pending_approval

cm = Cloudmail("https://mail.yourdomain.com", token="ttk_...")

result = cm.mail.send(
    "support@yourdomain.com",
    to="priya@example.org",
    subject="Pilot start date",
    text="Monday works.",
)
if is_pending_approval(result):
    print("Waiting for approval:", result.approval_url)  # don't retry
```

## Webhooks and live events

Signed JSON events, retried six times over about nine hours. The payload is a summary, never the message itself. The same events stream over WebSocket or Server-Sent Events, and replay from where a client left off.

| Event | Sent when |
| --- | --- |
| `message.received` | Mail was stored in a mailbox |
| `message.sent` | The sending provider accepted a message |
| `message.delivery_failed` | A send failed or the recipient was suppressed |
| `message.bounced` | A permanent bounce came back |
| `message.opened / message.clicked` | Tracking pixel loaded, or a tracked link followed |
| `deliverability.warning` | A domain's complaint rate crossed 0.1%, or bulk sending paused at 0.3% |
| `usage.budget_exceeded` | Projected AI or sending cost passed your budget |

### Verify a webhook (Node)

```js
import crypto from "node:crypto";

// X-Tapetide-Signature: v1=<hex>, HMAC-SHA256 of `${timestamp}.${rawBody}`
const expected = "v1=" + crypto
  .createHmac("sha256", secret)
  .update(`${ts}.${rawBody}`)
  .digest("hex");
const ok = crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected));
```

## REST API

- **OpenAPI 3.1**: Served by every deployment at `/api/v1/openapi.json`, with a readable reference at `/api/docs`.
- **Scoped tokens**: Limit a token to scopes such as mail:read or mail:send, and to particular mailboxes.
- **Idempotency keys**: Every send and create accepts one. A repeat returns the first response for 24 hours instead of sending again.
- **Rate limits per caller**: 600 API requests and 120 MCP requests a minute, plus each mailbox's send caps.
- **More**: [The email API, CLI and SDKs in one page](https://trycloudmail.com/features/email-api).

## Related

- [Features](https://trycloudmail.com/features)
- [Docs](https://trycloudmail.com/docs)
- [MCP, API and CLI](https://trycloudmail.com/mcp)
- [Pricing](https://trycloudmail.com/pricing)
