Using ShortPixel Image Optimizer with Cloudflare's API Token

In order to follow our instructions below, you must have access to your Cloudflare control panel. If Cloudflare was set up through your hosting provider (e.g. SiteGround, WP Engine, Kinsta...), you will not be able to do this unless they grant you access to your Cloudflare control panel. Alternatively, you can disable the Cloudflare integration with your hosting provider and set it up yourself with a free Cloudflare account.

ShortPixel Image Optimizer allows you to use the secure Cloudflare API Token on its settings instead of the Global API Key and Cloudflare account e-mail. This integration will allow our plugin to update your images on Cloudflare as soon as they are optimized so that Cloudflare will never serve unoptimized images.

To create a Token that is suited for this, you need to grant it the " Cache Purge" permission. Follow the instructions below to create it:

  1. Log in to your Cloudflare account, click the user icon in the navigation menu, and then My Profile.

  2. Select API Tokens on the left menu and then press the Create Token button.

  3. Scroll down and click the Get Started button next to Create Custom Token tab.

  4. Under the Token name, give the token an internal descriptive name, such as "ShortPixel".

  5. Under Permissions, select " Zone" > "Cache Purge" > "Purge" in the three dropdown menus.

    If you see " Edit" instead of " Purge" under the third dropdown menu, you can select this option instead.
  6. Under Zone Resources, select " Include" > "Specific zone" > "Your Domain" in the three dropdown menus. Note that your site must be added to your Cloudflare account for the domain to appear in the third dropdown, as seen in the screenshot below.

    If you have multiple websites, you have two options: either click the " + Add more" link to add the domains you wish, or choose " All zones" from the second dropdown menu if you want to create the token for all your websites at once.

  7. Scroll down and press Continue to summary and then the Create Token button.

  8. Copy the token generated. Make sure you save it because it will not be displayed again.

  9. Paste the token code in our plugin settings ( Settings > ShortPixel > Cloudflare API > Cloudflare Token).

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us