Bouncewise

Bouncewise › Guides › Mailgun EU region API: US vs EU endpoints and errors

Mailgun guide

Mailgun US vs EU region: endpoints, and the errors you get on the wrong one

Updated · 3 min read

Short answer

Each Mailgun domain lives in one region, chosen when you add it, and every API call for it must go to that region's host: https://api.mailgun.net for US domains, https://api.eu.mailgun.net for EU domains (and https://api.au.mailgun.net for AU, contract only). API keys are global for US and EU, so the wrong host doesn't reject your key. It behaves as if the domain doesn't exist, typically a 404 with "Domain not found". A domain's region can't be changed; you recreate it in the other region.

Endpoints by region

ServiceUSEUAU (contract only)
REST APIapi.mailgun.netapi.eu.mailgun.netapi.au.mailgun.net
Outgoing SMTPsmtp.mailgun.orgsmtp.eu.mailgun.orgsmtp.au.mailgun.org
Inbound MXmxa.mailgun.org, mxb.mailgun.orgmxa.eu.mailgun.org, mxb.eu.mailgun.orgmxa.au.mailgun.org, mxb.au.mailgun.org
Open/click tracking CNAMEmailgun.orgeu.mailgun.orgau.mailgun.org
Control panelapp.mailgun.comapp.eu.mailgun.com

The paths are the same in every region; only the host changes. Switching a client to the EU means changing https://api.mailgun.net/v3/mg.example.com/messages to https://api.eu.mailgun.net/v3/mg.example.com/messages, and the SMTP host to match.

Connect screen for Mailgun showing domains found in both the US and EU regions from one API key
One key, domains from both regions.

What is global and what stays in one region

Global (one account)Region-bound (US / EU / AU)
Account metadata, users, billing, API keys (except AU)Sending domains and their SMTP credentials, messages (MIME), event logs, metrics, suppressions, mailing lists, tags, routes, IP addresses

Mailgun says message data never leaves the region in which it is processed. That is why a domain can't simply be moved: its logs, suppressions and stored messages stay where they are.

Symptoms of calling the wrong region

What you seeWhat it means
404 with {"message": "Domain not found"} from /v4/domains/mg.example.com or another domain endpointThat host has no such domain. Check its region (or the spelling, such as example.com instead of mg.example.com).
GET /v4/domains lists some of your domains but not othersEach host only lists its own region's domains. Query both.
Logs, metrics or suppressions come back without the domain's dataThat data lives on the other region's host.
401 with Invalid private key (or Forbidden on sending)Not a US/EU region problem: the key is wrong, deleted or lacks access. Keys work in both US and EU; AU keys are the exception.

Find a domain's region

The quickest check is to ask both hosts. The domain appears on exactly one of them, because a domain name is unique across Mailgun and can't exist in both regions.

curl -s --user "api:$MAILGUN_API_KEY" \
  https://api.mailgun.net/v4/domains/mg.example.com

curl -s --user "api:$MAILGUN_API_KEY" \
  https://api.eu.mailgun.net/v4/domains/mg.example.com

The one that answers 200 with the domain's details is its region. In the control panel, the region is shown when you open the domain, and EU accounts sign in at app.eu.mailgun.com.

Moving a domain to the other region

Mailgun can't change a domain's region after it is created; its help centre gives possible GDPR implications as the reason. AU, for completeness, is available on contract only and for Mailgun Send only. To move between US and EU you have two options:

  1. Add a new subdomain in the target region (for example eu.mg.example.com) and move sending over gradually. Nothing is deleted, so there is no gap.
  2. Delete the domain and add it again in the other region. Deleted data can't be recovered, so first export suppressions (Bounces, Complaints, Unsubscribes each have an Export button) and mailing lists, and note your Routes, webhooks and SMTP credentials, which you recreate by hand.

Either way you publish the new region's DNS records (EU MX and tracking values differ; see Mailgun domain verification), and point your code at the new API and SMTP hosts. Dedicated IPs are region-bound too: an EU domain needs an EU dedicated IP.

Questions

Does a Mailgun API key work in both the US and EU regions?

Yes. API keys are global across US and EU, so one key can manage domains in both. AU is the exception.

Can the same domain exist in both regions?

No. Domain names are unique across Mailgun, so the same domain can only be in one region at a time.

Can I switch a Mailgun domain from US to EU?

Not in place. Either add a new subdomain in the EU region or delete the domain and recreate it there, exporting suppressions and lists first.

Where is EU Mailgun data stored?

Message data stays in the region where it is processed. Only account-level data such as users, billing and API keys is replicated globally.

Sources