WP_SECRETS_KEY: what WordPress 7.2's Secrets API asks of your site
WordPress 7.2, scheduled for 8 December 2026, adds a Secrets API: plugins can store API keys and other credentials encrypted instead of in plain options. The encryption rests on one new constant in wp-config.php, WP_SECRETS_KEY. New installs get it automatically; sites that update from an earlier version don't. Here is what the key does, how to add it, the one mistake to avoid with it, and what Site Health starts reporting after the update.
What changes in WordPress 7.2
Plugins have always kept their API keys, OAuth client secrets and similar credentials in the options table, usually as plain text. Anyone who gets a copy of the database (a leaked backup, an export, a staging copy) gets those credentials too. WordPress 7.2 gives plugins a standard place to put them instead: the Secrets API, with functions such as wp_set_secret() and wp_get_secret().
Secrets are still stored in the options table, but encrypted with libsodium. Each one is encrypted with a key derived from a random root key, and the root key itself is stored encrypted with WP_SECRETS_KEY from wp-config.php. So a database copy on its own is no longer enough to read them: the reader also needs the key, which lives in a file outside the database.
The API keeps one previous version of each secret, so a plugin can roll out a new credential and fall back to the old one while it does. That only matters to you if a plugin you use adopts the API: nothing moves into it by itself, and plugins have to check that the API is available before they use it.
The final release is scheduled for 8 December 2026. The details below come from the WordPress core team's developer note of 11 November 2026 (corrected on 13 November), written during the beta: check the release notes when 7.2 ships.
Existing sites need WP_SECRETS_KEY added
On a new install, the installer writes WP_SECRETS_KEY into wp-config.php along with the salts. A site that updates to 7.2 keeps its old wp-config.php, which has no such line. Without a usable key the API stores nothing: every write, and every read of a stored secret, returns an error. Early betas fell back to a key made from the login key and salt; that fallback was removed before the release.
An empty value doesn't count, and neither does the placeholder from wp-config-sample.php or a value copied from one of the authentication keys or salts. The key has to be its own random value.
Nothing on the site breaks because the key is missing. Plugins that use the Secrets API are meant to check wp_is_secrets_api_available() first and keep their old storage when it says no, so their credentials simply stay where they were. Adding the key is what lets them move into encrypted storage.
How to add the key
After updating to 7.2, open Tools → Site Health. The Secrets API key test generates the line for you; copy it into wp-config.php, below the authentication keys and salts. It has the form define( 'WP_SECRETS_KEY', '…' ); with a base64-encoded random 32-byte value.
You can also make a value yourself on the command line: php -r 'echo base64_encode( random_bytes( 32 ) ), "\n";'. Use one value per site; two sites sharing a key gain nothing and lose some isolation.
If your host or a deployment tool writes wp-config.php for you, ask whether it adds the key. The developer note asks tools that write the salts to add WP_SECRETS_KEY at the same time, and says WP-CLI's wp config create is being updated to do it.
Treat the value like a password. Keep it in your password manager or your deployment secrets, with the rest of wp-config.php, and never commit it to a public repository.
Don't rotate it like the salts
The developer note puts it plainly: "Don't treat the key like the salts." Changing the authentication keys and salts is a routine step after a hack or a staff change: everyone is logged out once and nothing else happens. WP_SECRETS_KEY is different. Once secrets are stored, changing or removing it makes every one of them unreadable until the old value is put back.
So when you replace the keys and salts after a cleanup, leave WP_SECRETS_KEY as it is. If you do need a new key (it leaked with the file, for example), WordPress has a supported way: put the old value in WP_SECRETS_KEY_PREVIOUS, the new one in WP_SECRETS_KEY, re-encrypt the root key with WP-CLI as the developer note shows, then remove the PREVIOUS line. The stored secrets themselves aren't rewritten; only the root key is.
If a key was changed by mistake, restoring the previous value fixes it. Site Health says the same in its critical message.
Moving, restoring and cloning sites
The key and the database now belong together. A database restored or migrated next to a wp-config.php with a different WP_SECRETS_KEY (or none) can't decrypt the secrets it holds. The plugins that stored them get an error when they read, and Site Health reports undecryptable secrets.
When you move a site, carry the key with it, the same way you already carry the database credentials. When you clone production to staging, copy the key too, or expect the clone's plugins to ask for their credentials again. Make sure your backups can restore wp-config.php as well as the database, or keep the key somewhere you can find it on the day you need it.
On multisite, each network has its own root key. An install with more than one network has to re-encrypt each network's root key when the key is replaced, not only the current one.
Hosts: the secrets.php drop-in
A host can replace part or all of the API with a drop-in, wp-content/secrets.php, loaded automatically like db.php or object-cache.php. It can keep the key that protects the root key in a key management service or hardware module, store the encrypted records outside the options table, or hand the whole API to an external secret manager. WordPress 7.2 lists secrets.php with the other drop-ins on the Plugins screen and in Site Health.
If the drop-in fails to load, every Secrets API call returns an error and Site Health says so: WordPress doesn't fall back to its default storage, so a broken backend can't pass for an empty one. On hosts with a read-only provider, the values are managed in the host's dashboard or CLI, plugins that try to save a secret there get an error; the developer note asks them to show a notice rather than an input field.
If you find a secrets.php you didn't expect, check where it came from. On a managed host it is likely theirs; on a site you run yourself, any PHP file that loads on every request is worth knowing about.
What Site Health will show
WordPress 7.2 adds three Site Health tests, all under Security. "Secrets API key source" is a recommendation when the key is missing or not usable, and critical when the key can't decrypt the root key that is already stored. "Secrets API: undecryptable secrets" is critical when any stored secret can't be decrypted. "Secrets API: credentials pending rotation" is a recommendation when secrets are flagged for rotation, as ones a plugin imported from an old option are.
The Info tab gains a Secrets API section with the provider, the keyring, where the key comes from and how many secrets are stored. Expect the missing-key recommendation on most sites right after the update: it goes away once the line is in wp-config.php.
If you tested a 7.2 beta
Secrets stored on an early beta without WP_SECRETS_KEY were encrypted under the old fallback, made from LOGGED_IN_KEY and LOGGED_IN_SALT. After updating, Site Health reports them as undecryptable, but they're still there. Leave the salts alone until you've moved them: add a new WP_SECRETS_KEY, set WP_SECRETS_KEY_PREVIOUS to the old fallback as the developer note shows, re-encrypt the root key, then remove the PREVIOUS line.
Developers who wrote a custom secrets.php during the beta have one more change: the keyring, store and provider became abstract classes, so a drop-in that still says implements instead of extends is a fatal error on every request once 7.2 is installed.
How Relvato catches it
Relvato's WordPress health monitor runs WordPress's own Site Health tests on Relvato's schedule, through the Relvato WordPress plugin, so you don't have to open Tools → Site Health to see them. Once a site is on 7.2, the missing-key recommendation appears on the run as "Site Health recommends: …", listed but not alerted. A critical result, such as a key that no longer decrypts the stored secrets after a migration or a wp-config.php rewrite, makes the run report an issue, and you can ignore it by its test if it's expected.
The Theme integrity monitor watches the PHP files loose in wp-content, drop-ins included, and reports when one changes. Its one-time review of files that run on every request treats a host's secrets.php as one of WordPress's own drop-ins, like object-cache.php. The plugin does the same from version 1.79.3. When the Exposure scan finds the sample phrases still in wp-config.php, its finding tells you to replace the keys and salts but leave WP_SECRETS_KEY as it is.
On the Free plan you press Run whenever you want to check, or schedule it weekly. Pro re-runs your monitors by itself after every update, so the first run after the 7.2 update shows the new Site Health tests.
The Secrets API in WordPress 7.2 at a glance
| Topic | What WordPress 7.2 does |
|---|---|
| New installs | The installer adds WP_SECRETS_KEY to wp-config.php with the salts |
| Updated sites | No key: the API stores nothing until you add one; Site Health recommends it |
| Where the key goes | wp-config.php, below the authentication keys and salts |
| Changing the key | Makes stored secrets unreadable; replace it only with WP_SECRETS_KEY_PREVIOUS and a re-encrypt |
| Storage | Options table, encrypted with libsodium (XChaCha20-Poly1305) |
| Hosts | A wp-content/secrets.php drop-in can replace the keyring, the store or the whole provider |
| Site Health | Three Security tests: key source, undecryptable secrets, credentials pending rotation |
Questions, answered
Do I have to add WP_SECRETS_KEY?
Nothing breaks without it, but the Secrets API stores nothing until it's there, so plugins that use the API keep their credentials in their old, unencrypted storage. Site Health recommends adding it, and it takes one line in wp-config.php.
Is WP_SECRETS_KEY one of the salts?
No. The salts can be replaced at any time; the only effect is that everyone is logged out. Changing WP_SECRETS_KEY after secrets are stored makes them unreadable until the old value is restored, so leave it alone when you rotate the salts.
What happens if I lose the key?
The stored secrets can't be decrypted. Site Health reports them as undecryptable, and each plugin that used the API will need its credentials entered again. Keep the key with your wp-config.php backups.
Does the Secrets API protect against a hacked site?
Not against code running on the site: any plugin can read any secret, since the name prefix only stops plugins overwriting each other's. What it adds is protection for copies of the database, such as a leaked backup or export, which no longer contain readable credentials.
When is WordPress 7.2 released?
It's scheduled for 8 December 2026, according to the WordPress 7.2 Beta 5 announcement of 10 November 2026.