Skip to content

Instantly share code, notes, and snippets.

@colinwilson
Created August 15, 2018 03:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save colinwilson/c83077c72203efc34ea252c8040fa81c to your computer and use it in GitHub Desktop.
Save colinwilson/c83077c72203efc34ea252c8040fa81c to your computer and use it in GitHub Desktop.
CloudFlare: Clear cache and enable development mode via API
email=colin@wyveo.com
tkn=<API KEY>
domain=wyveo.com
zone=$(curl -s -X GET "https://api.CloudFlare.com/client/v4/zones?name=${domain}&status=active&page=1&per_page=20&order=status&direction=desc&match=all" \
-H "X-Auth-Email: ${email}" \
-H "X-Auth-Key: ${tkn}" \
-H "Content-Type: application/json")
zone=${zone:18:32}
curl -X DELETE "https://api.CloudFlare.com/client/v4/zones/${zone}/purge_cache" \
-H "X-Auth-Email: ${email}" \
-H "X-Auth-Key: ${tkn}" \
-H "Content-Type: application/json" \
--data '{"purge_everything":true}'
curl -X PATCH "https://api.cloudflare.com/client/v4/zones/${zone}/settings/development_mode" \
-H "X-Auth-Email: ${email}" \
-H "X-Auth-Key: ${tkn}" \
-H "Content-Type: application/json" \
--data '{"value":"on"}'
unset zone email tkn domain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment