Mailgun API defined by OpenAPI Specification (OAS) 3.1.0
Mailgun API (3.0.0)
https://api.mailgun.net/
https://api.eu.mailgun.net/
Domain Tracking
Mailgun offers tracking for clicks, unsubscribes, and opens, with optional HTTPS protocol support on tracking URLs. To enable HTTPS, Mailgun uses Let’s Encrypt with HTTP-01 challenges through your existing tracking CNAME record to issue a TLS certificate. This setup also includes support for HTTP Strict Transport Security (HSTS) for enhanced security.
Account Webhooks
Webhooks API to manage account-specific webhooks. You can create, retrieve, update, and delete webhooks programmatically. Account-level webhooks are configured independently for US and EU regions. When triggered, webhook URLs are deduplicated by event type, across account and domain levels to prevent redundant webhook sends.
The name of the webhook to delete.
| Enum Value | Description |
|---|---|
| accepted | The accepted event occurs when Mailgun accepts a message for delivery. |
| clicked | The clicked event occurs when a recipient clicks a link in the email. This requires click tracking to be enabled for the domain. |
| opened | The opened event occurs when a recipient opens the email. This requires open tracking to be enabled for the domain. |
| unsubscribed | The unsubscribed event occurs when a recipient unsubscribes using an unsubscribe mechanism in your email (for example, a list-unsubscribe link). |
| delivered | The delivered event occurs when an email is successfully delivered to the recipient's mail server. |
| permanent_fail | The permanent_fail event occurs when an email cannot be delivered due to a permanent error. |
| temporary_fail | The temporary_fail event occurs when an email cannot be delivered due to a temporary error. |
| complained | The complained event occurs when a recipient marks your email as spam or their email provider registers a spam complaint. |
- US Mailgun
https://api.mailgun.net/v3/domains/{domain_name}/webhooks/{webhook_name}
- EU Mailgun
https://api.eu.mailgun.net/v3/domains/{domain_name}/webhooks/{webhook_name}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
-u <username>:<password> \
'https://api.mailgun.net/v3/domains/{domain_name}/webhooks/{webhook_name}'{ "message": "Webhook has been deleted", "webhook": { "urls": [ … ] } }
Event types to associate with this URL. Use multiple times to specify multiple event types. This replaces the existing associations.
| Enum Value | Description |
|---|---|
| accepted | The accepted event occurs when Mailgun accepts a message for delivery. |
| clicked | The clicked event occurs when a recipient clicks a link in the email. This requires click tracking to be enabled for the domain. |
| opened | The opened event occurs when a recipient opens the email. This requires open tracking to be enabled for the domain. |
| unsubscribed | The unsubscribed event occurs when a recipient unsubscribes using an unsubscribe mechanism in your email (for example, a list-unsubscribe link). |
| delivered | The delivered event occurs when an email is successfully delivered to the recipient's mail server. |
| permanent_fail | The permanent_fail event occurs when an email cannot be delivered due to a permanent error. |
| temporary_fail | The temporary_fail event occurs when an email cannot be delivered due to a temporary error. |
| complained | The complained event occurs when a recipient marks your email as spam or their email provider registers a spam complaint. |
- US Mailgun
https://api.mailgun.net/v4/domains/{domain}/webhooks
- EU Mailgun
https://api.eu.mailgun.net/v4/domains/{domain}/webhooks
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X PUT \
-u <username>:<password> \
'https://api.mailgun.net/v4/domains/{domain}/webhooks' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d url=string \
-d event_types=acceptedA 200 response
List of webhooks
Accepted webhook URLs
Accepted webhook URLs
Delivered webhook URLs
Delivered webhook URLs
Opened webhook URLs
Opened webhook URLs
Clicked webhook URLs
Clicked webhook URLs
Unsubscribed webhook URLs
Unsubscribed webhook URLs
Complained webhook URLs
Complained webhook URLs
Temporary fail webhook URLs
Temporary fail webhook URLs
{ "webhooks": { "delivered": { … }, "opened": { … }, "clicked": { … } } }
Event types. Use multiple times to specify multiple event types.
| Enum Value | Description |
|---|---|
| accepted | The accepted event occurs when Mailgun accepts a message for delivery. |
| clicked | The clicked event occurs when a recipient clicks a link in the email. This requires click tracking to be enabled for the domain. |
| opened | The opened event occurs when a recipient opens the email. This requires open tracking to be enabled for the domain. |
| unsubscribed | The unsubscribed event occurs when a recipient unsubscribes using an unsubscribe mechanism in your email (for example, a list-unsubscribe link). |
| delivered | The delivered event occurs when an email is successfully delivered to the recipient's mail server. |
| permanent_fail | The permanent_fail event occurs when an email cannot be delivered due to a permanent error. |
| temporary_fail | The temporary_fail event occurs when an email cannot be delivered due to a temporary error. |
| complained | The complained event occurs when a recipient marks your email as spam or their email provider registers a spam complaint. |
- US Mailgun
https://api.mailgun.net/v4/domains/{domain}/webhooks
- EU Mailgun
https://api.eu.mailgun.net/v4/domains/{domain}/webhooks
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
-u <username>:<password> \
'https://api.mailgun.net/v4/domains/{domain}/webhooks' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d url=string \
-d event_types=acceptedA 200 response
List of webhooks
Accepted webhook URLs
Accepted webhook URLs
Delivered webhook URLs
Delivered webhook URLs
Opened webhook URLs
Opened webhook URLs
Clicked webhook URLs
Clicked webhook URLs
Unsubscribed webhook URLs
Unsubscribed webhook URLs
Complained webhook URLs
Complained webhook URLs
Temporary fail webhook URLs
Temporary fail webhook URLs
{ "webhooks": { "accepted": { … }, "delivered": { … }, "clicked": { … }, "permanent_fail": { … } } }
Stats
Mailgun collects many different events and generates event statistics which are available in your Control Panel. This data is also available via our stats API endpoint.
WARNING: This API is deprecated in favor of our Metrics API.
Events
Mailgun keeps track of every inbound and outbound message event and stores this data for at least 3 days.
WARNING: This API is deprecated in favor of our Logs API.
Alerts
Mailgun allows you to get instant notifications on the sending metrics that matter most, configured specifically for your unique business needs and assets. Route these alerts to the channels your team relies on. Stay on top of sending performance without the need to manually monitor.
Bounces
Bounces - Bounce list stores events of delivery failures due to permanent recipient mailbox errors such as non-existent mailbox. Soft bounces (for example, mailbox is full) and other failures (for example, ESP rejects an email because it thinks it is spam) are not added to the list.
Allowlist
The allowlist API provides the ability to allowlist specific addresses from being added to bounce list. You can allowlist by domain name (i.e example.com) or by specific address (i.e. alice@example.com). Mailgun doesn’t add an address to bounce list if the address is allowlisted. This API is very useful if you test against your private services and don’t want to constantly clean up bounce lists