Mailgun secret API key rejected

Hi everyone,

I tried to set up Mailgun bounce handling today and therefore wanted to configure the secret Mailgun API key. But I can’t save the key and only get this error message:

Value doesn’t match the required format.

Have they changed their format maybe? My key is “key-” followed by 32 lower-case alpha-numeric characters.

The regex looks fine to me:

And I can’t repro the issue locally using a random key like: key-a64b3021781d9467b6c7e9da7741fed0

1 Like

The RegEx matches hex values, but my Mailgun key looks more like


Haven’t tested this regex, just off the top of my head :wink:

Correction: Just saw that my API key even includes dashes (-).

Strange. I just opened a ticket on Mailgun asking if the API key format has changed.

Edit: And I heard back from them. It’s still the same. @lunikon, my best guess is that you’re using an SMTP password rather than an API key. You can look at my install FAQ for how to find the API key.


I am definitely using an API key, from the exact location described in your install FAQ. I guess I’ll have to contact Mailgun myself and figure out what went wrong there. Maybe there was a bug on their side when my set of keys was generated.

1 Like

I am unable to repro with an actual key from mailgun, feel free to PM me your key if you want me to test it.


I am also seeing this issue on a new install.

ETA: 1.9.0.beta6

And you’re sure that you’re using an API key and not a password?


Very very quite certain :slight_smile:

I’m having the same problem with v2.0.0.beta3. My Mailgun API key also has dashes in it, I assume the regex just doesn’t match. (And yes, I’m definitely using the correct secret key, not a password.)

Nene generate another key?

So apparently this problem does exist for several people over a longer time-span. Wouldn’t it be easier to just make the regex in Discourse less restrictive? The worst that could happen is that someone enters a wrong key, resulting in an error message somewhere. But that could already happen today (with an expired key for example).

I had this problem.
I think older API keys are 32 alpha-numeric, and newer ones are 32 hex characters, and the regex only allows hex. I don’t use the API anywhere else, so I just re-generated my API key so I had a new hex-only one.


I’ve noticed that the keys I’ve seen lately no longer start with “key=”

My current mailgun secret API key gives the error mailgun_api_key: Value doesn't match the required format. I’m on v2.1.0.beta3 +64. Anything I can do to make it accept my API key?

What is the format of your key? Does it start with key-? Are all of the trailing characters in 1234567890abcdef?

1 Like

Hi, it’s been fixed. Forgot to update this thread. Here’s the link: