# Mails.ai > Email infrastructure for AI agents. Self-serve email API for AI agents — drop ~6 lines into your agent program and it gets a working email address with parsing, identity, and reputation built in. Typed reply events, per-agent reputation graph, native prompt-injection scanning, MCP-native distribution. Self-serve signup — no contact-sales gate. Every workspace is manually approved before it can send. ## API Base URL https://api.mails.ai — all endpoints under /v1 — auth header: Authorization: Bearer mk_live_. Send: POST /v1/messages with JSON { agent, to, subject, body_text }. Returns the sent message (id, status, cost_usd). Receive: GET /v1/events?event_type=message.received, live tail GET /v1/events/stream (SSE), or register a webhook with POST /v1/webhooks. - [API quickstart](https://mails.ai/docs/quickstart): Key, agent, first send, first reply event — five minutes. - [API reference](https://mails.ai/docs/api-reference): Every REST endpoint with exact request and response fields. ## Background - [Architecture](https://mails.ai/architecture): How sends and replies flow — send pipeline, typed reply events, per-agent reputation graph, multi-vendor failover. - [Use cases](https://mails.ai/use-cases): Four named agents on one primitive — support, notifications, doc-parse, browser 2FA. - [Pricing](https://mails.ai/pricing): Self-serve only. Free 3K events / Pro $20 (50K+50K) / Scale $99 (250K+500K) + Metered ($0.001/send + $0.002/inbound (+$0.003 opt-in classify)) (coming soon). Dedicated IP add-on $50/mo on Scale+, available on request. No Enterprise gate. - [About](https://mails.ai/about): What we are, what we ship, how we operate, what we don't do. - [Trust](https://mails.ai/trust): Security posture, sub-processors, audit roadmap. - [Sub-processors](https://mails.ai/sub-processors): Vendors that process customer data on our behalf. ## Comparisons - [vs AgentMail](https://mails.ai/vs/agentmail): AgentMail and Mails.ai both ship programmatic agent inboxes — the same primitive, different design choices. AgentMail is funded, in-market, and has 500+ B2B customers. Mails.ai goes deeper on typed reply events, prompt-injection scanning, per-agent reputation, and metered pricing. - [vs Resend](https://mails.ai/vs/resend): Resend is the dev-loved modern email API. Send-first DNA, polished DX, React Email open source, ~$1B valuation. Mails.ai is built for agents that read inbound — typed reply events, prompt-injection scanning, per-agent reputation, MCP-native. Different shape, different center of gravity. - [vs SendGrid](https://mails.ai/vs/sendgrid): SendGrid built the playbook for transactional email-as-a-service in 2009 and was acquired by Twilio in 2019. The platform is reliable, deeply integrated, and enterprise-trusted. Mails.ai is built for the 2026 agent era — different primitives, different design center. - [vs Postmark](https://mails.ai/vs/postmark): Postmark earned its premium-transactional reputation through deliverability obsession and human support. They are excellent at what they do. Mails.ai is built around the agent inbound primitive Postmark deliberately does not chase — typed reply events, injection scanning, MCP-native, metered economics. - [vs Amazon SES](https://mails.ai/vs/amazon-ses): SES is raw send/receive infrastructure at $0.10 per 1,000 emails — extreme cost efficiency, no agent abstractions. Mails.ai is the agent-native layer above it. Pick SES if you have engineering bandwidth to build the agent layer yourself; pick mails.ai if you want it shipped. - [vs Mailgun](https://mails.ai/vs/mailgun): Mailgun shipped the playbook for developer-first email APIs in 2010 and has 14+ years of production iteration behind them. Mails.ai is the agent-era equivalent — typed reply events, injection scanning, MCP-native. Different design centers, different decades, both coherent. - [vs Cloudflare Email](https://mails.ai/vs/cloudflare-email): Cloudflare Email Routing is inbound-only forwarding bundled with Workers. Public Workers-Email send is in beta (April 2026). For free, edge-distributed, Workers-tied inbound routing, they win. For real send + reply primitives + agent abstractions, mails.ai is the right shape. - [vs Loops](https://mails.ai/vs/loops): Mails.ai is a different shape from Loops — agent inbound primitives (typed reply events, injection scanning, per-agent reputation) that a SaaS lifecycle tool doesn't ship. Coherent for different problem spaces. ## Integrations - [Claude Code](https://mails.ai/integrations/claude-code): One JSON snippet in ~/.claude.json and your Claude Code session has email. mails.send / mails.on_reply / mails.list_threads / mails.suppress / mails.get_reputation tools auto-discovered, no SDK install, no glue code. - [Cursor](https://mails.ai/integrations/cursor): Same JSON snippet as Claude Code, dropped into ~/.cursor/mcp.json. Cursor auto-discovers the mails.* tools, surfaces them in the tool execution preview, and the in-IDE agent can send + read email without leaving the editor. - [Cline](https://mails.ai/integrations/cline): Same MCP server config as Claude Code and Cursor — pasted into Cline's MCP Settings panel. Mails.* tools auto-register, Cline's plan-mode previews tool calls before executing, and the autonomous-loop agent can send + read email as part of multi-step task runs. - [Continue](https://mails.ai/integrations/continue): Continue runs in both VS Code and JetBrains IDEs. Drop the mails.ai MCP server config into ~/.continue/config.json and the same five mails.* tools become available to Continue's chat, autocomplete, and agent modes — same shape, two editor ecosystems covered. - [Windsurf](https://mails.ai/integrations/windsurf): Windsurf's Cascade is one of the most capable autonomous IDE agents. Drop the mails.ai MCP server into Codeium's MCP config and Cascade auto-discovers the five mails.* tools — usable in plan mode (review before send) or write mode (autonomous execution). - [OpenAI Agents SDK](https://mails.ai/integrations/openai-agents-sdk): OpenAI's Agents SDK speaks MCP via MCPServerStdio. Three lines wire mails.ai in. Or wrap the REST API as @function tools for fine-grained control. Both shapes documented here with full code. - [Anthropic SDK](https://mails.ai/integrations/anthropic-sdk): The Anthropic SDK ships built-in MCP-client primitives. Three lines wire mails.ai in as a tool surface for any Claude conversation. Or use the @mailsai/sdk client directly for fine-grained control. Both paths documented here. - [Vercel AI SDK](https://mails.ai/integrations/vercel-ai-sdk): Vercel AI SDK doesn't have first-class MCP-client primitives yet, so the integration is via the SDK's tool() helper wrapping the @mailsai/sdk client. Works seamlessly in Next.js Route Handlers, Server Actions, edge runtime, and node runtime. - [LangGraph](https://mails.ai/integrations/langgraph): LangGraph doesn't have native MCP-client primitives, so the mails.ai integration is via @tool decorated functions wrapping the REST API. Pattern works in StateGraph nodes, conditional edges, and parallel-fanout flows. Full Python example with state persistence. - [Pydantic AI](https://mails.ai/integrations/pydantic-ai): Pydantic AI brings the same type-safety obsession to agent code that Pydantic brought to data validation. mails.ai integrates as @agent.tool decorated functions with typed input schemas, dependency injection for the mails client, and structured output for downstream graph nodes. ## Documentation - [Quickstart](https://mails.ai/docs/quickstart): Key → agent → first send → first reply event. The five-minute path through the REST API, with copy-paste curl and fetch. - [Authentication](https://mails.ai/docs/authentication): Bearer keys, the mk_live_ format, three scopes (send / read / manage), live vs test mode, and rotation. Everything about authenticating a request. - [Core concepts](https://mails.ai/docs/concepts): Workspace, agent, message, event, thread, draft, webhook, suppression, reputation — the eight nouns the API is built from, and how they fit together. - [API reference](https://mails.ai/docs/api-reference): Every endpoint, with the exact request and response fields — messages, batch, received, events, webhooks, agents, keys, suppression. - [Errors](https://mails.ai/docs/errors): One envelope on every failure — type, code, message, param, request_id. The type → status mapping and the full code list. - [Events & streaming](https://mails.ai/docs/events): List events or tail the live SSE stream. Every event type, the inbound payload, and a reconnect-safe consumer. - [Webhooks](https://mails.ai/docs/webhooks): Register an endpoint, verify the HMAC signature, handle retries. The push half of the events model, done safely. - [Limits](https://mails.ai/docs/limits): Per-tier send caps, single-message payload limits, and the 429 + Retry-After behavior when you exceed them. - [SDKs & MCP](https://mails.ai/docs/sdks): REST is available now. The TypeScript/Python SDKs and the MCP server publish at Phase 1 launch — here's the shape they'll take. ## Blog - [Structured reply events — why your agent should never read raw email](https://mails.ai/blog/typed-reply-events): Most email APIs hand your agent a string body. Mails.ai parses every inbound into a structured reply event — injection score and sender reputation on every event, opt-in classification for intent, entities, and urgency — so your code reads against a structured object, not raw bytes. - [Prompt injection in inbound email is a real RCE class. Here's how mails.ai scans for it.](https://mails.ai/blog/prompt-injection-in-inbound-email): Prompt injection in agent runtimes is a tracked vulnerability class — Microsoft Security Response Center publishes AI-security advisories, OWASP catalogues it as LLM01. The vulnerability is structural: any agent that reads raw inbound text is exposed. Mails.ai runs a six-category scanner on every inbound before the structured reply event reaches your code, and flags high-confidence attacks (`quarantined`) so your agent skips them. - [Per-event metered pricing: why monthly tiers force over-commit](https://mails.ai/blog/per-call-mpp-pricing): Resend wants $20/month whether your agent sends 0 or 50,000 emails. Postmark wants $50. Agent traffic is bursty by nature — quiet days and incident spikes — so monthly tiers structurally force over-commit. Per-event metered pricing aligns cost to what you actually use, and incumbents cannot match without rebuilding their economics. - [MCP-native email — `from mails import agent` becomes the default agent comms primitive](https://mails.ai/blog/mcp-native-email): MCP collapsed N runtimes × M SDKs into one server that every runtime can use. Mails.ai shipped MCP-native from day one — drop a JSON snippet into your runtime config and your agent gets send, on_reply, list_threads, and get_reputation tools automatically. ## Glossary - [Structured reply event (reply.event)](https://mails.ai/glossary/typed-event): A structured object representing an inbound email reply. injection_score + sender_reputation are computed on every event; intent, entities, and urgency are added when opt-in classification is enabled. - [Injection score](https://mails.ai/glossary/injection-score): 0–1 risk score on every inbound structured reply event. Output of Mails.ai's six-category prompt-injection scanner. Above 0.95 the event is flagged `quarantined`. - [MCP server](https://mails.ai/glossary/mcp-server): Mails.ai's drop-in Model Context Protocol server. Distributed via npm as @mailsai/mcp-server. Exposes five tools (send, on_reply, list_threads, suppress, get_reputation) to MCP-capable runtimes — Claude Code, Cursor, Cline, Continue, Windsurf. - [Per-event metered pricing](https://mails.ai/glossary/per-call-mpp): Mails.ai's usage-based pricing tier, coming soon — Stripe metered billing at $0.001/send + $0.002/inbound (+$0.003 opt-in classify). No monthly minimum. Aligns cost to actual agent send + inbound volume rather than over-committed monthly tiers. - [Classifier](https://mails.ai/glossary/classifier): The reputation model that scores every send for abuse and complaint risk before it leaves the system. Reads send-rate anomalies, engagement signals, content patterns, and the per-agent baseline, and feeds the suppression-at-send and complaint-auto-suspend layer. - [Sender reputation](https://mails.ai/glossary/sender-reputation): An agent's reputation score (0–1), built from real engagement. Queryable today via the mails.get_reputation tool; the current API returns an agent's own score. Workspace-scoped — the API returns the agent's own score. ## Optional - [Sitemap](https://mails.ai/sitemap.xml): Full XML sitemap of all pages. - [Changelog](https://mails.ai/changelog): Release notes — what we shipped, when.