Skip to content

Mailgun API (0.0.0)

Mailgun API defined by OpenAPI Specification (OAS) 3.1.0

Download OpenAPI description
Languages
Servers
US Mailgun

https://api.mailgun.net/

EU Mailgun

https://api.eu.mailgun.net/

Messages

Send email two ways via our REST API:

  1. Send emails using MIME format using a MIME building library
  2. Submit the individual parts (Text, html, attachments, etc.)

Reminder: You can also send email via SMTP with Mailgun. Please reference the user manual.

Operations

Domains

Domains API manages domains, domain keys and DNS verification.

Operations

Domain Keys

An authentication standard used to prevent email spoofing.

Operations

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.

Operations

Get tracking settings

Request

Use to check if open, click and unsubscribe tracking are active/inactive.

Security
basicAuth
Path
namestringrequired

The name of the domain to fetch tracking details for.

curl -i -X GET \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/domains/{name}/tracking'

Responses

A 200 response

Bodyapplication/json
trackingobject(github.com-mailgun-domains-httpapi-trackingSettings)required
tracking.​openobjectrequired

Open tracking settings

tracking.​open.​activebooleanrequired

Whether open tracking is enabled or not

tracking.​open.​place_at_the_topbooleanrequired

If the pixel should be placed at the top of the email

tracking.​clickobjectrequired

Click tracking settings

tracking.​click.​activebooleanrequired

Whether click tracking is enabled or not

tracking.​unsubscribeobjectrequired

Unsubscribe tracking settings

tracking.​unsubscribe.​activebooleanrequired

Whether unsubscribe tracking is enabled or not

tracking.​unsubscribe.​html_footerstringrequired

The HTML footer for the unsubscribe link

tracking.​unsubscribe.​text_footerstringrequired

The text footer for the unsubscribe link

tracking.​web_schemestringrequired

The web scheme for the domain

Response
application/json
{ "tracking": { "open": {}, "click": {}, "unsubscribe": {}, "web_scheme": "http" } }

Update click tracking settings

Request

Use to turn on/off the click tracking at the domain level.

Security
basicAuth
Path
namestringrequired

The name of the domain you want to update

Bodymultipart/form-datarequired
activestring

Set param to htmlonly, true, or false. Omit this param to make no change to the active status. Click tracking is consider as active if it's in the 'htmlonly' or 'true' state

curl -i -X PUT \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/domains/{name}/tracking/click' \
  -H 'Content-Type: multipart/form-data' \
  -F active=string

Responses

A 200 response

Bodyapplication/json
messagestringrequired

A message indicating success

clickobjectrequired

Click settings

click.​activebooleanrequired

Whether click tracking is enabled or not

Response
application/json
{ "message": "Domain tracking settings have been updated", "click": { "active": true } }

Update open tracking settings

Request

Use to turn on/off the open tracking at the domain level.

Security
basicAuth
Path
namestringrequired

The name of the domain you want to update

Bodymultipart/form-datarequired
activeboolean

Set this param to true or false to toggle open tracking active status. Omit this param to keep current settings.

place_at_the_topboolean

Setting this param to true will place the open tracking pixel at the top of the HTML body when inserted into the email mime. Omit this param to keep current setting.

curl -i -X PUT \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/domains/{name}/tracking/open' \
  -H 'Content-Type: multipart/form-data' \
  -F active=true \
  -F place_at_the_top=true

Responses

A 200 response

Bodyapplication/json
messagestringrequired

A message indicating success

openobjectrequired

Open settings

open.​activebooleanrequired

Whether open tracking is enabled or not

open.​place_at_the_topbooleanrequired

If the pixel should be placed at the top of the email

Response
application/json
{ "message": "Domain tracking settings have been updated", "open": { "active": true } }

DKIM Security

Automatic Sender Security DKIM Key APIs. To enable this feature please see 'Update a domain' API docs.

Operations

Webhooks

Webhooks API manages domain's webhooks. You can create, access and delete webhooks programmatically.

Operations

Metrics

Mailgun collects many different events and generates event metrics which are available in your Control Panel. This data is also available via our analytics metrics API endpoint.

Operations

Logs

Mailgun keeps track of every inbound and outbound message event and stores this log data. This data can be queried and filtered to provide insights into the health of your email infrastructure.

Operations

Tags New

Mailgun allows you to tag your email with unique identifiers. Tags are visible via our analytics tags API endpoint.

Operations

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.

Operations

Tags

Mailgun lets you tag each outgoing message with a custom value. When you access stats on your messages, they will be aggregated by these tags.

WARNING: This API is deprecated in favor of our new Tags API.

Operations

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.

Operations

Unsubscribe

Unsubscribe list stores email addresses of recipients who unsubscribed from your mailings by clicking a Mailgun generated unsubscribe link.

Operations

Complaints

Email addresses of recipients who marked your messages as a spam (for ESPs that support FBL).

Operations

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.

Operations

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

Operations

Routes

Define a list of routes to handle incoming emails. When a message matches a route expression, Mailgun can forward it on to your application via HTTP or another email address, or store the message temporarily (3 days) for subsequent retrieval.

Operations

Mailing Lists

Programatically create mailing lists.

Operations

Templates

This API allows you to store predefined templates and use them to send messages using the Sending API.

Operations

IP Pools

IP Pools allow you to group your dedicated IPs into customized "pools" to help manage your sending reputation for different mail sending streams.

Operations

Dynamic IP Pools

Dynamic IP Pools allow you to group your dedicated IPs into customized "pools" based on sender reputation. Health checks are performed on domains and assigned to the appropriate Dynamic Pool.

Operations

IPs

The IP API endpoint allows you to access information regarding the IPs allocated to your Mailgun account that are used for outbound sending.

Operations

IP Address Warmup

Operations

Subaccounts

Mailgun supports the creation, modification, and deletion of subaccounts. A subaccount is a child account of a parent account. The parent account can have multiple subaccounts. The subaccounts are created and managed by the parent account.

Operations

Custom Message Limit

The custom message limit imposes a hard limit on how many messages your account can send during a calendar month.

Operations

Account Management

Perform account-level CRUD operations.

Operations

Keys

The Keys API lets you view and manage api keys.

Operations

Credentials

The Credentials API lets you view and manage SMTP credentials.

Operations

IP Allowlist

The IP Allowlist API lets you view and manage allowlisted IP addresses to which api key and SMTP credential usage is restricted.

Operations

Users

Mailgun API supports viewing user entities.

Operations