Trusted by teams building with AI

Atlassian is a customer of Mailtrap
Adobe is a customer of Mailtrap
Yelp is a customer of Mailtrap
PayPal is a customer of Mailtrap
Toptal is a customer of Mailtrap
Calendly is a customer of Mailtrap

One API for the complete agent email lifecycle

Test outbound email, receive inbound messages, trigger workflows, and send replies — all via Mailtrap API.

  • /inbound/folders/{id}/inboxes

    Create dedicated inboxes for agents or AI workflows in seconds.

  • /inbound/inboxes/{id}/messages/{id}/reply

    Reply in-thread; Mailtrap handles headers and sender address.

  • /sandboxes/{id}/messages/{id}

    Inspect captured messages, spam score, HTML – before any email reaches a recipient.

  • Mailtrap /templates endpoint

    /api/webhooks

    Get real-time notifications when emails arrive, so your workflows react instantly without polling.

Copy

curl -X GET https://mailtrap.io/api/inbound/folders/{folder_id}/inboxes \
  -H 'Authorization: Bearer YOUR_API_KEY'

Everything your agent needs to work with email

Hosted inboxes

Create dedicated inboxes for agents, workflows, customers, or environments in seconds.

Structured email parsing

Get emails as clean JSON with sender, recipients, content, headers, and metadata.

Real-time webhooks

Trigger agent workflows instantly when new email arrives.

Conversation threading

Keep full email context by fetching entire conversations, not isolated messages.

Attachments as URLs

Access files on demand without loading large attachments into your agent context.

Sandbox testing

Test inbound email workflows safely before connecting production inboxes.

Built for teams adding email to AI agents and workflows

Whether you're building Mailtrap provides the complete email layer to manage email via a single API and MCP server.

  • Engineering teams

    Engineering teams

    Add inbound email to your product without running email infrastructure.

    • Create inboxes programmatically
    • Receive parsed email as structured JSON
    • Store messages, attachments, and conversation history
    • Trigger application logic from incoming email
  • AI builders & enthusiasts

    AI builders & enthusiasts

    Give every agent its own inbox and full email context.

    • Create inboxes for agents, assistants, and copilots
    • Turn incoming email into agent events
    • Access complete conversation threads
    • Reply in-thread through the API
  • Automation & ops builders

    Automation & ops builders

    Use email as a trigger for workflows and business processes.

    • Start workflows when emails arrive
    • Route messages to the right system or team
    • Process invoices, approvals, and notifications
    • Connect email to n8n, Make, or custom automations

Common use cases for the Inbound Email API

How teams use inbound email with Mailtrap’s API

AI Support Agent

AI Support Agent

Receive support emails, create tickets, draft replies.

AI Receptionists

AI Receptionists

Read appointment requests, answer common questions, and schedule meetings.

GitHub Automation

GitHub Automation

Convert alert emails into issues and tasks.

Invoice Processing

Invoice Processing

Extract PDFs and trigger accounting workflows.

AI agent quality testing

AI agent quality testing

Inspect every email your agent drafts and catch the bad ones before a customer sees them.

Inbound reply testing

Inbound reply testing

Test how your agent replies to inbound emails before those replies ever go out.

Question icon

Frequently Asked Questions

  • How do you give an AI agent its own programmable email inbox?

    Call the Mailtrap API to create an inbox, then register a webhook URL where your agent gets notified when new mail arrives. Start on a Mailtrap-hosted address with no MX records, no DNS, and no mail server to set up, or connect your own custom domain when you’re ready for production. The moment an email lands, your agent gets a webhook notification and can fetch the fully parsed message from the Messages API. Create or delete inboxes programmatically for each agent, project, or session.

  • Why give an agent a dedicated inbox instead of access to Gmail?

    OAuth into a personal Gmail account hands your agent someone’s entire mailbox, with all the privacy, scope, and security questions that it brings, and it breaks the moment a token is revoked. A dedicated agent inbox is isolated, scoped to addresses you control, and provisioned per agent or project. Your agent only ever sees emails meant for it, and you can spin inboxes up or tear them down without touching anyone’s personal account.

  • Do I need a custom domain or DNS setup to receive email?

    No, not to get started. A Mailtrap-hosted inbox works the moment you create it, with nothing to add in DNS and no MX records to configure. When you’re ready for production, connect your own custom domain and keep the same API and webhooks. Replies go out the same way in both cases, with a single API call.

  • Can my agent reply to inbound emails?

    Yes. Replying is part of the same API, so your agent answers in-thread with a single API call and the conversation flows both ways. On a Mailtrap-hosted inbox, replies are capped at 20 in total; connect your own custom domain and that limit goes away.

  • What is an email sandbox for AI agents?

    It’s a safe, Mailtrap-hosted environment that captures the email your AI agent sends instead of delivering it. Your agent sends exactly as it would in production but every message lands in the sandbox, where you can read the content, headers, and attachments, check the spam score, and validate the HTML. Nothing reaches a real recipient, so you can test what an agent generates without any risk of emailing a customer by mistake.

  • How do I add a human-in-the-loop approval step to my AI email workflow?

    A common approach is to have your AI agent generate emails in Mailtrap Sandbox first instead of sending them directly.

    You can review the message in the Mailtrap UI or retrieve its content, spam score, HTML checks, and other analysis via API. If changes are needed, your AI agent can revise the draft and send an updated version to Sandbox for another review cycle.

    Once the email looks right, switch to Mailtrap’s sending endpoint (or the Inbound Reply API for inbound conversations) to deliver the final message. This creates a simple human approval workflow without changing your email generation logic.