Snippets

snowflakers Cloudflare - cache purge via cURL (to automate the process, for example in CI/CD tool)

Created by Bartek Mis last modified
1. Log into the Cloudflare account and go to "My Profile" - you can find the API key over there.
2. Generate zone id requires for the API calls;
`curl -X GET "https://api.cloudflare.com/client/v4/zones" \
    -H "X-Auth-Email: user@example.com" \
    -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
    -H "Content-Type: application/json"`
3. In the response, you can find the ZONE ID (```id```) of the desired domain name.
4. To purge everything from the cache via cURL, please follow as belows:
`curl -X POST "https://api.cloudflare.com/client/v4/zones/<ZONE ID HERE>/purge_cache" \
     -H "X-Auth-Email: user@example.com" \
     -H "X-Auth-Key: c2547eb745079dac9320b638f5e225cf483cc5cfdda41" \
     -H "Content-Type: application/json" \
     --data '{"purge_everything":true}'`

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.