Purge Cache by geo - API PHP

Goodmorning to everyone, I am new here.
I have a free account on CloudFlare and I’m using DNS and CDN.

I have set the following page rule in order to cache the content of my website:

Here, in place of “mywebsite” I put my web site domain.

Now, I’m trying to purge cache only for Italy for same specific pages but CloudFlare purges cache also for other country given that if I visit the website from other ip (in other countries), the first time after I do the purge operation, pages are not on cache.

This is my code:

$cust_zone = $zoneId;
$ch_purge = curl_init();
curl_setopt($ch_purge, CURLOPT_URL, "https://api.cloudflare.com/client/v4/zones/".$cust_zone."/purge_cache");
curl_setopt($ch_purge, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($ch_purge, CURLOPT_RETURNTRANSFER, 1);
	$headers = array(
    'X-Auth-Email: [email protected]',
    'X-Auth-Key: my-auth-key',
    'Content-Type: application/json'
);
	
	
    	
$data = '{"files":[
  {
"url": "https://www.mydomain.it/",
"headers": {
  "CF-IPCountry": "IT"
}
  },
  {
"url": "https://www.mydomain.it/pagina-2",
"headers": {
  "CF-IPCountry": "IT"
}
  }
]}';
	
	
curl_setopt($ch_purge, CURLOPT_POST, true);
curl_setopt($ch_purge, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch_purge, CURLOPT_HTTPHEADER, $headers);

$result = json_decode(curl_exec($ch_purge),true);
curl_close($ch_purge);

It looks like “CF-IPCountry” is ignored and the specified pages are removed from cache for all geo area. Someone can help me to understand?
Maybe I can purge cache accourding Geo-Tag if I have a free account?

Thanks in advance.

The “headers” object is only relevant if you are caching with a custom key. Are you doing that (e.g. via a worker), respectively are you on an Enterprise plan?

No, I’m on a free plan. Can I use custom key with free plan,alternatively, if I update to pro, can i use custom key or I need and Enterprise plan?

In this case you cant have a custom key and “headers” wont take effect either. You’d need an Enterprise plan.