/server/provision
POST https://api.sitehost.nz/1.3/server/provision.json
Provisions a new server.
Form Parameters
Parameter | Type | Required | Description |
client_id | integer | Yes | The ID for the client to provision the new server for.Example: 1 |
label | string | Yes | A label for the new server.Example: example-label |
location | string | Yes | The code for the location to provision the new server at.Example: |
product_code | string | Yes | The code for the product to use for the new server.Example: CLDCON1 |
image | string | Yes | The image to use for the new server.Example: ubuntu-trusty |
params[name] | string | The name to give the new server. This will be generated automatically when not passed.Example: example | |
params[ipv4][0] | string | The IPv4 addresses to assign to the new server. This parameter accepts one or more values in the format of params[ipv4][0]=x, params[ipv4][1]=y. Alternatively, simply pass the string 'auto' to automatically assign an IPv4 address.Example: auto | |
params[ipv6][0] | string | The IPv6 addresses to assign to the new server. This parameter accepts one or more values in the format of params[ipv6][0]=x, params[ipv6][1]=y. Alternatively, simply pass the string 'auto' to automatically assign an IPv6 address.Example: auto | |
params[ssh_keys][0] | string | The SSH keys to load onto the new server. This parameter accepts one or more values in the format of params[ssh_keys][0]=x, params[ssh_keys][1]=y.Example: ssh-rsa AAAAB3NzaC1yc2EAAA... user@host | |
params[contact_id] | string | The ID for the contact who is provisioning the server.Example: 3 | |
params[backup] | string | Specifies whether or not to add an automatic backup subscription for the new server. 0 for no and 1 for yesExample: 1 | |
params[send_email] | string | Specifies whether or not to send the provision email. 0 for no and 1 for yesExample: 1 |
Code Samples
JavaScript PHP Rails Pythonvar xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "https://api.sitehost.nz/1.3/server/provision.json", false);
var data = new FormData();
data.append("apikey", "your_key_here");
data.append("client_id", "1");
data.append("label", "example-label");
data.append("location", "");
data.append("product_code", "CLDCON1");
data.append("image", "ubuntu-trusty");
data.append("params[name]", "example");
data.append("params[ipv4][0]", "auto");
data.append("params[ipv6][0]", "auto");
data.append("params[ssh_keys][0]", "ssh-rsa AAAAB3NzaC1yc2EAAA... user@host");
data.append("params[contact_id]", "3");
data.append("params[backup]", "1");
data.append("params[send_email]", "1");
xmlHttp.send(data);
var response = xmlHttp.responseText;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.sitehost.nz/1.3/server/provision.json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$body = array(
'apikey' => 'your_key_here',
'client_id' => 1,
'label' => 'example-label',
'location' => '',
'product_code' => 'CLDCON1',
'image' => 'ubuntu-trusty',
'params[name]' => 'example',
'params[ipv4][0]' => 'auto',
'params[ipv6][0]' => 'auto',
'params[ssh_keys][0]' => 'ssh-rsa AAAAB3NzaC1yc2EAAA... user@host',
'params[contact_id]' => '3',
'params[backup]' => '1',
'params[send_email]' => '1',
);
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.3/server/provision.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,
"label" => "example-label",
"location" => "",
"product_code" => "CLDCON1",
"image" => "ubuntu-trusty",
"params[name]" => "example",
"params[ipv4][0]" => "auto",
"params[ipv6][0]" => "auto",
"params[ssh_keys][0]" => "ssh-rsa AAAAB3NzaC1yc2EAAA... user@host",
"params[contact_id]" => "3",
"params[backup]" => "1",
"params[send_email]" => "1",
}
request.set_form_data(body)
response = http.request(request)
import requests
from collections import OrderedDict
uri = 'https://api.sitehost.nz/1.3/server/provision.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['label'] = 'example-label'
body['location'] = ''
body['product_code'] = 'CLDCON1'
body['image'] = 'ubuntu-trusty'
body['params[name]'] = 'example'
body['params[ipv4][0]'] = 'auto'
body['params[ipv6][0]'] = 'auto'
body['params[ssh_keys][0]'] = 'ssh-rsa AAAAB3NzaC1yc2EAAA... user@host'
body['params[contact_id]'] = '3'
body['params[backup]'] = '1'
body['params[send_email]'] = '1'
response = requests.post(uri, data=body)
Response
200:application/json
{
"return": {
"job_id": "2251119",
"name": "server-name",
"password": "4d6bxsnx",
"ips": [
"192.168.11.108"
],
"server_id": "11353"
},
"msg": "Successful",
"status": true
}
"return": {
"job_id": "2251119",
"name": "server-name",
"password": "4d6bxsnx",
"ips": [
"192.168.11.108"
],
"server_id": "11353"
},
"msg": "Successful",
"status": true
}