Skip to content
Last updated

API Overview

Base URL

All API calls referenced in our documentation start with a base URL. Mailgun allows the ability to send and receive email in both US and EU regions. Be sure to use the appropriate base URL based on which region you have created for your domain.

It is also important to note that Mailgun uses URI versioning for our API endpoints, and some endpoints may have different versions than others. Please reference the version stated in the URL for each endpoint.

For domains created in our US region the base URL is:

https://api.mailgun.net/

For domains created in our EU region the base URL is:

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

Date Format

Mailgun returns JSON for all API calls. JSON does not have a built-in date type; dates are passed as strings encoded according to RFC-2822. This format is native to JavaScript and is also supported by most programming languages out of the box

'Thu, 13 Oct 2011 18:02:00 +0000'
Warning!

Abbreviated time zones like (EST, CET, IST, HLC) may not result in the correct offset due to ambiguous nature. Use numerical offset (+0500) or GMT/UTC instead.

API Response Codes

All of Mailgun's HTTP response codes follow standard HTTP definitions.

CodeDescriptionTroubleshooting
400Bad RequestResponse typically contains a JSON "message" key with human-readable error details
401UnauthorizedInvalid or missing API key. Check that your API key is correct and properly formatted in the Authorization header
403ForbiddenValid credentials but access denied. Ensure you have permissions for the requested resource
404Not FoundResource not found. May be temporal due to eventually-consistent system. Missing JSON response usually indicates incorrect endpoint
429Rate LimitedRate limits exceeded. Retry as defined in response headers. Contact support if limits need adjustment
500Internal ErrorMailgun server error. Retry with exponential backoff. Contact support if issue persists

Mailgun Regions

Using a single account and billing plan, you can choose to provision new sending domains in the EU environment. It is important to note that message data never leaves the region in which it is processed. Only a limited amount of account data is replicated globally, giving you a single account from which to manage domains in both the US and the EU.

Here are the specifics on the type of data that is replicated globally versus what is region-bound:

GlobalRegion-Bound (US / EU)
Account Information, User Accounts, Billing Details (invoices/plan information), API Keys, Domain NamesDomain Metadata (e.g., SMTP credentials), Messages, Event Logs, Suppressions, Mailing Lists, Tags, Statistics, Routes, IP Addresses

Below are the endpoints you will use for sending/receiving/tracking messages in the EU:

ServiceUS EndpointEU Endpoint
REST APIapi.mailgun.netapi.eu.mailgun.net
Outgoing SMTP Serversmtp.mailgun.orgsmtp.eu.mailgun.org
Inbound SMTP Server (Routes)mxa.mailgun.orgmxa.eu.mailgun.org
Inbound SMTP Server (Routes)mxb.mailgun.orgmxb.eu.mailgun.org
Open/Click Tracking Endpointmailgun.orgeu.mailgun.org