API purge single file


I’ve got a nextjs site where I woudl like to purge cache for single URL, i.e:



But sending purge requests like:

curl -X POST ‘api/purge_cache’ -H ‘Authorization: Bearer ‘token’’ -H ‘Content-Type: application/json’ -d ‘{“files”:[“mydomaincom/contact”’]}

doesn’t clear the cache and content on site isn’t refreshed - anyway I’ve got an response:


so the cache should be purged.

Only purge all do the job, but I don’t want to clear all cache for a single URL.
We have an Pro plan on CF if that changes anything. Do I have to include all headers into request, i.e:

x-nextjs-cache: STALE
x-powered-by: Next.js
x-powered-by: PleskLin

Trying to do this few days and have no idea what I’m doing wrong.

If you’re still having issues, try using a fully qualified URI in the files field, so https://mydomaincom/contact instead.

Interestingly/annoyingly the API doesn’t return an error if the files field is outside the scope of your API permissions, or even outside of your own account, but it won’t work either.

This command line is copied from one of my own scripts, with the Zone-ID and Token replaced, of course.

curl --output /dev/null --silent -X POST "https://api.cloudflare.com/client/v4/zones/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/purge_cache" -H "Authorization: Bearer zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz" -H "Content-Type: application/json" --data '{"files":["https://mysite.example.com/my-file"]}'