Mailgun API defined by OpenAPI Specification (OAS) 3.1.0
- List Mailgun API keys
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.
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
- US Mailgun
https://api.mailgun.net/v1/keys
- EU Mailgun
https://api.eu.mailgun.net/v1/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/keys?domain_name=string&kind=domain'A 200 response
The type of the key which determines how it can be used
| Enum Value | Description |
|---|---|
| domain | Domain-specific API key for keys with 'sending' role |
| user | API key tied to a user role for RBAC limitations |
| web | Web session API key generated for user login sessions |
The role of the key which determines its scope in CRUD operations that have role-based access control
| Enum Value | Description |
|---|---|
| admin | Provides admin-level permissions on an API key |
| basic | Provides basic aka analyst-level permissions on an API key |
| sending | Provides domain-scoped permissions on an API key for use only with 'domain' kind key |
| developer | Provides developer-level permissions on an API key |
When the key was created in ISO 8601 date-time format without timezone offset (UTC time)
When the key was last updated in ISO 8601 date-time format without timezone offset (UTC time)
When the key will expire in ISO 8601 date-time format without timezone offset (UTC time)
The sending domain associated with the key required for 'domain' kind keys
The sending domain associated with the key required for 'domain' kind keys
An email address associated with the key
An email address associated with the key
{ "total_count": 1, "items": [ { … } ] }
Type of API key ('domain', 'user', or 'web'). Defaults to 'user' if not provided. Note: web keys are not subject to IP allowlisting and have a default/maximum validity period of 1 day.
| Enum Value | Description |
|---|---|
| domain | Create API key of type 'domain' |
| user | Create API key of type 'user' |
| web | Create API key of type 'web' |
Key role ('admin', 'basic' [use in place of analyst], 'sending' [use with keys of domain kind], or 'developer')
| Enum Value | Description |
|---|---|
| admin | Provides admin-level permissions on an API key |
| basic | Provides basic aka analyst-level permissions on an API key |
| sending | Provides domain-scoped permissions on an API key for use only with 'domain' kind key |
| developer | Provides developer-level permissions on an API key |
- US Mailgun
https://api.mailgun.net/v1/keys
- EU Mailgun
https://api.eu.mailgun.net/v1/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/keys \
-H 'Content-Type: multipart/form-data' \
-F domain_name=string \
-F kind=domain \
-F description=string \
-F expiration=0 \
-F role=admin \
-F user_id=string \
-F user_name=string \
-F email=stringA 200 response
The type of the key which determines how it can be used
| Enum Value | Description |
|---|---|
| domain | Domain-specific API key for keys with 'sending' role |
| user | API key tied to a user role for RBAC limitations |
| web | Web session API key generated for user login sessions |
The role of the key which determines its scope in CRUD operations that have role-based access control
| Enum Value | Description |
|---|---|
| admin | Provides admin-level permissions on an API key |
| basic | Provides basic aka analyst-level permissions on an API key |
| sending | Provides domain-scoped permissions on an API key for use only with 'domain' kind key |
| developer | Provides developer-level permissions on an API key |
When the key was created in ISO 8601 date-time format without timezone offset (UTC time)
When the key was last updated in ISO 8601 date-time format without timezone offset (UTC time)
When the key will expire in ISO 8601 date-time format without timezone offset (UTC time)
The sending domain associated with the key required for 'domain' kind keys
The sending domain associated with the key required for 'domain' kind keys
An email address associated with the key
An email address associated with the key
{ "message": "great success", "key": { "id": "f2153fd0-f1277777", "description": "api key", "kind": "domain", "role": "sending", "created_at": "2006-01-02T15:04:05", "updated_at": "2006-01-02T15:04:05", "requestor": null, "user_name": null, "domain_name": "example.com", "is_disabled": false, "secret": "api-key-be-careful" } }
- US Mailgun
https://api.mailgun.net/v1/keys/{key_id}
- EU Mailgun
https://api.eu.mailgun.net/v1/keys/{key_id}
- curl
- JavaScript
- Node.js
- Python
- Java
- C#
- PHP
- Go
- Ruby
- R
- Payload
curl -i -X DELETE \
-u <username>:<password> \
'https://api.mailgun.net/v1/keys/{key_id}'{ "message": "key deleted" }