Skip to content

Instantly share code, notes, and snippets.

@lucien144
Last active May 19, 2024 21:24
Show Gist options
  • Save lucien144/832e9493a4a599303df3200863daa450 to your computer and use it in GitHub Desktop.
Save lucien144/832e9493a4a599303df3200863daa450 to your computer and use it in GitHub Desktop.
Clear Cloudflare cache from command line.
#!/bin/bash
curl -X POST "https://api.cloudflare.com/client/v4/zones/{$ZONE_ID}/purge_cache" \
-H "X-Auth-Email: {$EMAIL}" \
-H "X-Auth-Key: {$API_KEY}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
@bluegreen08
Copy link

@bluegreen08 Most likely like this:

curl -X POST "https://api.cloudflare.com/client/v4/zones/{$ZONE_ID}/purge_cache" \
     -H "X-Auth-Email: {$EMAIL}" \
     -H "X-Auth-Key: {$API_KEY}" \
     -H "Content-Type: application/json" \
     --data '{"prefixes":["www.example.com/foo","images.example.com/bar/baz"]}'

I realized this is tied to mu specific email. Is there a way to have this command and use a service token or service account?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment