Plugins Plugin hub Backup SEO Caching Security Forms WooCommerce Images Best backup plugins
Hosting Hosting directory Shared hosting Managed WordPress Cloud hosting VPS hosting By reader location Hosting finder
Themes & builders Compare Rank Math vs Yoast
Tools All tools Hosting finder Plugin stack builder Cost calculator Salt generator Theme detector Who is hosting this? Speed test Headline analyzer robots.txt generator Redirect generator Uptime calculator Blog name generator
Blog Best backup plugins Deals
Guides All guides Speed up WordPress Choose hosting Back up WordPress
How we test

Developer · Explainer

What Is an API Key in WordPress? Explained

What Is an API Key in WordPress? Explained

Short answer

An API key is a secret code that lets a plugin or app prove its identity when connecting to another service, such as Google Maps, Mailchimp or Stripe. WordPress core uses application passwords instead of API keys for its own REST API.

Key takeaways

  • API keys act like passwords for plugin-to-service connections.
  • Most keys in WordPress come from outside services.
  • WordPress core uses application passwords, not API keys.
  • WooCommerce uses a consumer key and secret for its REST API.
  • Restrict, limit and rotate keys to keep them safe.

What is an API key in WordPress?

An API key in WordPress is a secret code that lets your site, a plugin or an outside app prove who it is when it connects to another service, such as Google Maps, Mailchimp, Stripe or a store API.

API stands for application programming interface. It is a set of rules that lets two pieces of software talk to each other. The key is like a password for that conversation.

When a plugin sends a request to a service, it includes the key. The service checks the key, decides what the caller is allowed to do, and sends back data or carries out an action.

Most API keys you meet in WordPress belong to outside services. You paste them into a plugin's settings so the plugin can work.

Where do you use API keys in WordPress?

You use API keys mainly in plugin settings that connect to outside services, such as maps, email marketing, payments, spam filters, AI tools and search.

Common examples include:

Service typeExampleWhat the key does
MapsGoogle Maps PlatformLoads maps and place search
Email marketingMailchimpAdds subscribers to your list
PaymentsStripeCreates charges and refunds
Spam protectionAkismet, reCAPTCHAChecks comments and forms
AI writing toolsVarious AI providersSends prompts and returns text
Store dataWooCommerce REST APILets outside apps read and write orders

For instance, a Google Maps plugin needs a key from Google's console. Google's guide on creating a Maps API key shows the process.

Our guide on getting a Mailchimp API key for WordPress walks through another common case.

Does WordPress itself use API keys?

WordPress core does not use classic API keys for its own REST API; it uses login cookies with nonces inside the site, and application passwords or OAuth for outside apps.

This surprises many people. If you want an outside app to talk to your WordPress site, you do not generate an API key in core settings. Instead, you create an application password under Users > Profile.

An application password works much like an API key. It is a long random string tied to one user, and you can revoke it at any time without changing the user's normal password.

The REST API authentication handbook explains each method. Our guide on using application passwords in WordPress shows the setup step by step.

What are WooCommerce API keys?

WooCommerce API keys are a pair of codes, a consumer key and a consumer secret, that let outside apps read or change store data through the WooCommerce REST API.

You create them under WooCommerce > Settings > Advanced > REST API. Each key pair is tied to a user and given read, write or read/write access.

Apps such as accounting tools, shipping services and mobile dashboards use these keys to pull orders, update stock or create products.

Our guide on getting a WooCommerce API key covers the screens.

For what you can do with them, see getting data from the WooCommerce API.

How is an API key different from a password or token?

An API key identifies an app or project, a password identifies a person, and a token is usually a short-lived credential issued after logging in.

CredentialWho it identifiesHow long it lastsTypical use
PasswordA personUntil changedLogging in to the dashboard
API keyAn app, site or projectUntil revokedPlugin to service connections
Application passwordA user, for one appUntil revokedOutside apps using the WordPress REST API
Access tokenA sessionMinutes to hoursOAuth logins and short tasks
NonceA single actionAbout a day in WordPressProtecting forms and REST calls

Some services give you two parts, such as a public key and a secret key. Stripe, for example, uses publishable keys in the browser and secret keys on the server. Stripe's page on API keys explains why the secret one must never be exposed.

Where are API keys stored in WordPress?

Most plugins store API keys in the WordPress database, in the wp_options table, though developers can store them in wp-config.php or server environment variables instead.

Storing a key in the database is convenient. You paste it into a settings screen and the plugin saves it.

The downside is that anyone with database access, or an admin account, can read it. Database backups also contain it.

For more control, some plugins let you define keys in wp-config.php with a constant:

define( 'MY_SERVICE_API_KEY', 'your-key-here' );

Keys in wp-config.php stay out of the database and out of the settings screen. Our guide on finding wp-config.php shows where that file lives. Only do this if the plugin's documentation supports it.

How do you keep API keys safe?

Keep API keys secret, restrict them to your domain or server where the service allows, give them the smallest permissions needed, and rotate them if they may have leaked.

Good habits include:

  • Never paste keys into public places, such as support forums, screenshots or public code repositories.
  • Restrict keys. Google, for example, lets you limit a key to your website's domain.
  • Use the right key type. Put secret keys only on the server, never in front-end JavaScript.
  • Use read-only access when an app only needs to read data.
  • Delete unused keys when you remove a plugin or stop using a service.
  • Rotate keys after a staff change or a suspected breach.

A leaked key can cost real money. Someone could run up a large maps or AI bill on your account, or read customer data from a store API.

What happens if an API key is wrong or missing?

If a key is wrong, expired or missing, the plugin cannot reach the service, so maps will not load, forms may not send, payments can fail and you will often see an error in the plugin settings.

Typical signs include:

  • A grey map box with a developer error message
  • Subscribers not showing up in your email list
  • Checkout errors that mention authentication
  • 401 Unauthorized or 403 Forbidden errors in logs

Check that you copied the whole key with no spaces, that it is for the right account and mode, and that it has the permissions the plugin needs. Test mode keys do not work in live mode, and the reverse is also true.

If the problem involves the WordPress REST API itself, our guide on enabling the REST API covers common blocks.

Do you need to understand APIs to use API keys?

No, most site owners only need to copy a key from a service's dashboard and paste it into a plugin's settings, while developers use keys in code to build custom features.

For everyday use, think of an API key as a login for a plugin. Get it from the service, paste it in, and keep it private.

If you want to build your own integrations, our guide on using the WordPress REST API is a good next step.

Frequently asked questions

Where do I find my WordPress API key?

WordPress core does not have a single API key. If a plugin asks for a key, get it from that service's own dashboard. For outside apps that need to reach your site, create an application password in your user profile instead.

Is an API key the same as an application password?

They work in a similar way, since both are long secret strings you can revoke. An API key usually identifies an app or project at a service, while a WordPress application password is tied to one user account on your site.

Can I share my API key with a developer?

Only if you trust them, and preferably give them a separate key with limited access. Delete or rotate that key when their work ends. Never send secret keys by public chat, forums or unencrypted shared documents.

Is it safe to put an API key in JavaScript?

Only public or publishable keys belong in browser code, and only when the service restricts them by domain. Secret keys must stay on the server, because anyone can view page source and copy what is in it.

What should I do if my API key leaks?

Revoke or regenerate the key in the service dashboard straight away, then paste the new key into your plugin. Check the service's usage and billing pages for unusual activity, and review who had access to where the key appeared.

Sources

  1. REST API Authentication WordPress Developer Resources
  2. Use API Keys with Maps JavaScript API Google for Developers
  3. API keys Stripe Docs
  4. WooCommerce REST API documentation WooCommerce

Is your product missing, or something out of date?

Tell us what to add or correct. We read every note and reply when we need a source. A message does not buy a ranking.

About the editors

Written and checked byWPLegible Editorial Team Independent WordPress reviews and guides

Researched from the primary sources listed above and checked against our editorial rules before publishing.