Error code 7003 & 7000 using Global API Key

Hello

Using a Global API Key we get the following responses when making a request to purge cache.

7003 Could not route to /zones/purge_cache, perhaps your object identifier is invalid?

7000 No route for that URI

The credentials are correct and should be no issue with permissions since this is the Global API Key.

The request is being made for assets located at a 4th level domain eg: four.three.domain.com

The domain has a CF Advanced (Dedicated) SSL purchased, setup and functioning as expected for *.domain.com, *.three.domain.com

Is there a known issue here, or is it more likely to be something else ?

Thanks

Furthermore, I understand that the request was not made for a 4th level but 3rd level domain. So perhaps this is not the issue.

The same has been tested using a Global API Key on a different CF account with 2nd level domain to purge cache which also has assets at 4th level, successfully. When attempting to do the same using an API Token, the request fails.

So actually there are 2 issues here.

Why do we get these errors as originally described, on one account and not on another?

and

Why do API Tokens not work for us in either account?

Hi @timsk!

Are are sending
https://api.cloudflare.com/client/v4/zones/purge_cache/
instead of
https://api.cloudflare.com/client/v4/zones/<zone_tag>/purge_cache/
?

Does your API Toke have the right permissions?

1 Like

As stated, the Global Key is being used so no issue with permissions.

Some progress has been made now but encounter an issue with how to manage zones within zone.

Here is code

<?php
$zone = '';
$login = '';
$apiKey = '';

$curlHandle = curl_init();
curl_setopt($curlHandle, CURLOPT_URL, "[https://api.cloudflare.com/client/v4/zones/{$zone}/purge_cache](https://api.cloudflare.com/client/v4/zones/%7B$zone%7D/purge_cache)");
curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1);
$headers = [
"X-Auth-Email: {$login}",
"X-Auth-Key: {$apiKey}",
'Content-Type: application/json',
];
$data = json_encode([
'purge_everything' => true,
]);
curl_setopt($curlHandle, CURLOPT_POST, true);
curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $data);
curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headers);

$result = json_decode(curl_exec($curlHandle), true, 512);
curl_close($curlHandle);

print_r($result);

It works with the 2nd level domain. It purges cache for the domain and all its subdomains that connected to the CF. Is it possible to control only one subdomain(maybe moving it to another Zone, to have another Zone ID for it) to avoid purging the cache of the main domain?