Skip to main content

How to keep your API key safe

It takes about 10 minutes and protects your account, your contacts and your sending reputation.

Written by Support Team

What is an API key?

An API key is like a password for programs. Your website, online shop, CRM or plugin uses it to work with your Elastic Email account without you logging in, for example to send order confirmations or add new contacts.

Anyone who has your API key can use your account from anywhere in the world, with whatever rights the key has. That is why it needs the same care as your bank password.

Your SMTP password works the same way. Everything below applies to it too.

1. Keep the key secret

  • Never send your API key by email or chat, or put it in a support ticket, a screenshot, a forum post or a shared document.

  • Never put it in code that others can see (for example on GitHub) or in a web page's code.

  • Keep it only in the settings of the tool that uses it, or in a password manager.

  • Our support team will never ask you for your API key. If someone does, don't send it.

2. Use the newest version of our API (version 4)

Our API has several versions. Older integrations often use version 2, which lets the key be written into the web address, for example:

https://api.elasticemail.com/v2/email/send?apikey=XXXX

That is not safe. A web address is stored in many places: server logs, browser history, monitoring tools, and links passed on to other people. A key inside the address ends up in all of them.

Version 4 of our API never puts the key in the address. It is sent hidden inside the request, which is much safer. Version 4 is also our current API, and new features arrive there.

How to tell which version you use: look at the settings of your plugin or integration, or ask whoever set it up. If you see /v2/ or apikey= in an address, you are on the old version.

You can find our latest documentation at the link here.

What to do:

  1. If you use a plugin or a ready-made connector: update it to the newest version and check with its maker that it uses Elastic Email API version 4.

  2. If a developer or agency built your integration: send them this article and ask them to move it to API version 4 (see "For developers" below).

  3. After the move, replace your API key (section 5). The old key may already be stored in logs.

Not sure? Contact our Support and tell us which tool you use. Don't send us the key.

3. One key for each tool

Create a separate API key for every website, plugin or service, and give each a clear name, for example "Shop - order emails".

If one key ever leaks, you only replace that one, and you know which tool it came from.

4. Give each key only what it needs

When you create a key, you can limit it:

  • Access: a website that only sends emails needs only the right to send, not full access to your account.

  • Restrict access to IP: if the tool runs on a server with a fixed address, enter that address. Your web host or developer can tell you what it is. A copied key then does not work from anywhere else.

  • Expiry date: for a test or a one-off job, let the key expire on its own.

If you manage several brands or clients, give each its own sub-account with its own keys.

5. Replace keys from time to time

  1. Create a new key.

  2. Put it into your tool in place of the old one.

  3. Check that your emails still go out.

  4. Delete the old key.

Do this straight away when:

  • someone who knew the key leaves your company or agency;

  • the key was sent by email or chat, or shown in a screenshot;

  • the key was written in a web address (section 2);

  • you see activity in your account that you don't recognise.

Also delete keys that nothing uses any more.

6. Protect your dashboard login too

Anyone who can log in to your dashboard can create new API keys.

  • Turn on two-factor authentication.

  • Use a password you don't use anywhere else.

  • Give each colleague their own user with only the rights they need, instead of sharing one login.

7. What if you think a key was stolen?

Warning signs:

  • emails you didn't send;

  • contacts, lists or domains you didn't add;

  • settings you didn't change;

  • credits used faster than usual.

What to do:

  1. Delete the key. If you don't know which one leaked, delete all keys.

  2. Create new keys and put them into your tools.

  3. Change your dashboard password.

  4. Contact our support.

For developers

  • Use API v4 and send the key in the X-ElasticEmail-ApiKey request header. API v4 accepts the key only there. Never pass it as ?apikey=.

  • If you still call v2, plan the move to v4 and the official client libraries.

  • Keep keys in environment variables or a secret store, never in source code or in JavaScript that runs in the browser.

  • Use one key per service, with the narrowest access, an IP restriction and an expiry where possible.

  • After the move, create a new key and delete the one that was used in URLs.

Did this answer your question?