/dns/domain_templates/create_template


POST https://api.sitehost.nz/1.0/dns/domain_templates/create_template.json

Creates a template.

Form Parameters

ParameterTypeRequiredDescription
client_idintegerYesThe ID for the client.Example: 1
namestringYesThe template name.Example: New Template
params[Nameserver]stringThe name server.Example: ns1.sitehost.co.nz
params[Email]stringThe email address.Example: example@example.com
params[Refresh]integerThe refresh value.Example: 3600
params[Retry]integerThe retry value.Example: 3600
params[Expire]integerThe expire value.Example: 3600
params[Min]integerThe minimum value.Example: 3600

Code Samples

JavaScript PHP Rails Python
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.0/dns/domain_templates/create_template.json", false);

var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", "1");
data.append("name", "New Template");
data.append("params[Nameserver]", "ns1.sitehost.co.nz");
data.append("params[Email]", "example@example.com");
data.append("params[Refresh]", "3600");
data.append("params[Retry]", "3600");
data.append("params[Expire]", "3600");
data.append("params[Min]", "3600");

xmlHttp.send(data);

var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.0/dns/domain_templates/create_template.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'name' => 'New Template',
'params[Nameserver]' => 'ns1.sitehost.co.nz',
'params[Email]' => 'example@example.com',
'params[Refresh]' => 3600,
'params[Retry]' => 3600,
'params[Expire]' => 3600,
'params[Min]' => 3600,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
require 'net/http'
require 'uri'

uri = URI.parse("https://api.sitehost.nz/1.0/dns/domain_templates/create_template.json")
http = Net::HTTP.new(uri.host, uri.port)
request = Net::HTTP::Post.new(uri.request_uri)

body = {"apikey" => "your_key_here",
"client_id" => 1,
"name" => "New Template",
"params[Nameserver]" => "ns1.sitehost.co.nz",
"params[Email]" => "example@example.com",
"params[Refresh]" => 3600,
"params[Retry]" => 3600,
"params[Expire]" => 3600,
"params[Min]" => 3600,
}
request.set_form_data(body)

response = http.request(request)
import requests
from collections import OrderedDict

uri = 'https://api.sitehost.nz/1.0/dns/domain_templates/create_template.json'

# We need ordered dictionary because parameters have to be in the right order.
# Refer to Developer Notes for more information.
body = OrderedDict()

body['apikey'] = 'your_key_here'
body['client_id'] = 1
body['name'] = 'New Template'
body['params[Nameserver]'] = 'ns1.sitehost.co.nz'
body['params[Email]'] = 'example@example.com'
body['params[Refresh]'] = 3600
body['params[Retry]'] = 3600
body['params[Expire]'] = 3600
body['params[Min]'] = 3600

response = requests.post(uri, data=body)

Response

200:

application/json
{
  "return": {
    "TemplateID": "168"
  },
  "msg": "Successful.",
  "status": true,
  "time": 21.37
}