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

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

Delete the DIPP

Request

The DIPPs feature must be enabled for the account.

It is not allowed to delete a DIPP inherited from the parent account.

If the DIPP is delegated to subaccounts, those will also be updated.

If the replacement DIPP is specified, all domains linked to the deleted DIPP will be relinked to the replacement DIPP. The latter must contain at least one IP.

If the replacement IP is specified, all domains linked to the deleted DIPP will be unlinked, and the replacement IP will be assigned to them. It is not allowed to delete a DIPP inherited from the parent account and replace it with an IP (subaccounts do not explicitly manage their IPs).

The replacement IP must be a dedicated one; it can't belong to another DIPP. If a special value shared is used, appropriate shared IPs will be used (the account must be eligible for shared IPs in this case).

Omitting both replacement DIPP and replacement IP is allowed only if the DIPP being deleted contains no IPs.

The processing of affected domains and subaccounts happens asynchronously after the endpoint returns a response.

Security
basicAuth
Path
pool_idstringrequired

Id of the DIPP to delete

Query
ipstringrequired

Replacement IP or a special value shared

pool_idstringrequired

Id of the replacement DIPP

Headers
X-Mailgun-Account-Idstringrequired

Account ID

X-Mailgun-Requestorstringrequired

Email address of the user making the request.

X-Mailgun-Requestor-Clientstringrequired

Identifier of the client application making the request.

curl -i -X DELETE \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/ip_pools/{pool_id}?ip=string&pool_id=string' \
  -H 'X-Mailgun-Account-Id: string' \
  -H 'X-Mailgun-Requestor: string' \
  -H 'X-Mailgun-Requestor-Client: string'

Responses

A 200 response

Bodyapplication/json
string(string)
Response
application/json
{ "allowed": { "dedicated": 1, "shared": 2 } }

Edit DIPP

Request

The account must have 'DIPPs' feature enabled.

It's not allowed to edit a DIPP inherited from the parent account.

IPs being added to the DIPP must be dedicated ones and belong to the account.

If IPs of the DIPP end up modified, and the DIPP is linked to domains, the domains will be updated asynchronously (after this endpoint returns response).

Returns an error if the passed parameters won't result in any changes.

Security
basicAuth
Path
pool_idstringrequired

Id of the DIPP to edit

Headers
X-Mailgun-Account-Idstringrequired

Account ID

X-Mailgun-Requestorstringrequired

Email address of the user making the request.

X-Mailgun-Requestor-Clientstringrequired

Identifier of the client application making the request.

Bodymultipart/form-datarequired
add_ipstring

The IP to add to the DIPP (may be specified multiple times)

descriptionstring

The new description for the DIPP

link_domainstring

The ID of the domain link to the DIPP (may be specified multiple times)

namestring

The new short for the DIPP

remove_ipstring

The IP to remove from the DIPP (may be specified multiple times)

unlink_domainstring

The ID of the domain to unlink from the DIPP (may be specified multiple times)

curl -i -X PATCH \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/ip_pools/{pool_id}' \
  -H 'Content-Type: multipart/form-data' \
  -H 'X-Mailgun-Account-Id: string' \
  -H 'X-Mailgun-Requestor: string' \
  -H 'X-Mailgun-Requestor-Client: string' \
  -F add_ip=string \
  -F description=string \
  -F link_domain=string \
  -F name=string \
  -F remove_ip=string \
  -F unlink_domain=string

Responses

A 200 response

Bodyapplication/json
string(string)
Response
application/json
{ "message": "success" }

Get domains linked to DIPP

Request

Returns a paginated list of domains that are linked to the specified dedicated IP pool.

Security
basicAuth
Path
pool_idstringrequired

Id of the DIPP to get details about

Query
limitinteger[ 10 .. 500 ]

The maximum number of records to return

Default 10
pagestring

Encoded page identifier retrieved from previous call

Headers
X-Mailgun-Account-Idstringrequired

Account ID

curl -i -X GET \
  -u <username>:<password> \
  'https://api.mailgun.net/v3/ip_pools/{pool_id}/domains?limit=10&page=string' \
  -H 'X-Mailgun-Account-Id: string'

Responses

A 200 response

Bodyapplication/json
string(string)
Response
application/json
{ "domains": [ {}, {} ], "paging": { "next": "http://api.mailgun.net/v3/ip_pools/686e71e8fcafa435bdb5be5f/domains?page=eyJj...", "first": "http://api.mailgun.net/v3/ip_pools/686e71e8fcafa435bdb5be5f/domains?page=eyJj..." } }

Dynamic IP Pools

Dynamic IP Pools allow you to group your dedicated IPs into customized "pools" based on sender reputation. Domains enrolled in Dynamic IP Pools will be assigned to a pool based on the result of periodic health checks.

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