# API: Get DNS templates

# getDNSTemplates

Get DNS templates for app ID

# Required parameters

Parameter Description
app_id App ID

# Request

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

# PHP Samples

$url = 'http://url_to_hb.com/admin/api.php';
$post = [
  'call' => 'getDNSTemplates',
  'api_id' => $API_ID,
  'api_key' => $API_KEY,
  'app_id' => $APP_ID,
];
$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,
];
$return = HBWrapper::singleton()->getDNSTemplates($params);
print_r($return);
/* Use this method to access HostBill api from HostBill modules */
$api = new ApiWrapper();
$params = [
  'app_id' => $APP_ID,
];
$return = $api->getDNSTemplates($params);
print_r($return);

# Response

{
    "success": true,
    "templates": {
        "1": [
            {
                "template_id": "1",
                "product_id": "19",
                "template": "Default",
                "name": "mail.{domain}",
                "type": "A",
                "content": "192.168.1.1",
                "ttl": "3600",
                "prio": "0",
                "product_name": "PowerDNS REST"
            },
            {
                "template_id": "1",
                "product_id": "19",
                "template": "Default",
                "name": "{domain}",
                "type": "CNAME",
                "content": "mail.{domain}",
                "ttl": "3600",
                "prio": "0",
                "product_name": "PowerDNS REST"
            }
        ],
        "2": [
            {
                "template_id": "2",
                "product_id": "19",
                "template": "Zone 2",
                "name": "test.mail.{domain}",
                "type": "A",
                "content": "{ipv4}",
                "ttl": "3600",
                "prio": "0",
                "product_name": "PowerDNS REST"
            },
            {
                "template_id": "2",
                "product_id": "19",
                "template": "Zone 2",
                "name": "{domain}",
                "type": "MX",
                "content": "example.com.",
                "ttl": "3600",
                "prio": "10",
                "product_name": "PowerDNS REST"
            },
            {
                "template_id": "2",
                "product_id": "19",
                "template": "Zone 2",
                "name": "{domain}",
                "type": "SPF",
                "content": "\"v=spf1 include:mailgun.org ~all.\"",
                "ttl": "3600",
                "prio": "0",
                "product_name": "PowerDNS REST"
            }
        ]
    },
    "call": "getDNSTemplates",
    "server_time": 1705668084
}
Last Updated: 10/7/2024, 2:36:43 PM