# Mails.ai > The AI email API for agents and developers. Email infrastructure built specifically for AI — drop ~6 lines into any agent 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, and sending works immediately — no approval queue. What is gated is the CONTENT: cold outreach and bulk marketing are refused by the API, which is why the sending estate stays deliverable. ## 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. Open source (MIT): the MCP server, the TypeScript SDK and the Python SDK are public at https://github.com/RolloutsAI/mailsai, with six runnable examples (first send, inbox loop, the injection firewall, OpenAI Agents SDK, LangGraph, MCP client config). The API implementation itself is closed. - [Source code and examples](https://github.com/RolloutsAI/mailsai): MIT-licensed MCP server, TypeScript and Python SDKs, and six runnable examples you can execute on a test key. ## 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 → first send (your agent is created automatically) → 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): The TypeScript SDK and the MCP server are on npm now; the Python SDK is coming next. All thin wrappers over the same REST surface. ## Blog - [The firewall between your AI agent and your sending reputation.](https://mails.ai/blog/agent-email-firewall): The scary part of letting an AI agent send email isn't a typo — it's that a bad loop, a poisoned input, or one abusive tenant can get your whole domain flagged as a spammer. Mails.ai is built as a firewall for exactly that: a reputation classifier and suppression check run before any send leaves, a complaint cron auto-suspends senders at 0.3% (before AWS SES's 0.5% threshold trips), reputation is isolated per agent and per workspace, and inbound is injection-scanned. Cold outreach is explicitly not a supported use case. - [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. - [AI Email Platform Architecture Guide for Developers](https://mails.ai/blog/ai-email-platform-architecture-guide): Learn how AI email platforms differ from transactional APIs: inbound parsing, MCP, classification, and agent-native architecture explained. - [AgentMail API vs Mails.ai: Best Email API for AI Agents](https://mails.ai/blog/agentmail-api-vs-mailsai): AgentMail API vs Mails.ai: a deep technical comparison of pricing, inbound parsing, MCP support, deliverability, and architecture for AI agent developers. - [Inbound Email Webhooks for AI Agents: Parse & Act](https://mails.ai/blog/inbound-email-webhooks-ai-agents-classification-parsing-actions): Learn how to wire inbound email webhooks for AI agents: MIME parsing, classification pipelines, idempotency, and automated action patterns with real code. - [AI in Email: Agents as Senders, Receivers & Reasoners](https://mails.ai/blog/ai-in-email-agents-action-layer): AI in email goes beyond notifications. Learn how agents send, receive, parse, and act on email as a full action layer with real engineering patterns. - [Mails.ai vs SendGrid for AI Agent Email: API Comparison](https://mails.ai/blog/mails-ai-vs-sendgrid-ai-agent-email): Mails.ai vs SendGrid for AI agent email: compare transactional APIs, inbound parsing, MCP support, pricing, and deliverability for automated senders. - [Securing an Agent Email Inbox Against Spoofing](https://mails.ai/blog/securing-agent-email-inbox-against-spoofing): Learn how to secure an agent email inbox against spoofing using SPF, DKIM, DMARC, webhook validation, and sender verification for AI agents. - [Compare Transactional Email Providers: Inbound Parsing & Routing (2026)](https://mails.ai/blog/best-inbound-email-parsing-api-for-developers): Compare transactional email providers that offer inbound email parsing and routing. Mailgun, SendGrid, Postmark, and Mails.ai — features, pricing, and a clear pick. - [AI Email Agent: Give Your Agent Its Own Address & Inbox](https://mails.ai/blog/ai-email-agent-address-inbox-send-capability): Learn how to give an AI email agent its own address, inbox, and send capability. Covers DNS setup, inbound parsing, SMTP auth, and threading. - [SPF DKIM DMARC for Automated Email Senders](https://mails.ai/blog/spf-dkim-dmarc-automated-email-senders): A technical guide to SPF, DKIM, and DMARC for automated and AI agent email senders. Configure authentication correctly and protect deliverability. - [Mailgun vs Mails.ai for Agent Email: Full Comparison](https://mails.ai/blog/mailgun-vs-mails-ai-agent-email): Mailgun vs Mails.ai for agent email: compare architecture, pricing, inbound parsing, MCP support, and deliverability to pick the right API for your AI agent. - [AI Mail: Dedicated Email APIs for Autonomous Agents](https://mails.ai/blog/ai-mail-dedicated-email-apis-autonomous-agents): How developers wire autonomous AI agents to dedicated email APIs — covering architecture, SPF/DKIM/DMARC, threading, parsing, and deliverability patterns. - [Mails.ai vs Resend vs Postmark for AI Agents (2025)](https://mails.ai/blog/mails-ai-vs-resend-vs-postmark-ai-agents): Side-by-side comparison of inbound parsing, MCP support, webhooks, and deliverability. See which transactional email API fits agentic workflows. - [AI Agent Email Addresses: Using Real .ai Domains](https://mails.ai/blog/what-is-ai-email-address-how-ai-agents-use-real-email-domains): AI agents need real email addresses for identity, replies, and async workflows. See how .ai domains work with transactional and inbound email APIs. - [Email Deliverability for Automated and AI Senders](https://mails.ai/blog/email-deliverability-automated-ai-senders): Email deliverability for automated and AI senders explained: SPF, DKIM, DMARC, IP warming, reputation management, and sending patterns that keep agents out of spam. - [Unique Reply-To Address | Route Agent Replies Reliably](https://mails.ai/blog/unique-reply-to-address): Learn how a unique reply-to address lets each agent route replies, preserve threading, verify identity, and process inbound email safely. - [AI Email API vs Transactional Email API: Key Differences](https://mails.ai/blog/ai-email-api-vs-transactional-email-api): Learn what an AI email API is, how it differs from a transactional email API, and which architecture your agent or application actually needs. - [mails.ai — Transactional & Inbound Email API for AI Agents](https://mails.ai/blog/ai-email-automation): Send transactional email and parse inbound replies in one API built for AI agents. Dynamic addresses, webhook delivery, thread tracking. Free tier available. - [B2B Contact Database Architecture for Agent-Driven Email](https://mails.ai/blog/b2b-marketing-database): How to design a contact database that supports agent-driven email workflows. Covers schema design, enrichment via inbound parsing, verification loops, and API integration patterns for B2B teams. - [B2B Leads Using SEO: How Search Traffic Converts with Agent-Driven Email](https://mails.ai/blog/b2b-leads-using-seo): How B2B teams use SEO to attract high-intent visitors and convert them into qualified pipeline using AI agent email workflows, structured reply handling, and automated follow-ups. - [Best B2B Demand Generation Tools for 2026](https://mails.ai/blog/b2b-lead-generation-tools-2026): Compare the top demand gen platforms and contact discovery tools B2B revenue teams use to fill pipeline and close more deals in 2026. - [AI Agent Transactional Email Patterns for Developers](https://mails.ai/blog/ai-agent-transactional-email-patterns): Learn how to send transactional email from an AI agent for OTPs, magic links, and notifications with secure, reliable delivery patterns. - [Top B2B Pipeline Tools for Revenue Teams in 2026](https://mails.ai/blog/b2b-lead-generation-tools): What B2B revenue teams actually use to find accounts, verify contacts, and fill pipeline — data providers, intent platforms, and enrichment tools compared. - [Transactional Email Pipeline: OTPs, Magic Links & Routing](https://mails.ai/blog/transactional-email-pipeline-otps-magic-links-notification-routing): Build a production-grade transactional email pipeline for AI apps: OTP delivery, magic link signing, notification routing, and deliverability mechanics explained. - [AI Email Automation for Developers: Triggers, Routing & Agent Actions](https://mails.ai/blog/ai-email-automation-developers-triggers-routing-agent-actions): A technical guide to AI email automation: transactional triggers, inbound routing pipelines, and agent actions — with code patterns and architecture advice for developers. - [AI Email API: Give Your AI Agent Its Own Email Address](https://mails.ai/blog/ai-agent-own-email-address): Learn how to provision a dedicated email address for your AI agent using DNS, SMTP, and inbound webhooks. Covers addressing, authentication, and thread management. - [Giving Your AI Agent an Inbox: Routing, Parsing & Webhooks](https://mails.ai/blog/ai-agent-inbox-inbound-email-routing-parsing-webhooks): Learn how to give your AI agent a real inbox: DNS routing, MIME parsing, webhook delivery, and idempotency patterns for production systems. - [Email Automation for AI Agents: API Pipeline Guide](https://mails.ai/blog/email-automation-ai): Learn how to wire AI agents to send, receive, and act on email via API. Covers routing, classification, and webhooks. Built for developers using mails.ai. - [Sending Transactional Email from AI Agents: OTPs, Links, Notifications](https://mails.ai/blog/transactional-email-ai-agents-otps-sign-in-links-notifications): Learn how AI agents should send OTPs, magic links, and notifications with correct headers, idempotency keys, rate limits, and deliverability controls. - [Mails.ai vs AgentMail: Email API for AI Agents](https://mails.ai/blog/mailsai-vs-agentmail-email-api-ai-agents): Mails.ai vs AgentMail compared on architecture, pricing, MCP support, inbound parsing, and deliverability for AI agent email workflows. - [Parsing Email Attachments for LLM Ingestion](https://mails.ai/blog/parsing-email-attachments-for-llm): A technical guide to extracting, normalizing, and feeding email attachments into LLMs — covering MIME parsing, PDF extraction, OCR, and chunking strategies. - [Transactional vs AI Agent Email: Architectural Differences](https://mails.ai/blog/transactional-email-vs-ai-agent-email-architectural-differences): Deep dive into the core architectural differences between transactional email and AI agent email — threading, state, inbound parsing, and deliverability. - [Inbound Email Processing for AI Agents: Classification, Routing, Actions](https://mails.ai/blog/inbound-email-processing-ai-agents-classification-routing-actions): How AI agents classify, route, and act on inbound email: parsing raw MIME, intent classification, routing logic, and triggering deterministic actions reliably. - [RFC-Compliant Email Replies from AI Agents](https://mails.ai/blog/rfc-compliant-email-replies-ai-agents): Learn how AI agents can compose RFC 5322-compliant email replies with correct threading headers, MIME structure, and quoting conventions. - [Idempotent Email Sending for AI Agents: Code Guide](https://mails.ai/blog/idempotent-email-sending-for-ai-agents): Stop duplicate emails in agent retry loops. Implement idempotency keys with the mails.ai API — includes working Python and Node.js examples. Read the guide. - [How AI Agents Should Handle Email Replies](https://mails.ai/blog/how-ai-agents-handle-email-replies): A technical guide to threading, reply detection, context management, and response generation for AI agents that send and receive email. - [Building an Email-Driven Agent Workflow](https://mails.ai/blog/building-email-driven-agent-workflow): Learn how to build production-grade email-driven agent workflows: inbound parsing, state machines, threading, tool dispatch, and deliverability for automated senders. - [Structured Reply Events for Email Agents](https://mails.ai/blog/structured-reply-events-for-email-agents): Learn how to design structured reply events so your email agents can parse, route, and act on inbound replies with precision — covering schemas, threading, and idempotency. - [Email API for AI Agents: Architecture & Provider Guide](https://mails.ai/blog/email-api-for-ai-agents-architecture-provider-guide): Compare email API providers for AI agents. Covers MCP support, inbound parsing, deliverability, and architecture — with a clear recommendation for agent builders. - [How to Build an MCP Email Server for AI Agents](https://mails.ai/blog/how-to-build-mcp-email-server-for-ai-agents): Learn how to build an MCP email server that lets AI agents send, receive, and parse email via the Model Context Protocol — with real code and architecture. - [Webhook-Based Inbound Email Processing for AI Agents](https://mails.ai/blog/webhook-based-inbound-email-processing-agents): Learn how to build reliable webhook-based inbound email pipelines for AI agents — parsing, routing, threading, and handling edge cases at scale. - [Transactional vs Agent Email Architecture](https://mails.ai/blog/transactional-vs-agent-email-architecture): Learn the core architectural differences between transactional and agent email systems—covering SMTP flows, inbound parsing, threading, webhooks, and MCP integration. ## Glossary - [Email](https://mails.ai/glossary/email): A message sent between addresses over the internet using SMTP — the foundational transport layer that AI agents use to communicate with humans and other systems. - [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. - [Automatic Mail](https://mails.ai/glossary/automatic-mail): Email sent programmatically by an AI agent or automated system — triggered by logic, events, or schedules — without a human composing or approving each message. - [AI-powered email](https://mails.ai/glossary/ai-powered-email): Email that is composed, addressed, timed, and sent by an AI agent rather than a human — with replies routed back to the agent as structured events for further action. - [AI email content](https://mails.ai/glossary/ai-email-content): AI email content is message copy generated by an AI agent for a specific recipient, event, or workflow — then sent, measured, and improved through the email infrastructure around that agent. - [AI email agent](https://mails.ai/glossary/ai-email-agent): An AI email agent is an autonomous software agent that sends, receives, and acts on email on behalf of a user or system — composing messages, parsing replies, and taking follow-up actions without human intervention. - [AI email platform](https://mails.ai/glossary/ai-email-platform): An AI email platform is infrastructure that gives AI agents dedicated sending and receiving addresses, structured inbound parsing, prompt-injection scanning, and enforced outbound constraints — so an autonomous agent can participate in email conversations safely. ## Optional - [Sitemap](https://mails.ai/sitemap.xml): Full XML sitemap of all pages.