{"id":706,"date":"2024-05-07T11:41:53","date_gmt":"2024-05-07T11:41:53","guid":{"rendered":"https:\/\/kb.shortpixel.com\/docs\/using-shortpixel-image-optimizer-with-cloudflare-api-token\/"},"modified":"2025-08-27T08:46:26","modified_gmt":"2025-08-27T08:46:26","password":"","slug":"using-shortpixel-image-optimizer-with-cloudflare-api-token","status":"publish","type":"docs","link":"https:\/\/kb.shortpixel.com\/knowledge-base\/article\/using-shortpixel-image-optimizer-with-cloudflare-api-token\/","title":{"rendered":"Using ShortPixel Image Optimizer with Cloudflare&#8217;s API Token"},"content":{"rendered":"\n<section class=\"callout-red\">In order to follow our instructions below, you <strong>must<\/strong> have access to your Cloudflare control panel. If Cloudflare was set up through your hosting provider (e.g. SiteGround, WP Engine, Kinsta&#8230;), 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.<\/section>\n\n\n\n<p>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.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"501\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656-1024x501.jpg\" alt=\"\" class=\"wp-image-1804\" srcset=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656-1024x501.jpg 1024w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656-300x147.jpg 300w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656-768x376.jpg 768w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656-360x176.jpg 360w, https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2024\/05\/Screenshot-20250311_104656.jpg 1493w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To create a Token that is suited for this, you need to grant it the <strong>Cache Purge<\/strong> permission. Follow the instructions below to create it:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.cloudflare.com\/\" target=\"_blank\" rel=\"noopener\">Log in<\/a> to your Cloudflare account, click the user icon in the navigation menu, and then <strong>My Profile<\/strong>.<br><figure><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-OgfGkX7Cns.jpg\"><\/figure><\/li>\n\n\n\n<li><p>Select <strong>API Tokens<\/strong> on the left menu and then press the <strong>Create Token<\/strong> button.<br><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-50hoF0hSaH.png\"><\/p><\/li>\n\n\n\n<li><p>Scroll down and click the <strong>Get Started<\/strong> button next to<strong> Create Custom Token<\/strong> tab.<br><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-Ekmvsru6cQ.png\"><\/p><\/li>\n\n\n\n<li><p>Under the Token name, give the token an internal descriptive name, such as &#8220;ShortPixel&#8221;.<\/p><\/li>\n\n\n\n<li><p>Under Permissions, select &#8220;<strong>Zone<\/strong>&#8221; > &#8220;<strong>Cache Purge<\/strong>&#8221; > &#8220;<strong>Purge<\/strong>&#8221; in the three dropdown menus. <span style=\"background-color: transparent; color: var(--theme-text-color); font-family: var(--theme-font-family); font-size: var(--theme-font-size); font-style: var(--theme-font-style, inherit); font-weight: var(--theme-font-weight); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">If you see &#8220;<\/span><strong style=\"color: var(--theme-text-color); font-family: var(--theme-font-family); font-size: var(--theme-font-size); font-style: var(--theme-font-style, inherit); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">Edit<\/strong><span style=\"background-color: transparent; color: var(--theme-text-color); font-family: var(--theme-font-family); font-size: var(--theme-font-size); font-style: var(--theme-font-style, inherit); font-weight: var(--theme-font-weight); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">&#8221; instead of &#8220;<\/span><strong style=\"color: var(--theme-text-color); font-family: var(--theme-font-family); font-size: var(--theme-font-size); font-style: var(--theme-font-style, inherit); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">Purge<\/strong><span style=\"background-color: transparent; color: var(--theme-text-color); font-family: var(--theme-font-family); font-size: var(--theme-font-size); font-style: var(--theme-font-style, inherit); font-weight: var(--theme-font-weight); letter-spacing: var(--theme-letter-spacing); text-transform: var(--theme-text-transform);\">&#8221; under the third dropdown menu, you can select this option instead.<\/span><\/p><\/li>\n\n\n\n<li><p>Under Zone Resources, select &#8220;<strong>Include<\/strong>&#8221; > &#8220;<strong>Specific zone<\/strong>&#8221; > &#8220;<strong>Your Domain<\/strong>&#8221; 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.<\/p><section class=\"callout-blue\">If you have multiple websites, you have two options: either click the &#8220;<strong>+ Add more<\/strong>&#8221; link to add the domains you wish, or choose &#8220;<strong>All zones<\/strong>&#8221; from the second dropdown menu if you want to create the token for all your websites at once.<\/section><figure><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-rRFs5Vfzxo.png\"><\/figure><\/li>\n\n\n\n<li>Scroll down and press <strong>Continue to summary<\/strong> and then the <strong>Create Token<\/strong> button.<br><figure><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-TzXk4r6iPN.png\"><\/figure><\/li>\n\n\n\n<li><p>Copy the token generated. Make sure you save it because it will not be displayed again.<br><img decoding=\"async\" src=\"https:\/\/kb.shortpixel.com\/wp-content\/uploads\/2025\/08\/file-p4qaEsGyFe.png\"><\/p><\/li>\n\n\n\n<li><p>Paste the token code in our plugin settings (<em>Settings <\/em>> <em>ShortPixel <\/em>> <em>Cloudflare API <\/em>> <strong>Cloudflare Token<\/strong>).<\/p><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;), 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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"footnotes":""},"doc_category":[37],"glossaries":[],"doc_tag":[],"class_list":["post-706","docs","type-docs","status-publish","hentry","doc_category-shortpixel-image-optimizer"],"blocksy_meta":[],"year_month":"2026-04","word_count":362,"total_views":"2289","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin","author_nicename":"admin_mdli53m5","author_url":"https:\/\/kb.shortpixel.com\/author\/admin_mdli53m5\/"},"doc_category_info":[{"term_name":"ShortPixel Image Optimizer","term_url":"https:\/\/kb.shortpixel.com\/knowledge-base\/category\/shortpixel-image-optimizer\/"}],"doc_tag_info":[],"knowledge_base_info":[],"knowledge_base_slug":[],"_links":{"self":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/comments?post=706"}],"version-history":[{"count":2,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/706\/revisions"}],"predecessor-version":[{"id":2651,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/docs\/706\/revisions\/2651"}],"wp:attachment":[{"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/media?parent=706"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_category?post=706"},{"taxonomy":"glossaries","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/glossaries?post=706"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/kb.shortpixel.com\/wp-json\/wp\/v2\/doc_tag?post=706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}