canonical: https://jentic.com/apis/mails.ai/mails-ai

# Mails.ai API

The Mails.ai API gives AI agents their own email identity, sending and receiving transactional email through per-agent mailboxes. Outbound mail goes out as single sends, batches of up to 100 messages, replies, forwards, scheduled sends, and drafts, with an Idempotency-Key header to stop duplicate sends. Inbound mail is run through an intent and prompt-injection classifier and delivered as typed events you can list, stream over Server-Sent Events, or receive by webhook. The API also manages agents with send limits and domain allowlists, custom send domains, API keys with send, read, and manage scopes, threads, suppression, and reputation.

## For AI agents

Give your agent its own mailbox to send, reply to, forward, and schedule email, read classified inbound messages and threads, and manage webhooks, domains, and send limits.

## Scope

Does not handle marketing campaign design, contact list management, SMS, or email address verification. Use for sending and receiving email from AI agent mailboxes only.

## Capabilities

- Send a message from a named agent with POST `/v1/messages`, or up to 100 messages at once with POST `/v1/messages/batch`, using an Idempotency-Key header to avoid double sends
- Reply to, forward, reschedule, or cancel a sent message by its id
- Read received messages and full threads, with SPF and DKIM results and extracted text on each inbound message
- Follow inbound activity through cursor-paginated events filtered by event_type, agent_id, and since, or a live Server-Sent Events stream
- Create agents with daily_send_limit, hourly_send_limit, allowlist_domains, blocklist_domains, and classify_inbound settings
- Register webhook endpoints, inspect delivery attempts, and replay a failed delivery
- Add and verify custom send domains, and simulate inbound mail end to end with a mk_test_ key

## Use cases

### An agent mailbox connected through Jentic

A support agent gets its own Mails.ai identity, reads inbound messages that arrive already classified for intent and prompt injection, and replies in thread. Through Jentic the agent finds the send and reply operations by intent, the mk_live_ key stays in the developer's own Jentic One instance, and a rule can keep the agent on reading and replying while key, domain, and billing operations stay out.

Example prompt: Call GET `/v1/messages/received` with agent_id 'support' and limit 10, then POST `/v1/messages/{id}/reply` on the newest message with body_text 'Thanks, we are looking into it.'

### Transactional sends with idempotency

Order and account notifications go out through POST `/v1/messages` with to and subject required and body_text or body_html as content, or in batches of up to 100 through POST `/v1/messages/batch` where per-message failures come back inline. Passing the same Idempotency-Key on a retry replays the stored response instead of sending twice, and scheduled_at defers delivery.

Example prompt: POST `/v1/messages` with agent 'support', to 'jordan@example.com', subject 'Your order #10473 has shipped', body_text, and an Idempotency-Key header of 'order-10473-shipped'

### Inbound event handling with webhooks

To react to incoming mail, register an endpoint with POST `/v1/webhooks` and a list of event_types, then watch GET `/v1/webhooks/{id}/deliveries` for failed attempts and replay them with POST `/v1/webhook-deliveries/{id}/replay.` Where webhooks are not practical, GET `/v1/events/stream` provides a Server-Sent Events tail that resumes from the last event id.

Example prompt: POST `/v1/webhooks` with url 'https://example.com/hooks/mail' and event_types ['message.received'], then POST `/v1/webhooks/{id}/test` to send a test event

### Testing an integration without sending real mail

A mk_test_ key exercises the whole API with real validation and real events but no outbound mail or cost. POST `/v1/test/inbound` simulates an inbound email for a given agent, from address, and body_text, so the classifier, events, and webhooks can be tested before switching to a live key.

Example prompt: Using a mk_test_ key, POST `/v1/test/inbound` with agent 'support', from 'customer@example.com', and body_text 'Where is my order?', then GET `/v1/events` with since set to the current time

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/v1/messages` | Send a message |
| POST | `/v1/messages/batch` | Send a batch of messages |
| POST | `/v1/messages/{id}/reply` | Reply to a message |
| GET | `/v1/messages/received` | List received messages |
| GET | `/v1/threads/{id}` | Retrieve a thread with messages |
| POST | `/v1/agents` | Create an agent |
| GET | `/v1/events` | List events |
| POST | `/v1/webhooks` | Create a webhook endpoint |

## Key resources

- **Messages** — Sent and received messages, with reply, forward, reschedule, cancel, and raw .eml download
- **Agents** — Per-agent mailboxes with send limits, domain allow and block lists, and inbound classification
- **Threads** — Conversations with their messages, labels, and status
- **Events and webhooks** — Typed events, an SSE stream, webhook endpoints, delivery attempts, and replay
- **Domains and API keys** — Custom send domains with verification, and scoped live or test API keys

## AI readiness

This API is usable in Jentic One now. Its AI-readiness score against Jentic's framework shows where it stands today and where improvements would make it even easier for agents to use.

- **Score:** 67 / 100
- **Maturity:** AI-Aware
- **Dimensions:**
  - Foundational Compliance: 84 / 100
  - Developer Experience & Jentic Compatibility: 69 / 100
  - AI-Readiness & Agent Experience: 47 / 100
  - Agent Usability: 93 / 100
  - Security: 60 / 100
  - AI Discoverability: 77 / 100
- **View full report:** https://jentic.com/apis/mails.ai/mails-ai/scorecard
- **How the score is calculated:** https://docs.jentic.com/reference/api-readiness-framework/overview/
- **More about the dimensions:** https://docs.jentic.com/reference/api-readiness-framework/specification/#dimensional-model-overview

### Score it yourself

Every API in the directory is allowlisted, so you can re-score it with no key required.

- **Score your own API:** https://jentic.com/scorecard.md
- **Scoring CLI agent skill:** https://github.com/jentic/jentic-api-scorecard/blob/main/skills/jentic-api-scorecard/SKILL.md

```sh
npx @jentic/api-scorecard-cli score <openapi-url>
```

## Why Jentic

- **Setup:** Wiring Mails.ai by hand means handling its bearer keys with send, read, and manage scopes, switching between mk_test_ and mk_live_ modes, cursor pagination, and Idempotency-Key headers yourself. Through Jentic you install once, import Mails.ai from the API Directory, store the key once, and your agent calls it.
- **Permission scoping:** Mails.ai puts message, thread, agent, and webhook ids in the URL path, so a rule can pin your agent to one thread or one message's reply and forward operations. New sends carry the agent and recipients in the request body, so those are bounded by operation, and you choose the operations it may call, so destructive ones like revoking API keys or deleting domains are not included unless you add them.
- **Credential handling:** Your Mails.ai API key is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'send an email' or 'list received messages', and Jentic returns the matching Mails.ai operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Resend API** — Developer email sending API for transactional mail
- **Postmark Server API** — Transactional email sending and inbound processing per server
- **MailProbe API** — Real-time email address verification

## FAQ

### Is there a Mails.ai MCP server?

You don't need an MCP server to give your agent Mails.ai. Jentic connects it directly from the API Directory: import it, store your API key once, and your agent calls it. Operations are discovered on demand, so the API's many operations do not load as tool definitions into the agent's context.

### What authentication does the Mails.ai API use?

Per its OpenAPI spec, the Mails.ai API uses bearer authentication with a mk_live_ or mk_test_ key in the Authorization header. Keys carry send, read, or manage scopes, and each operation notes the scope it needs. The unsubscribe and health check operations are open and take no key. Through Jentic the key is stored encrypted by your own Jentic One instance and injected at execution time, so it never enters the agent's context.

### Can I limit what my agent is allowed to do with Mails.ai?

Yes. For example, write a rule that allows GET `/v1/messages/received`, GET `/v1/threads/{id}`, and POST `/v1/messages/{id}/reply`, so the agent can read its inbox and answer existing conversations but cannot start new sends, create API keys, or delete domains. Every call it makes is logged on your own machine.

### Does Mails.ai protect my agent from prompt injection in incoming email?

Inbound messages are run through an intent and prompt-injection classifier. The classification includes an injection_score and injection_categories alongside intent, entities, urgency, and sender_reputation, so your agent can check the score before acting on a message. Classification is controlled per agent with the classify_inbound setting.

### How do I send an email through Jentic?

Install Jentic One, import the Mails.ai API from the directory, and search for 'send an email from my agent'. Jentic returns the sendMessage operation with its input schema; your agent supplies to and subject plus body_text or body_html, and can add an Idempotency-Key header for safe retries. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I test Mails.ai without sending real email?

Yes. A mk_test_ key runs the full API with real validation, persisted resources, and real events and webhooks, but sends no real email and incurs no cost. Use POST `/v1/test/inbound` with a test key to simulate an inbound message end to end.

### What are the rate limits for the Mails.ai API?

The OpenAPI spec does not state request rate limits for the API itself. Per-agent sending is capped by the daily_send_limit and hourly_send_limit settings on each agent. Check https://mails.ai for current account limits.
