Skip to content

Mailgun API (0.0.0)

Mailgun API defined by OpenAPI Specification (OAS) 3.1.0

Download OpenAPI description
Languages
Servers
Mock server

https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/

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

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

List Mailgun API keys

Request

List Mailgun API keys

Security
basicAuth
Query
domain_namestring

Domain name filter for domain keys

kindstring

Key kind filter

Enum ValueDescription
domain

Filter for domain keys

user

Filter for user keys

web

Filter for web keys

curl -i -X GET \
  -u <username>:<password> \
  'https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/v1/keys?domain_name=string&kind=domain'

Responses

A 200 response

Bodyapplication/json
itemsArray of objects(github.com-mailgun-cerberus-keys-KeyInfoResp)required
items[].​idstringrequired

The ID for the key

items[].​descriptionstringrequired

The description provided for the key upon its creation

items[].​kindstringrequired

The type of the key which determines how it can be used

items[].​rolestringrequired

The role of the key which determines its scope in CRUD operations that have role-based access control

items[].​created_atstringrequired

When the key was created

items[].​updated_atstringrequired

When the key was last updated

items[].​expires_atstring

When the key will expire

items[].​secretstring

The full api key secret in plain text

items[].​disabled_reasonstring

The reason for the key's disablement

items[].​is_disabledbooleanrequired

Whether or not the key is disabled from use

items[].​domain_namestring or nullrequired

The sending domain associated with the key

items[].​requestorstring or nullrequired

An email address associated with the key

items[].​user_namestring or nullrequired

The api key user's name

total_countinteger(int32)required

The number of keys returned in 'items'

Response
application/json
{ "items": [ {} ], "total_count": 1 }

Create Mailgun API key

Request

Create Mailgun API key

Security
basicAuth
Bodymultipart/form-datarequired
emailstring

API Key user's email address; should be provided for all keys of 'web' kind

domain_namestring

Web domain to associate with the key, for keys of 'domain' kind

kindstring

Type of api key ('domain', 'user', or 'web'). Defaults to 'user' if not provided. Note: web keys are not subject to IP whitelisting and have a default/maximum validity period of 1 day.

Enum ValueDescription
domain

Create api key of type 'domain'

user

Create api key of type 'user'

web

Create api key of type 'web'

expirationinteger

Key lifetime in seconds, must be greater than 0 if set

rolestringrequired

Key role ('admin', 'basic' [use in place of analyst], 'sending' [use with keys of domain kind], 'support', or 'developer')

user_idstring

API Key user's string user ID; should be provided for all keys of 'web' kind

user_namestring

API Key user's name

descriptionstring

Key description

curl -i -X POST \
  -u <username>:<password> \
  https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/v1/keys \
  -H 'Content-Type: multipart/form-data' \
  -F email=string \
  -F domain_name=string \
  -F kind=domain \
  -F expiration=0 \
  -F role=string \
  -F user_id=string \
  -F user_name=string \
  -F description=string

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Response message

keyobject(github.com-mailgun-cerberus-keys-KeyInfoResp)required
key.​idstringrequired

The ID for the key

key.​descriptionstringrequired

The description provided for the key upon its creation

key.​kindstringrequired

The type of the key which determines how it can be used

key.​rolestringrequired

The role of the key which determines its scope in CRUD operations that have role-based access control

key.​created_atstringrequired

When the key was created

key.​updated_atstringrequired

When the key was last updated

key.​expires_atstring

When the key will expire

key.​secretstring

The full api key secret in plain text

key.​disabled_reasonstring

The reason for the key's disablement

key.​is_disabledbooleanrequired

Whether or not the key is disabled from use

key.​domain_namestring or nullrequired

The sending domain associated with the key

key.​requestorstring or nullrequired

An email address associated with the key

key.​user_namestring or nullrequired

The api key user's name

Response
application/json
{ "key": { "description": "api key", "kind": "domain", "role": "sending", "created_at": "2006-01-02T15:04:05", "updated_at": "2006-01-02T15:04:05", "domain_name": "example.com", "id": "f2153fd0-f1277777", "user_name": null, "requestor": null, "is_disabled": false }, "message": "great success" }

Delete Mailgun API key

Request

Delete Mailgun API key

Security
basicAuth
Path
key_idstringrequired

The Key ID generated by Mailgun on key creation

curl -i -X DELETE \
  -u <username>:<password> \
  'https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/v1/keys/{key_id}'

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Response message

Response
application/json
{ "message": "key deleted" }

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