buy
Edit DNS record

Edit DNS record

Use the following API to edit DNS record.

Parameter

Sample Code

Please refer following sample code for CURL and API.

NOTE : For editing a DNS record for any domain you first need to have index of DNS record , that you can find using the provided API . Where you will get the DNS list of domain. Click here to get the dns_record_index using API. In below screenshot the highlighted index are the index of DNS record that you need to pass in edit_record.

image

NOTE : You need to add the index of DNS record for which you want to edit the DNS record in "edit_record". For instance you want to change the dns record of A record then you will find the index from the above API and you can pass the index in dns_record_index like 1.

curl --insecure -d "edit_record=dns_record_index" -d "name=prefix" -d "domain=domain" -d "ttl=ttl-value" -d "type=dns_type" -d "record=IP"  -u "root:password" -X POST "https://HOSTNAME or SERVER IP:2005/index.php?api=json&act=advancedns&domain=domain"
<?php
$user = 'root';
$pass = 'password';
 
$url = 'https://'.rawurlencode($user).':'.rawurlencode($pass).'@HOSTNAME or SERVER IP:2005/index.php?api=json&act=advancedns';  

$post = array('edit_record' => dns_record_index,
	       'name' => 'prefix',
	       'domain' => 'domain',
	       'ttl' => 'ttl-value',
	       'type' => 'A',
	       'record' => 'IP',
);

// Set the curl parameters 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 

if(!empty($post)){
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
}
// Get response from the server. 
$resp = curl_exec($ch);
// print_r($resp);

// The response will hold a string as per the API response method. In this case its PHP Serialize
$res = json_decode($resp, true);

// // Done ?
if(!empty($res['done'])){
    print_r($res['done']['msg']);
}else{
    print_r($res['error']);
}

Output

Record edited successfully
    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list