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

Update domain

Request

Update domain configuration like smtp credentials, enable/disable automatic sender security, spam actions, wildcard, or tracking web scheme.

Security
basicAuth
Path
namestringrequired

The name of the domain you want to update

Bodymultipart/form-datarequired
mailfrom_hoststring

The hostname to update to. Must be in lower case

message_ttlinteger

Specifies the time-to-live (TTL) in seconds for retrieving both incoming and outgoing messages. The maximum TTL value is determined by your subscription plan.

require_tlsboolean

If set to true, this requires messages for the domain only be sent over a TLS connection. If a TLS connection cannot be established, Mailgun will not deliver the message.

If set to false, Mailgun will still try and upgrade the connection, but if Mailgun cannot, the message will be delivered over a plaintext SMTP connection.

The default value is false.

skip_verificationboolean

If set to true, the certificate and hostname will not be verified when trying to establish a TLS connection and Mailgun will accept any certificate during delivery of a message.

If set to false, Mailgun will verify the certificate and hostname. If either one can not be verified, a TLS connection will not be established.

The default value is false.

smtp_passwordstring

Updates the domain's SMTP credentials with the given string

spam_actionstring

Updates the domain's spam action. Valid values are 'disabled', 'tag', and 'block'

use_automatic_sender_securityboolean

Enable or disable Automatic Sender Security. If enabled, requires setting DNS CNAME entries for DKIM keys instead of a TXT record. Domain must be reverified after changing this field. Defaults to false

web_schemestring

Updates your open, click and unsubscribe URLs to use http or https. Value either http or https. Defaults to http. In order for https to work, you must have a valid cert created for your domain. See Domain Tracking for TLS cert generation.

web_prefixstring

This updates the web prefix used for a domain's tracking features. Must be a valid atom. Nothing will be updated if omitted. This impacts click, open, and unsubscribe tracking features.

Note: Updating the web prefix for a domain will require also updating the domain's DNS to include the CNAME record to match. For example, if you set the web prefix to zed for the domain my-domain.com, the corresponding CNAME zed.my-domain.com will need to be created in your domain's dns zone.

wildcardboolean

Updates the domain's wildcard status with the given boolean

curl -i -X PUT \
  -u <username>:<password> \
  'https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/v4/domains/{name}' \
  -H 'Content-Type: multipart/form-data' \
  -F mailfrom_host=string \
  -F message_ttl=0 \
  -F require_tls=true \
  -F skip_verification=true \
  -F smtp_password=string \
  -F spam_action=string \
  -F use_automatic_sender_security=true \
  -F web_scheme=string \
  -F web_prefix=string \
  -F wildcard=true

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Success message

domaingithub.com-mailgun-domains-client-golang-Domain (object) or nullrequired

Domain object

Any of:

Domain object

domain.​created_atstringrequired

Timestamp indicating when the domain was created in RFC1123 format

domain.​idstringrequired

Unique identifier of the domain

domain.​is_disabledbooleanrequired

Indicates whether the domain is currently disabled

domain.​namestringrequired

Fully qualified domain name registered with Mailgun

domain.​require_tlsbooleanrequired

If true Mailgun will only send messages over a TLS connection

domain.​skip_verificationbooleanrequired

If true Mailgun will not verify the certificate and hostname when setting up a TLS connection

domain.​smtp_loginstringrequired

SMTP login username for the domain

domain.​smtp_passwordstring

Optional SMTP password for the domain used for SMTP authentication

domain.​spam_actionstringrequired

Action to take when a message is flagged as spam. Options are disabled

domain.​subaccount_idstring

The subaccount ID the domain belongs to. This field is only present if the domain is associated with a subaccount

domain.​statestringrequired

Current verification status of the domain

domain.​typestringrequired

Classification of the domain. Possible values are custom or sandbox

domain.​tracking_hoststring

Custom tracking host for the domain used for tracking opens and clicks if configured

domain.​use_automatic_sender_securitybooleanrequired

If true Mailgun manages DKIM key generation and DNS record configuration automatically

domain.​web_prefixstringrequired

Subdomain prefix used for open and click tracking

domain.​web_schemestringrequired

Protocol scheme used for tracking

domain.​wildcardbooleanrequired

Indicates if the domain is a wildcard domain and can receive emails for any subdomain

domain.​disabledgithub.com-mailgun-domains-client-golang-Disabled (object) or null

Optional field containing additional details about the domain's disabled status if applicable

Any of:

Optional field containing additional details about the domain's disabled status if applicable

domain.​encrypt_incoming_messagebooleanrequired

If true incoming messages to this domain will be encrypted

domain.​message_ttlinteger(int32)

Specifies the time-to-live (TTL) in seconds for retrieving both incoming and outgoing messages. The maximum TTL value is determined by your subscription plan

receiving_dns_recordsArray of github.com-mailgun-domains-client-golang-Record (object) or null

List of DNS records required for receiving emails

sending_dns_recordsArray of github.com-mailgun-domains-client-golang-Record (object) or null

List of DNS records required for sending emails

Response
application/json
{ "domain": { "created_at": "Thu, 13 Oct 2011 18:02:00 GMT", "id": "123456789012345678901234", "name": "example.com", "require_tls": true, "smtp_login": "postmaster@example.com", "spam_action": "disabled", "state": "active", "type": "sandbox", "use_automatic_sender_security": true, "web_prefix": "email", "web_scheme": "http" }, "receiving_dns_records": [ {} ], "sending_dns_records": [ {} ] }

Verify Domain

Request

Verify the domains DNS records (includes A, CNAME, SPF, DKIM and MX records) to ensure the domain is ready and able to send

Security
basicAuth
Path
namestringrequired

The name of the domain you want to verify

curl -i -X PUT \
  -u <username>:<password> \
  'https://documentation.mailgun.com/_mock/docs/mailgun/api-reference/openapi-final/v4/domains/{name}/verify'

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Response message

domaingithub.com-mailgun-domains-client-golang-Domain (object) or nullrequired

Domain record information

Any of:

Domain record information

domain.​created_atstringrequired

Timestamp indicating when the domain was created in RFC1123 format

domain.​idstringrequired

Unique identifier of the domain

domain.​is_disabledbooleanrequired

Indicates whether the domain is currently disabled

domain.​namestringrequired

Fully qualified domain name registered with Mailgun

domain.​require_tlsbooleanrequired

If true Mailgun will only send messages over a TLS connection

domain.​skip_verificationbooleanrequired

If true Mailgun will not verify the certificate and hostname when setting up a TLS connection

domain.​smtp_loginstringrequired

SMTP login username for the domain

domain.​smtp_passwordstring

Optional SMTP password for the domain used for SMTP authentication

domain.​spam_actionstringrequired

Action to take when a message is flagged as spam. Options are disabled

domain.​subaccount_idstring

The subaccount ID the domain belongs to. This field is only present if the domain is associated with a subaccount

domain.​statestringrequired

Current verification status of the domain

domain.​typestringrequired

Classification of the domain. Possible values are custom or sandbox

domain.​tracking_hoststring

Custom tracking host for the domain used for tracking opens and clicks if configured

domain.​use_automatic_sender_securitybooleanrequired

If true Mailgun manages DKIM key generation and DNS record configuration automatically

domain.​web_prefixstringrequired

Subdomain prefix used for open and click tracking

domain.​web_schemestringrequired

Protocol scheme used for tracking

domain.​wildcardbooleanrequired

Indicates if the domain is a wildcard domain and can receive emails for any subdomain

domain.​disabledgithub.com-mailgun-domains-client-golang-Disabled (object) or null

Optional field containing additional details about the domain's disabled status if applicable

Any of:

Optional field containing additional details about the domain's disabled status if applicable

domain.​encrypt_incoming_messagebooleanrequired

If true incoming messages to this domain will be encrypted

domain.​message_ttlinteger(int32)

Specifies the time-to-live (TTL) in seconds for retrieving both incoming and outgoing messages. The maximum TTL value is determined by your subscription plan

sending_dns_recordsArray of github.com-mailgun-domains-client-golang-Record (object) or nullrequired

List of DNS records required for sending emails

Any of:
sending_dns_records[].​is_activebooleanrequired

Indicates whether the DNS record is currently active

sending_dns_records[].​cachedArray of stringsrequired

List of Mailguns cached values for the DNS record

sending_dns_records[].​namestring

Name of the DNS record if applicable

sending_dns_records[].​prioritystring

Priority value for MX DNS records

sending_dns_records[].​record_typestringrequired

Type of DNS record such as MX TXT or CNAME

sending_dns_records[].​validstringrequired

Indicates whether the DNS record is valid

sending_dns_records[].​valuestringrequired

Expected value of the DNS record

receiving_dns_recordsArray of github.com-mailgun-domains-client-golang-Record (object) or nullrequired

List of DNS records required for receiving emails

Any of:
receiving_dns_records[].​is_activebooleanrequired

Indicates whether the DNS record is currently active

receiving_dns_records[].​cachedArray of stringsrequired

List of Mailguns cached values for the DNS record

receiving_dns_records[].​namestring

Name of the DNS record if applicable

receiving_dns_records[].​prioritystring

Priority value for MX DNS records

receiving_dns_records[].​record_typestringrequired

Type of DNS record such as MX TXT or CNAME

receiving_dns_records[].​validstringrequired

Indicates whether the DNS record is valid

receiving_dns_records[].​valuestringrequired

Expected value of the DNS record

Response
application/json
{ "message": "Domain DNS records have been updated", "domain": { "created_at": "Mon, 02 Jan 2006 15:04:05 MST", "id": "123456789012345678901234", "name": "example.com", "require_tls": true, "smtp_login": "postmaster@example.com", "spam_action": "disabled", "state": "unverified", "type": "sandbox", "use_automatic_sender_security": true, "web_prefix": "email", "web_scheme": "http", "disabled": {} }, "sending_dns_records": [ {} ], "receiving_dns_records": [ {} ] }

Delete a domain

Request

The domain must not be disabled or used as an authority for an other domain. Sandbox domain can't be deleted.

Security
basicAuth
Path
namestringrequired

The name of the domain to delete

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

Responses

A 200 response

Bodyapplication/json
messagestringrequired

Response message

Response
application/json
{ "message": "Domain will be deleted in the background" }

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

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