# API: Create new zone

# addDNSZone

Requires DNS Zone editor plugin to be added and active in HostBill. Create new zone. Before creating a DNS zone, we could check to see if one exists first - see "get DNS Zone Details" - to make sure we do not create a zone over the top of one that already exists. Ideally, we should only ever need to complete this action once, per domain.

# Required parameters

Parameter Description
app_id App ID
name Zone name

# Optional parameters

Parameter Description
template_id DNS template ID
ip IP address
client_id Client ID
postaction Zone content, can be import-file, import-axfr, clone or leave empty to add entries manually
axfr_server Nameserver IP, required if postaction = import-axfr
zone_file Standard Zone File, required if postaction = import-file
clone_domain Domain to clone zone content from, required if postaction = clone
replace_record_content Add the parameter to replace record content (i.e. CNAMEs) as well, optional for postaction = clone

# Request

GET /admin/api.php?api_id=API_ID&api_key=API_KEY&call=addDNSZone&app_id=APP_ID&name=NAME

# PHP Samples

$url = 'http://url_to_hb.com/admin/api.php';
$post = [
  'call' => 'addDNSZone',
  'api_id' => $API_ID,
  'api_key' => $API_KEY,
  'app_id' => $APP_ID,
  'name' => $NAME,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$data = curl_exec($ch);
curl_close($ch);

$return = json_decode($data, true);
print_r($return);
include 'class.hbwrapper.php';
HBWrapper::setAPI('http://url_to_hb.com/admin/api.php','API ID','API Key');
$params = [
  'app_id' => $APP_ID,
  'name' => $NAME,
];
$return = HBWrapper::singleton()->addDNSZone($params);
print_r($return);
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = [
  'app_id' => $APP_ID,
  'name' => $NAME,
];
$return = $api->addDNSZone($params);
print_r($return);

# Response

{
    "success": true,
    "zone_id": "3",
    "call": "addDNSZone",
    "server_time": 1622815422,
    "info": [
        "The zone has been created"
    ]
}
Last Updated: 3/31/2025, 2:16:41 PM