Connecting to Cloudflare
The plugin talks to Cloudflare with an API token you create, scoped to only the permissions you choose. You add the token once on the WAF Rules screen, and you can connect as many Cloudflare accounts as you manage.
Two sign-in methods are supported:
- API Token (recommended): limited to the permissions you pick, and you can revoke it in one click.
- Email + Global API Key: your Cloudflare login email and Global API Key. The key has full control of the account, including billing and members, so use it only when a token won’t do.
Step 1: Create the API token#
- In Cloudflare, go to My Profile → API Tokens (dash.cloudflare.com/profile/api-tokens).
- Click Create Token, then Create Custom Token at the bottom.
- Name it, for example WP WAF Manager.
- Under Permissions, add a row for each permission in the table below that matches a screen you use. You can add more later by editing the token.
- Under Account Resources, choose Include → All accounts, or the client account.
- Under Zone Resources, choose Include → All zones from an account (pick the account), or All zones.
- Click Continue to summary, then Create Token.
- Copy the token now. Cloudflare shows it only once.
Token permissions by screen#
Each screen needs only its own permissions. The first three rows are needed for the core features.
| Screen or feature | Type | Permission | Access |
|---|---|---|---|
| Zone lists on every screen | Zone | Zone | Read |
| WAF Rules | Zone | Zone WAF | Edit |
| DNS Manager | Zone | DNS | Edit (Read to view only) |
| Zone Status, zone analytics and client reports | Zone | Analytics | Read |
| Zone Controls | Zone | Zone Settings | Edit |
| Cache purge (Zone Controls and admin bar) | Zone | Cache Purge | Purge |
| Security headers (Zone Controls) | Zone | Managed Headers | Edit |
| Bot Control | Zone | Bot Management | Edit |
| SSL & Insights: certificates | Zone | SSL and Certificates | Read |
| SSL & Insights: HTTPS settings and fixes | Zone | Zone Settings | Read (Edit for fixes) |
| SSL & Insights: Security Insights | Account | Security Center Insights | Read (Edit to dismiss) |
| Security Events | Zone | Analytics | Read (Pro plan zones and higher) |
| Alerts & Health: alerts and webhooks | Account | Notifications | Edit (Read to view only) |
| Alerts & Health: Health Checks | Zone | Health Checks | Edit (Read to view only) |
| Turnstile | Account | Turnstile | Edit |
| Page Rules: scan and turn on or off | Zone | Page Rules | Edit (Read to scan only) |
| Page Rules: migrate redirects | Zone | Single Redirect | Edit |
| Page Rules: migrate cache settings | Zone | Cache Rules | Edit |
| IP Access Rules | Account | Account Firewall Access Rules | Edit |
| Email Routing: destination addresses | Account | Email Routing Addresses | Edit |
| Email Routing: forwarding rules | Zone | Email Routing Rules | Edit |
AI tools connected through AI and MCP use the same token, so they need the same permissions as the screens they act on.
If a screen says a permission is missing, edit the token in Cloudflare, add that row and save. The plugin picks it up on the next request, so you don’t need to paste the token again.
Step 2: Add the token to the plugin#
- Go to WAF Manager → WAF Rules. The Cloudflare API Credentials card is at the top.
- In Account Name / Label, enter a name you’ll recognise, such as Agency account or Client A.
- Keep the API Token tab selected and paste the token.
- Leave Keep for on Forever.
- Click Verify & Save.

When Cloudflare accepts the token you’ll see Token status: active, the badge changes to Connected and your zones load. To use the Global API Key instead, choose the Email + Global API Key tab, then enter your Cloudflare login email and the key (find it under My Profile → API Tokens → Global API Key → View).
Keep for controls how long the credentials are stored: Forever, 1 hour, 8 hours or 1 day. When the time is up, the plugin deletes the account the next time it contacts Cloudflare. Short times suit one-off work on a client account you don’t want stored.
More than one Cloudflare account#
Agencies often have a token per client account. To add another, open Add Another Account on the same card and repeat Step 2. The account you add becomes the active one.

Your accounts are listed under Saved Accounts. The Active account is the one every screen uses. Click Switch on another account to make it active.
- Edit changes the label or how long it is kept. Paste the token again when you edit an account that isn’t active. For Email + Global API Key accounts, enter the email and key again.
- Remove deletes the account from WordPress. It doesn’t change anything in Cloudflare.
A few screens let you pick an account without switching: IP Access Rules, and the client editor in Clients & Reports. Screens that work on a whole Cloudflare account (Security Insights, Alerts and Turnstile) have a Cloudflare account dropdown that lists every account the active token can see.
How credentials are stored#
Tokens and keys are encrypted with libsodium before they are saved, using a key derived from your site’s AUTH_KEY in wp-config.php. They are never sent to the browser, and the AI and MCP abilities never return them. If AUTH_KEY changes, the saved credentials can’t be read any more: add them again.
Advanced: accounts in wp-config.php#
To keep credentials out of the database, define them in wp-config.php, above the line /* That's all, stop editing! */.
One account with a token:
define( 'WPWAF_API_TOKEN', 'your-token' );
define( 'WPWAF_API_LABEL', 'Agency account' ); // optional
One account with the Global API Key:
define( 'WPWAF_API_EMAIL', '[email protected]' );
define( 'WPWAF_API_KEY', 'your-global-api-key' );
Several accounts:
define( 'WPWAF_ACCOUNTS', [
[ 'label' => 'Agency account', 'api_token' => 'token-1' ],
[ 'label' => 'Client B', 'api_email' => '[email protected]', 'api_key' => 'key-2' ],
] );
WPWAF_ACCOUNTStakes priority over the single-account constants.- The first account in wp-config.php is always the active one.
- These accounts show (wp-config.php) after their name and can’t be edited or removed in WordPress. Change them in wp-config.php.
Check the connection#
Go to WAF Manager → Settings and click Test Connection. A working connection shows the account name and how many active zones it can see. Run it after rotating a token or changing its permissions.
If zones don’t load, the token is usually missing Zone → Zone → Read, has expired, or doesn’t include the zones under Zone Resources. See Troubleshooting and FAQ.
Was this helpful?
Thanks for your feedback!
✓ Feedback received. Thank you!