N Docs
← Back to site

Keep the Bunny API key in wp-config.php

2 min readUpdated November 23, 2026

By default, the Bunny API key you paste in the setup wizard is saved in your WordPress database. You can keep it in wp-config.php instead, so it never sits in the database, in database backups or in exports.

Why you might want this#

  • Database backups and staging copies don’t carry the key.
  • Someone with database access but not file access can’t read it.
  • Your host or agency may require secrets to live in configuration files.

The key can do a lot in your Bunny account (create and delete pull zones, scripts and databases), so it’s worth protecting.

Add the key#

  1. Open wp-config.php in the root of your WordPress site.
  2. Add this line above the one that says /* That's all, stop editing! */:
define( 'NAHNU_LINKS_BUNNY_API_KEY', 'your-bunny-api-key' );
  1. Replace your-bunny-api-key with your key from Bunny: click your name at the top right, then Account settings, then API key.
  2. Save the file.

The dashboard now uses that key and shows from wp-config.php where the key would be.

What changes#

  • The key can only be changed in the file. If you try to change it in the dashboard, it tells you the key is set in wp-config.php.
  • The setup wizard skips the Connect step’s key box.
  • Everything else works the same.

Remove a key already saved in the database#

If you connected before adding the line, the old copy stays in the database but is no longer used: the key in wp-config.php always wins.

Rotating the key#

If you make a new API key in Bunny, update the line in wp-config.php with the new key. Short links keep working while you do this: they never use the key.

One exception: if you turned on Domains over the API for the partner API, the edge script keeps its own copy of the key so it can add domains. After changing the key in wp-config.php, turn that setting off and on again under Settings > Developers so the edge script gets the new key. See Domains over the API.