Subscribe to receive notifications of new posts:

CloudFlare Tips: 5 Frequently used CloudFlare API calls


3 min read

Sumatran Tiger: San Francisco Zoo
Editor's Note: Some of you may be asking why CloudFlare is using an image of a tiger for something related to the CloudFlare API. Since Ian Pye of CloudFlare is our API lead, I asked Ian what image he would like in the blog post about the API. His response to me: "A tiger. Our API is like a tiger. Oh, and everyone likes tigers." So, now you know the story of why a tiger is in the CloudFlare API post.

As many of our Facebook fans and Twitter followers may have noticed recently, CloudFlare has been spending a fair amount of time recently asking what we can do to improve the service. One of the most startling revelations
to me was that many of our customers don't know we have a CloudFlare API that mimics many of the features found in your CloudFlare settings' page, even though we have the API fairly well documented in the CloudFlare Forums, so I thought I would put together a little "cheat sheet" for frequently used API features.

Things you need to know or get before using the API:

  1. You will need to get your API key for your account first. You can locate the API key by going to your 'My Account' page.
  2. Each zone ( on CloudFlare has a unique number identifier. If you need to locate the zoneid for a domain, simply go to the "Reports and Stats' link for that domain (the zone id appears at the end with an equal sign, such as zid=xxxxxx).
  3. Your account email address.
  4. You may interface with the API via HTTPS POST or GET requests to

Commonly used API features

Development Mode
If you plan on making changes to the static content CloudFlare caches on your site, it is best for you go to Development Mode first to bypass the CloudFlare cache so these changes appear immediately.

Purge CloudFlare cache
If you want to purge your CloudFlare cache, or if you forgot to go to Development Mode when making changes to your site, you may purge your CloudFlare cache so that these changes appear. You would only want to do this when you really want to purge all the static content CloudFlare has stored in the cache for that domain. Purging is not selectively done by file extension or file name.

Pulling basic statistics for your site
One of the most common requests we get from our users is that they would like to share their statistics with clients without providing login details to the account. While we currently don't offer a way for people to access an account with a "read only" option, you can use the API to grab basic CloudFlare statistics from your account.

Reporting spam back to CloudFlare
While the reporting spam back to CloudFlare API option has been fairly well documented on our blog already, you would use this option if CloudFlare's data sources don't catch some sources of spam that make it through to websites (we're always looking to improve).

Since we rely on our community of websites to alert us to online threats reported to us through the API or threat control, it actually helps make our system smarter for all sites on the system and can help stop spam from hitting other sites as well.

Updating your screen capture on your challenge page
If the look and feel of your site changes frequently, you probably want to update the image associated with your CloudFlare challenge (captcha) page on a regular basis so your visitors know that they are hitting your site.

The specific calls and parameters for using each of these API functions can be found in the CloudFlare Client Interface API.

Have a suggestion about improving the API? Please contact CloudFlare with any requests.

We protect entire corporate networks, help customers build Internet-scale applications efficiently, accelerate any website or Internet application, ward off DDoS attacks, keep hackers at bay, and can help you on your journey to Zero Trust.

Visit from any device to get started with our free app that makes your Internet faster and safer.

To learn more about our mission to help build a better Internet, start here. If you're looking for a new career direction, check out our open positions.
APIProduct NewsDevelopersBest Practices

Follow on X


Related posts

May 30, 2024 12:12 PM

Cloudflare acquires BastionZero to extend Zero Trust access to IT infrastructure

We’re excited to announce that BastionZero, a Zero Trust infrastructure access platform, has joined Cloudflare. This acquisition extends our Zero Trust Network Access (ZTNA) flows with native access management for infrastructure like servers, Kubernetes clusters, and databases...