Mailgun API defined by OpenAPI Specification (OAS) 3.1.0
Mailgun API (3.0.0)
Request
List domain keys, and optionally filter by signing domain or selector. Results are paginated - use the 'limit' parameter to control page size (default 10, max 100). Use the 'page' parameter from the paging response URLs to navigate through pages.
- US Mailgunhttps://api.mailgun.net/v1/dkim/keys
- EU Mailgunhttps://api.eu.mailgun.net/v1/dkim/keys
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X GET \
-u <username>:<password> \
https://api.mailgun.net/v1/dkim/keys \
-H 'Content-Type: multipart/form-data' \
-F page=string \
-F limit=0 \
-F signing_domain=string \
-F selector=string{ "items": [ { … }, { … } ], "paging": { "previous": "/v1/dkim/keys?page=<previous_page_token>", "first": "/v1/dkim/keys", "next": "/v1/dkim/keys?page=<encoded_page_token>", "last": "/v1/dkim/keys?page=<last_page_token>" } }
Request
Create a domain key. Note that once private keys are created or imported they are never exported. Alternatively, you can import an existing PEM file containing a RSA private key in PKCS #1, ASn.1 DER format. Note, the pem can be passed as a file attachment or as a form-string parameter.
- US Mailgunhttps://api.mailgun.net/v1/dkim/keys
- EU Mailgunhttps://api.eu.mailgun.net/v1/dkim/keys
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X POST \
-u <username>:<password> \
https://api.mailgun.net/v1/dkim/keys \
-H 'Content-Type: multipart/form-data' \
-F signing_domain=string \
-F selector=string \
-F bits=0 \
-F pem=string{ "signing_domain": "example.com", "selector": "s1", "dns_record": { "cached": [], "name": "s1._domainkey.example.com", "record_type": "TXT", "valid": "unknown", "value": "k=rsa; p=<public_key>" } }
- US Mailgunhttps://api.mailgun.net/v1/dkim/keys
- EU Mailgunhttps://api.eu.mailgun.net/v1/dkim/keys
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
-u <username>:<password> \
'https://api.mailgun.net/v1/dkim/keys?signing_domain=string&selector=string'{ "message": "success" }
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.
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.
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.
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.
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 - 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.
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