Virtual Servers API v2

Virtual Servers

The Virtual Servers endpoints provide you the ability to retrieve information and interact with the Virtual Servers that you have at LeaseWeb. This resource gives you control over each virtual server. You can power on, power off, reboot, reinstall and retrieve administrative information from all of your virtual servers via this resource.

GEThttps://api.leaseweb.com/cloud/v2/virtualServers
REQUEST EXAMPLE
curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("GET", "/cloud/v2/virtualServers", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "virtualServers": [
    {
      "id": "222903",
      "reference": "Web server",
      "customerId": "1301178860",
      "dataCenter": "AMS-01",
      "cloudServerId": null,
      "state": "STOPPED",
      "firewallState": "DISABLED",
      "template": "Ubuntu 14.04 64 40 20140707T1340",
      "serviceOffering": "S",
      "sla": "Bronze",
      "contract": {
        "id": "30000778",
        "startsAt": "2016-02-01T00:00:00+0200",
        "endsAt": "2017-01-31T00:00:00+0200",
        "billingCycle": 12,
        "billingFrequency": "MONTH",
        "pricePerFrequency": 4.7,
        "currency": "EUR"
      },
      "hardware": {
        "cpu": {
          "cores": 1
        },
        "memory": {
          "unit": "MB",
          "amount": 1024
        },
        "storage": {
          "unit": "GB",
          "amount": 40
        }
      },
      "iso": null,
      "ips": [
        {
          "ip": "10.11.116.130",
          "version": 4,
          "type": "PUBLIC"
        }
      ]
    },
    {
      "id": "301708",
      "reference": null,
      "customerId": "1301178860",
      "dataCenter": "AMS-01",
      "cloudServerId": null,
      "state": "STOPPED",
      "firewallState": "ENABLED",
      "template": "CentOS 7.0 64 60 20140711T1039",
      "serviceOffering": "M",
      "sla": "Bronze",
      "contract": {
        "id": "30000779",
        "startsAt": "2016-02-01T00:00:00+0200",
        "endsAt": "2017-01-31T00:00:00+0200",
        "billingCycle": 12,
        "billingFrequency": "MONTH",
        "pricePerFrequency": 4.7,
        "currency": "EUR"
      },
      "hardware": {
        "cpu": {
          "cores": 2
        },
        "memory": {
          "unit": "MB",
          "amount": 2048
        },
        "storage": {
          "unit": "GB",
          "amount": 60
        }
      },
      "iso": {
        "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
        "name": "Knoppix",
        "displayName": "Knoppix"
      },
      "ips": [
        {
          "ip": "10.11.116.132",
          "version": 4,
          "type": "PUBLIC"
        }
      ]
    }
  ],
  "_metadata": {
    "totalCount": 2,
    "offset": 0,
    "limit": 10
  }
}

GETList your Virtual Servers

To retrieve a list of all of your virtual servers, send a GET request to /cloud/v2/virtualServers.

The following query parameters are available:

Name Type Required Description Example
limit integer No Maximum amount of virtual servers to be retrieved, for pagination purposes. 10
offset integer No Result offset, for pagination purposes. 0

The response will be a JSON object with following keys:

Name Type Description
virtualServers object Array of your virtual servers.
_metadata object Metadata of the request, containing the total number of virtual servers in the collection, the limit and the offset.

The virtualServers object consists of array of virtualServer having the following attributes:

Name Type Description
id string Identifier of the virtual server resource.
reference string The reference description for the virtual server.
customerId string Your customer identifier.
dataCenter string Data center code where the virtual server is located.
cloudServerId string Cloud Server identifier (in case your virtual server is associated to one).
state string State of your virtual server. Possible values are: RUNNING, STOPPED, STARTING, STOPPING, UNKNOWN.
firewallState string State of the firewall of the virtual server. Possible values are: DISABLED, ENABLED, UNKNOWN.
template string Name of the Operating System template of your virtual server.
serviceOffering string Service Offering of your virtual server. Possible values are: S, M, L, XL.
sla string Service Level Agreement of your virtual server.
contract object Virtual server contract information.
hardware object Virtual server hardware information.
iso object ISO information if there is an ISO image attached to the virtual server, otherwise the value will be null.
ips object Information about the virtual server's IP address(es).
networkTraffic object Network traffic associated to the virtual server.

The contract object contains the following attributes:

Name Type Description
id string Virtual server contract identifier.
startsAt date Contractual date for the virtual server.
endsAt date Contractual end date for the virtual server.
billingCycle integer Applied billing cycle.
billingFrequency string Applied billing frequency.
currency string Currency of the contract according to ISO-4217.

The hardware object contains the following attributes:

Name Type Description
cpu object CPU information.
memory object Memory information.
storage object Storage information.

The cpu object contains the following attributes:

Name Type Description
cores integer Number of cores that the virtual server has.

The memory object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of memory that the virtual server has.

The storage object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of storage that the virtual server has.

The iso object contains the following attributes:

Name Type Description
id string ISO identifier.
name string ISO name.
displayName string ISO friendly name.

The ips object consists of array of ip objects having the following attributes:

Name Type Description
ip string IP address
version integer IP address version. Possible values are: 4, 6.
type string IP type. Possible values are: PUBLIC, PRIVATE.

The networkTraffic object contains the following attributes:

Name Type Description
type string Type of network traffic. Possible values are: DATATRAFFIC.
trafficType string Type of traffic. Possible values are: VOLUME, PREMIUM.
datatrafficUnit string Unit in which the data traffic limit is represented.
datatrafficLimit integer Data traffic limit for the virtual server.

The _metadata object contains the following attributes:

Name Type Description
totalCount integer Total amount of virtual servers that were found.
limit integer Maximum amount of virtual servers that will be included in the virtualServers array.
offset integer Offset of the request.

The following query string parameters are available:

Name Example Description
limit about limits
offset offset
GEThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined
REQUEST EXAMPLE
curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("GET", "/cloud/v2/virtualServers/undefined", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "id": "222903",
  "reference": "Web server",
  "customerId": "1301178860",
  "dataCenter": "AMS-01",
  "cloudServerId": null,
  "state": "STOPPED",
  "firewallState": "DISABLED",
  "template": "Ubuntu 14.04 64 40 20140707T1340",
  "serviceOffering": "S",
  "sla": "Bronze",
  "contract": {
    "id": "30000778",
    "startsAt": "2016-02-01T00:00:00+0200",
    "endsAt": "2017-01-31T00:00:00+0200",
    "billingCycle": 12,
    "billingFrequency": "MONTH",
    "pricePerFrequency": 4.7,
    "currency": "EUR"
  },
  "hardware": {
    "cpu": {
      "cores": 1
    },
    "memory": {
      "unit": "MB",
      "amount": 1024
    },
    "storage": {
      "unit": "GB",
      "amount": 40
    }
  },
  "iso": {
    "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
    "name": "Knoppix",
    "displayName": "Knoppix"
  },
  "ips": [
    {
      "ip": "10.11.116.130",
      "version": 4,
      "type": "PUBLIC"
    }
  ]
}

GETRetrieve a Virtual Server

To get information about a specific virtual server, send a GET request to /cloud/v2/virtualServers/{id}.

Name Type Description
id string Identifier of the virtual server resource.
reference string The reference description for the virtual server.
customerId string Your customer identifier.
dataCenter string Data center code where the virtual server is located.
cloudServerId string Cloud Server identifier (in case your virtual server is associated to one).
state string State of your virtual server. Possible values are: RUNNING, STOPPED, STARTING, STOPPING, UNKNOWN.
firewallState string State of the firewall of the virtual server. Possible values are: DISABLED, ENABLED, UNKNOWN.
template string Name of the Operating System template of your virtual server.
serviceOffering string Service Offering of your virtual server. Possible values are: S, M, L, XL.
sla string Service Level Agreement of your virtual server.
contract object Virtual server contract information.
hardware object Virtual server hardware information.
iso object ISO information if there is an ISO image attached to the virtual server, otherwise the value will be null.
ips object Information about the virtual server's IP address(es).
networkTraffic object Network traffic associated to the virtual server.

The contract object contains the following attributes:

Name Type Description
id string Virtual server contract identifier.
startsAt date Contractual date for the virtual server.
endsAt date Contractual end date for the virtual server.
billingCycle integer Applied billing cycle.
billingFrequency string Applied billing frequency.
currency string Currency of the contract according to ISO-4217.

The hardware object contains the following attributes:

Name Type Description
cpu object CPU information.
memory object Memory information.
storage object Storage information.

The cpu object contains the following attributes:

Name Type Description
cores integer Number of cores that the virtual server has.

The memory object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of memory that the virtual server has.

The storage object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of storage that the virtual server has.

The iso object contains the following attributes:

Name Type Description
id string ISO identifier.
name string ISO name.
displayName string ISO friendly name.

The ips object consists of array of ip objects having the following attributes:

Name Type Description
ip string IP address
version integer IP address version. Possible values are: 4, 6.
type string IP type. Possible values are: PUBLIC, PRIVATE.

The networkTraffic object contains the following attributes:

Name Type Description
type string Type of network traffic. Possible values are: DATATRAFFIC.
trafficType string Type of traffic. Possible values are: VOLUME, PREMIUM.
datatrafficUnit string Unit in which the data traffic limit is represented.
datatrafficLimit integer Data traffic limit for the virtual server.
PUThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined
REQUEST EXAMPLE
curl --request PUT \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424' \
  --header 'content-type: application/json' \
  --data '{
  "reference": "My reference"
}'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "PUT",
  CURLOPT_POSTFIELDS => "{  \"reference\": \"My reference\"}",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424",
    "content-type: application/json"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

payload = "{  \"reference\": \"My reference\"}"

headers = {
    'X-LSW-Auth': "213423-2134234-234234-23424",
    'content-type': "application/json"
    }

conn.request("PUT", "/cloud/v2/virtualServers/undefined", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'
request["content-type"] = 'application/json'
request.body = "{  \"reference\": \"My reference\"}"

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "id": "222903",
  "reference": "Web server",
  "customerId": "1301178860",
  "dataCenter": "AMS-01",
  "cloudServerId": null,
  "state": "STOPPED",
  "firewallState": "DISABLED",
  "template": "Ubuntu 14.04 64 40 20140707T1340",
  "serviceOffering": "S",
  "sla": "Bronze",
  "contract": {
    "id": "30000778",
    "startsAt": "2016-02-01T00:00:00+0200",
    "endsAt": "2017-01-31T00:00:00+0200",
    "billingCycle": 12,
    "billingFrequency": "MONTH",
    "pricePerFrequency": 4.7,
    "currency": "EUR"
  },
  "hardware": {
    "cpu": {
      "cores": 1
    },
    "memory": {
      "unit": "MB",
      "amount": 1024
    },
    "storage": {
      "unit": "GB",
      "amount": 40
    }
  },
  "iso": {
    "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
    "name": "Knoppix",
    "displayName": "Knoppix"
  },
  "ips": [
    {
      "ip": "10.11.116.130",
      "version": 4,
      "type": "PUBLIC"
    }
  ]
}

PUTUpdate a Virtual Server

To update your virtual server, send a PUT request to /cloud/v2/virtualServers/{id}.

The request must have the following attributes in the body:

Name Type Description
reference string The reference description for the virtual server.

The response will be a virtual server object, which contains the following fields:

Name Type Description
id string Identifier of the virtual server resource.
reference string The reference description for the virtual server.
customerId string Your customer identifier.
dataCenter string Data center code where the virtual server is located.
cloudServerId string Cloud Server identifier (in case your virtual server is associated to one).
state string State of your virtual server. Possible values are: RUNNING, STOPPED, STARTING, STOPPING, UNKNOWN.
firewallState string State of the firewall of the virtual server. Possible values are: DISABLED, ENABLED, UNKNOWN.
template string Name of the Operating System template of your virtual server.
serviceOffering string Service Offering of your virtual server. Possible values are: S, M, L, XL.
sla string Service Level Agreement of your virtual server.
contract object Virtual server contract information.
hardware object Virtual server hardware information.
iso object ISO information if there is an ISO image attached to the virtual server, otherwise the value will be null.
ips object Information about the virtual server's IP address(es).
networkTraffic object Network traffic associated to the virtual server.

The contract object contains the following attributes:

Name Type Description
id string Virtual server contract identifier.
startsAt date Contractual date for the virtual server.
endsAt date Contractual end date for the virtual server.
billingCycle integer Applied billing cycle.
billingFrequency string Applied billing frequency.
currency string Currency of the contract according to ISO-4217.

The hardware object contains the following attributes:

Name Type Description
cpu object CPU information.
memory object Memory information.
storage object Storage information.

The cpu object contains the following attributes:

Name Type Description
cores integer Number of cores that the virtual server has.

The memory object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of memory that the virtual server has.

The storage object contains the following attributes:

Name Type Description
unit string Unit in which the amount attribute is measured.
amount integer Amount of storage that the virtual server has.

The iso object contains the following attributes:

Name Type Description
id string ISO identifier.
name string ISO name.
displayName string ISO friendly name.

The ips object consists of array of ip objects having the following attributes:

Name Type Description
ip string IP address
version integer IP address version. Possible values are: 4, 6.
type string IP type. Possible values are: PUBLIC, PRIVATE.

The networkTraffic object contains the following attributes:

Name Type Description
type string Type of network traffic. Possible values are: DATATRAFFIC.
trafficType string Type of traffic. Possible values are: VOLUME, PREMIUM.
datatrafficUnit string Unit in which the data traffic limit is represented.
datatrafficLimit integer Data traffic limit for the virtual server.
POSThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOn
REQUEST EXAMPLE
curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOn \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOn",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("POST", "/cloud/v2/virtualServers/undefined/powerOn", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOn")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
202 Accepted
{
  "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  "name": "virtualServers.powerOn",
  "status": "PENDING",
  "createdAt": "2016-12-31T01:00:59+00:00"
}

POSTPower on

To power on the virtual server, send a POST request request to /cloud/v2/virtualServers/{id}/powerOn. The power on call is an asynchronous call, meaning the power on will be performed as soon as possible.

The response will be a HTTP 202 Accepted with a JSON object containing the following attributes:

Name Type Description
id string Identifier of the job.
name string Friendly name of the job.
status string Status of the job. Possible values are: PENDING, COMPLETED.
createdAt date Date when the job was created.
POSThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOff
REQUEST EXAMPLE
curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOff \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOff",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("POST", "/cloud/v2/virtualServers/undefined/powerOff", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/powerOff")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
202 Accepted
{
  "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  "name": "virtualServers.powerOff",
  "status": "PENDING",
  "createdAt": "2016-12-31T01:00:59+00:00"
}

POSTPower off

To power off the virtual server, send a POST request request to /cloud/v2/virtualServers/{id}/powerOff. The power off call is an asynchronous call, meaning the power off will be performed as soon as possible.

The response will be a HTTP 202 Accepted with a JSON object containing the following attributes:

Name Type Description
id string Identifier of the job.
name string Friendly name of the job.
status string Status of the job. Possible values are: PENDING, COMPLETED.
createdAt date Date when the job was created.
POSThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/reboot
REQUEST EXAMPLE
curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reboot \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reboot",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("POST", "/cloud/v2/virtualServers/undefined/reboot", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reboot")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
202 Accepted
{
  "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  "name": "virtualServers.reboot",
  "status": "PENDING",
  "createdAt": "2016-12-31T01:00:59+00:00"
}

POSTReboot

To reboot the virtual server, send a POST request request to /cloud/v2/virtualServers/{id}/reboot. The reboot call is an asynchronous call, meaning the reboot will be performed as soon as possible.

The response will be a HTTP 202 Accepted with a JSON object containing the following attributes:

Name Type Description
id string Identifier of the job.
name string Friendly name of the job.
status string Status of the job. Possible values are: PENDING, COMPLETED.
createdAt date Date when the job was created.
POSThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/reinstall
REQUEST EXAMPLE
curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reinstall \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reinstall",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("POST", "/cloud/v2/virtualServers/undefined/reinstall", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/reinstall")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
202 Accepted
{
  "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  "name": "virtualServers.reinstall",
  "status": "PENDING",
  "createdAt": "2016-12-31T01:00:59+00:00"
}

POSTReinstall

To reinstall the virtual server, send a POST request request to /cloud/v2/virtualServers/{id}/reinstall. The virtual server will be reinstalled with the same operating system that it currently has. The reinstall call is an asynchronous call, meaning the reinstall will be performed as soon as possible.

The response will be a HTTP 202 Accepted with a JSON object containing the following attributes:

Name Type Description
id string Identifier of the job.
name string Friendly name of the job.
status string Status of the job. Possible values are: PENDING, COMPLETED.
createdAt date Date when the job was created.
GEThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined
REQUEST EXAMPLE
curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("GET", "/cloud/v2/virtualServers/undefined/credentials/undefined", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "credentials": [
    {
      "type": "OPERATING_SYSTEM",
      "username": "root"
    }
  ],
  "_metadata": {
    "totalCount": 1,
    "offset": 0,
    "limit": 10
  }
}

GETList the credentials

To retrieve a list of all of your credentials, send a GET request to /cloud/v2/virtualServers/{id}/credentials/{credentialType}. Please note that you will only be able to retrieve the last password that we configured in your server or control panel. If you changed it, the information retrieved by this API call will not work.

The following table explains the possible values that must be used in the URL parameters:

Name Type Description
credentialType string Type of credential pair. Possible values are OPERATING_SYSTEM, CONTROL_PANEL.

The following query parameters are available:

Name Type Required Description Example
limit integer No Maximum amount of credentials to be retrieved, for pagination purposes. 10
offset integer No Result offset, for pagination purposes. 0

The response will be a JSON object with following keys:

Name Type Description
credentials object Array of your credentials.
_metadata object Metadata of the request, containing the total number of credentials in the collection, the limit and the offset.

The credentials object consists of array of credentials having the following attributes:

Name Type Description
type string Type of credential pair. Possible values are OPERATING_SYSTEM, CONTROL_PANEL.
username string Name of the user in your server.

Please note that the password is not returned in this call, you must use the endpoint to get a credential by the username to retrieve it.

The _metadata object contains the following attributes:

Name Type Description
totalCount integer Total amount of credentials that were found.
limit integer Maximum amount of credentials that will be included in the credentials array.
offset integer Offset of the request.
GEThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined/undefined
REQUEST EXAMPLE
curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined/undefined \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined/undefined",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("GET", "/cloud/v2/virtualServers/undefined/credentials/undefined/undefined", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/credentials/undefined/undefined")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "type": "OPERATING_SYSTEM",
  "username": "root",
  "password": "password123"
}

GETGet the credentials of a user

To get information about a specific credentials, send a GET request to /cloud/v2/virtualServers/{id}/credentials/{credentialType}/{username}. Please note that you will only be able to retrieve the last password that we configured in your server or control panel. If you changed it, the information retrieved by this API call will not work.

Name Type Description
type string Type of credential pair. Possible values are OPERATING_SYSTEM, CONTROL_PANEL.
username string Name of the user in your server.
password string Password associated to the username.
GEThttps://api.leaseweb.com/cloud/v2/virtualServers/undefined/metrics/datatraffic
REQUEST EXAMPLE
curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/undefined/metrics/datatraffic \
  --header 'X-LSW-Auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/cloud/v2/virtualServers/undefined/metrics/datatraffic",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "X-LSW-Auth: 213423-2134234-234234-23424"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import http.client

conn = http.client.HTTPSConnection("api.leaseweb.com")

headers = { 'X-LSW-Auth': "213423-2134234-234234-23424" }

conn.request("GET", "/cloud/v2/virtualServers/undefined/metrics/datatraffic", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.leaseweb.com/cloud/v2/virtualServers/undefined/metrics/datatraffic")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["X-LSW-Auth"] = '213423-2134234-234234-23424'

response = http.request(request)
puts response.read_body
RESPONSE EXAMPLE
200 OK
{
  "_metadata": {
    "from": "2016-01-01T00:00:00+00:00",
    "to": "2016-01-31T23:59:59+00:00",
    "granularity": "DAY",
    "aggregation": "SUM"
  },
  "metrics": {
    "DATATRAFFIC_UP": {
      "unit": "B",
      "values": [
        {
          "timestamp": "2016-01-01T23:59:59+00:00",
          "value": 900
        },
        {
          "timestamp": "2016-01-31T23:59:59+00:00",
          "value": 2500
        }
      ]
    },
    "DATATRAFFIC_DOWN": {
      "unit": "B",
      "values": [
        {
          "timestamp": "2016-01-01T23:59:59+00:00",
          "value": 90
        },
        {
          "timestamp": "2016-01-31T23:59:59+00:00",
          "value": 250
        }
      ]
    }
  }
}

GETGet the datatraffic metrics

To retrieve a list of all of your datatraffic metrics, send a GET request to /cloud/v2/virtualServers/{id}/metrics/datatraffic.

The following query parameters are available:

Name Type Required Description
granularity string No Granularity of the request. Possible values are: NONE, 5MIN, HOUR, DAY, MONTH, YEAR.
aggregation string Yes Aggregation method of the returned values. Possible values are: SUM.
from date Yes Start of date interval in RFC3339 format.
to date Yes End of date interval in RFC3339 format.

The response will be a JSON object with following keys:

Name Type Description
metrics object Array of your datatraffic metrics.
_metadata object Metadata of the request.

The metrics object consists of array of metric having the following attributes:

Name Type Description
DATATRAFFIC_UP object Outgoing datatraffic metrics.
DATATRAFFIC_DOWN object Incoming datatraffic metrics.

The DATATRAFFIC_UP object contains the following attributes:

Name Type Description
unit string Unit in which the metric is measured.
values object Array of value objects that contains the metric measurements.

The DATATRAFFIC_DOWN object contains the following attributes:

Name Type Description
unit string Unit in which the metric is measured.
values object Array of value objects that contains the metric measurements.

The value object contains the following attributes:

Name Type Description
timestamp date Date where the metric was measured.
value object Metric value.

The _metadata object contains the following attributes:

Name Type Description
from date Start date (inclusive) in format RFC3339.
to date End timestamp (exclusive) in format RFC3339.
granularity string Granularity of the request. Possible values are: NONE, 5MIN, HOUR, DAY, MONTH, YEAR.
aggregation string Aggregation method of the returned values. Possible values are: SUM.

The following query string parameters are available:

Name Example Description
granularity Specify the preferred interval for each metric. If granularity is omitted from the request, only one metric is returned. (Allowed values: NONE,5MIN,HOUR,DAY,MONTH,YEAR)
aggregation Aggregate each metric using the given aggregation function. (Allowed values: SUM)
from 2016-01-01T00:00:00+00:00 Start of date interval in RFC3339 format. The returned data will include everything up from - and including - the specified date time.
to 2016-01-02T00:00:00+00:00 End of date interval in RFC3339 format. The returned data will include everything up until - but not including - the specified date time.