API to create A records

Good day,

I was using API to create DNS records for subdomains, it was working very well until few days ago. Has there been any change to API for free account holders?

Can you provide us with some more details?

  • what error are you receiving?
  • can you share the script/API call? (anonymized if you like?)

I redacted my email address, API Keys and public IP adress:

if (mysqli_num_rows($userData) > 0) {
while($row = mysqli_fetch_assoc($userData)) {
if(!empty($row[‘username’])){

               function cloudflare_api($params,$data,$action){
            	    $cloudflareEndPoint = 'https://api.cloudflare.com';//$params['configoption1'];
            	    $cloudflareAuthEmail = '[email protected]';//$params['configoption2'];
            	    $cloudflareAuthKey = 'myauthkey';//$params['configoption3'];
            	    $ch = curl_init();    
            	    curl_setopt($ch, CURLOPT_URL, $cloudflareEndPoint.$action);
            	    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            	    curl_setopt($ch, CURLOPT_POST, 1);
            	    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
            	    $headers = array();
            	    $headers[] = 'X-Auth-Email: '.$cloudflareAuthEmail;
            	    $headers[] = 'X-Auth-Key: '.$cloudflareAuthKey;
            	    $headers[] = 'Content-Type: application/json';
            	    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
            	    $result = curl_exec($ch);
            	    $err = curl_error($ch);
            	    curl_close($ch);
            	    return $result;
            	}
            	
            	$new_url = $row['new_url'];
            	$domain = $row['domain'];
            	
            	$cfdata = [
                    "type" => 'A',
                    "proxied" => true, 
                    "name" => $domain,
                    "content" => '192.168.1.20',
                ];
                $action = '/client/v4/zones/myzoneapi/dns_records';
                $params = array();
                $zones = cloudflare_api($params,$cfdata,$action);
                $zonesd = json_decode($zones,true);
                $dnsRecordId = $zonesd['result']['id'];
                
                
                
           }
            
        }
        
    }

Could you try again with modifying that to:

$headers[] = 'Authorization: Bearer '.$cloudflareAuthKey;

and then use a TOKEN like recommended here:
https://api.cloudflare.com/#getting-started-requests
And make sure your API does have the correct rights according to:
https://developers.cloudflare.com/api/tokens/create

You anyway did not state what error you get like requested here:

Or try any of the other solutions availble in the communityforum here:

Hi M4rt1n,
Thanks for the quick responses, below is the error:
This web property is temporarily restricted from being added to Cloudflare at this time. Please try again later, or contact Cloudflare Support with any questions.

Ah …that changes everything. Such errors are very important, please in future always post them if you want to have a good answer :slight_smile:

Please have a read here:

The part that matches your case is (1105) not (1097)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.