canonical: https://jentic.com/apis/documentation.mailgun.com/mailgun

# Documentation Mailgun Mailgun API

The Mailgun API is a transactional email delivery service that lets developers send messages and retrieve delivery details through a simple REST interface. This Jentic-curated specification exposes the two core operations: POST /{domain}/messages to send an email and GET /{domain}/messages/{messageId} to fetch a stored message by ID. Authentication uses HTTP Basic with the Mailgun private API key as the password. The API is suited to teams sending application-generated email such as receipts, notifications, and verification messages from a verified sending domain.

## For AI agents

Send a transactional email via Mailgun and retrieve the stored message by its ID using HTTP Basic authentication with a private API key.

## Scope

Does not handle SMS, push notifications, or voice calls - use for transactional email delivery and stored-message retrieval only.

## Capabilities

- Send a transactional email through POST /{domain}/messages
- Retrieve a stored message by ID via GET /{domain}/messages/{messageId}
- Address messages to multiple recipients in a single send
- Attach files and inline images to outbound messages
- Authenticate every call with HTTP Basic and the Mailgun private API key

## Use cases

### Transactional Email Delivery

Send transactional emails such as receipts, password resets, and account notifications by posting to /{domain}/messages with from, to, subject, and body fields. Mailgun handles routing, retries, and delivery tracking on the configured sending domain. Integrating the single send endpoint typically takes under an hour.

Example prompt: POST /{domain}/messages with from='noreply@example.com', to='user@example.com', subject='Receipt', and an HTML body, then capture the returned message id.

### Message Retrieval and Audit

Fetch a stored email by its message ID via GET /{domain}/messages/{messageId} to support audit logs, customer support lookups, and content review. The endpoint returns the original message body and headers so an agent or support tool can reproduce what was sent without storing the content separately.

Example prompt: GET /{domain}/messages/{messageId} for a known message id and parse the response body to confirm the recipient and subject line.

### AI Agent Notifications via Jentic

An AI agent calls Mailgun through Jentic to dispatch transactional notifications (alerts, summaries, status updates) on behalf of users. The agent searches Jentic for 'send an email', loads the schema for POST /{domain}/messages, and executes the call while Jentic injects the Mailgun Basic auth credential.

Example prompt: Search Jentic for 'send a transactional email', load the Mailgun POST messages operation, and execute it to notify a user that a long-running task has finished.

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/{domain}/messages` | Send an email message |
| GET | `/{domain}/messages/{messageId}` | Get message details by ID |

## Key resources

- **Messages** — Send outbound messages and retrieve stored messages by ID

## Why Jentic

- **Setup:** Wiring the Mailgun API by hand means encoding your private key into a Basic auth header and slotting your verified sending domain into each route before a message sends. Through Jentic you install once, import the Mailgun API from the API Directory, store the private key once, and your agent calls it.
- **Permission scoping:** Mailgun puts the sending domain in the URL path (/{domain}/messages), so a rule can pin your agent to one domain: it can send and retrieve stored messages for that domain and nothing else. You choose the operations it may call, so it sends only from the domain and endpoints you allow.
- **Credential handling:** Your Mailgun private 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 a transactional email', and Jentic returns the Mailgun POST /{domain}/messages operation with its parameter schema so the agent calls the right endpoint against the verified sending domain without reading the reference docs.

## Related APIs

- **SendGrid** — Transactional and marketing email delivery with templates and analytics
- **Brevo** — Transactional email plus SMS and CRM in one platform
- **Twilio** — SMS, voice, and messaging APIs

## FAQ

### What authentication does the Mailgun API use?

Mailgun uses HTTP Basic authentication. You pass the literal string 'API' as the username and your Mailgun private API key as the password. Through Jentic, the key is stored encrypted in the vault and applied at execution time so the agent runtime never holds it.

### Can I send a transactional email with the Mailgun API?

Yes. POST /{domain}/messages accepts from, to, subject, and text or html body fields and queues the message for delivery from your verified sending domain. The response contains the Mailgun message id you can store for later retrieval.

### What are the rate limits for the Mailgun API?

Limits depend on your Mailgun plan and the reputation of your sending domain rather than a single per-second cap declared in the spec. Apply exponential backoff on 429 responses and respect the per-domain hourly limits visible in the Mailgun control panel.

### How do I send an email with the Mailgun API through Jentic?

Run pip install jentic and search for 'send a transactional email'. Jentic returns the Mailgun POST /{domain}/messages operation with its parameter schema. Execute it with from, to, subject, and body; Jentic injects the Basic auth credential automatically.

### Can I retrieve a previously sent message?

Yes. GET /{domain}/messages/{messageId} fetches the stored message body and headers for a given Mailgun message id. This supports audit, replay, and customer support flows without keeping a separate copy of the email content.

### Does the Mailgun API support multiple recipients?

Yes. POST /{domain}/messages accepts a comma-separated list in the to field and supports cc and bcc. For larger sends, batch through Mailgun recipient variables to keep each request within Mailgun's recipient limits.

### Can I limit what my agent is allowed to do with the Mailgun API?

Yes. Because you run Jentic One yourself, your own rules decide which Mailgun operations and credentials the agent may use. Since Mailgun puts the sending domain in the URL path (/{domain}/messages), you can pin the agent to a single verified domain and grant only the operations you choose, such as sending via POST /{domain}/messages while withholding message retrieval, or the reverse. Anything you do not allow stays off limits to the agent.
