Introduction

With the Virtual Servers API you can manage your Virtual Servers. Using the REST principle, the API is designed to have predictable resources and responses using standard HTTP Status codes. JSON will be returned in all responses from the API, unless stated otherwise.

Authentication

You authenticate to the Virtual Servers API by providing an API key in your request header. You can generate your API key at the Self Service Center. To use your key include your API key to all API request in a header that looks like the follwing:

X-Lsw-Auth: fasfee-23eqeq-23eeded-23eqed

All API calls must be made over HTTPS. The base URL is: https://api.leaseweb.com/v1/virtualServers


Virtual Servers

The Virtual Servers resources are virtual servers you have running at LeaseWeb. This resource gives you control over each virtual server. You can reboot and shutdown the virtual server via this resource.

List your Virtual servers

curl -X GET -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers"
<?php

$resource = '/virtualServers';
$apiKey   = '****-****-****-****';

$apiUrl   = 'https://api.leaseweb.com/v1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers'
headers = {"X-Lsw-Auth":"****-****-****-****"}

# Send synchronously
try:
  response = requests.get(apiUrl, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "virtualServers":
  [
    {
      "id":156829,
      "serverName":"LSWV030",
      "reference":"vps1",
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-08-14T00:00:00",
        "startDate":"2013-10-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20130814185479"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Bronze - 24x7x4",
      "ipAddresses": [
        {
          "ip": "85.17.214.125",
          "isNulled": false,
          "reverseDNS": "hosted.by.leaseweb.com"
        },
        {
          "ip": "2001:1AF8:4100:A052:0024::",
          "isNulled": false,
          "reverseDNS": "hosted.by.leaseweb.com."
        }
      ],
      "type": {
        "Id": 6,
        "PlatformName": "Virtual Server"
      },
      "state":"Running",
      "template":"Debian 7 64 40",
      "attachedISO":null,
      "macAddress":"06:ae:8c:00:00:1b"
    },
    {
      "id":162342,
      "serverName":"LSWV031",
      "reference":null,
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-10-14T11:53:00",
        "startDate":"2013-11-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20131014189113"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Basic - 24x7x24",
      "ipAddresses":{
        "85.17.254.43":{
          "isNulled":false,
          "reverseDNS":"hosted-by.lea.com"
        }
      },
      "state":"Running",
      "template":"CentOS 6.5 64 40 20140904T1300",
      "attachedISO":null,
      "macAddress":"06:3a:50:00:00:d2"
    },
    {
      "id":162343,
      "serverName":"LSWV032",
      "reference":null,
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-10-14T11:53:00",
        "startDate":"2013-11-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20131014189113"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Basic - 24x7x24",
      "ipAddresses":{
        "85.17.254.85":{
          "isNulled":false,
          "reverseDNS":"hosted-by.leaseweb.com."
        }
      },
      "state":"Running",
      "template":"CentOS 6 64 80 20140904T1300",
      "attachedISO":null,
      "macAddress":"06:0c:3c:00:00:02"
    },
    {
      "id":163834,
      "serverName":"LSWV033",
      "reference":"My Webserver :)",
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-10-28T11:20:00",
        "startDate":"2013-11-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20131028190032"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Basic - 24x7x24",
      "ipAddresses":{
        "85.17.248.190":{
          "isNulled":false,
          "reverseDNS":"hosted-by.cloud.com."
        },
        "2001:1AF8:0018:0018::":{
          "isNulled":false,
          "reverseDNS":""
        }
      },
      "state":"Running",
      "template":"Ubuntu 14.04 amd64 60 GB",
      "attachedISO":null,
      "macAddress":"06:92:4c:00:00:1e"
    },
    {
      "id":165811,
      "serverName":"LSWV034",
      "reference":null,
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-11-14T08:01:00",
        "startDate":"2013-12-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20131114191139"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Basic - 24x7x24",
      "ipAddresses":{
        "85.17.164.222":{
          "isNulled":false,
          "reverseDNS":"hosted-by.leaseweb.com."
        }
      },
      "state":"Running",
      "template":"CentOS 6.5 64 60 20140904T1300",
      "attachedISO":null,
      "macAddress":"06:15:a4:00:00:c4"
    },
    {
      "id":167101,
      "serverName":"LSWV035",
      "reference":null,
      "administrativeInfo":{
        "customerNumber":"1301178860",
        "createdAt":"2013-11-26T09:30:00",
        "startDate":"2013-12-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20131126191866"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,
      "SLA":"Basic - 24x7x24",
      "ipAddresses":{
        "85.17.248.14":{
          "isNulled":false,
          "reverseDNS":"hosted-by.leaseweb.com."
        }
      },
      "state":"Stopped",
      "template":"Windows 2012 R2STD 64 60 20150325T1025",
      "attachedISO":null,
      "macAddress":"06:79:a4:00:00:d3"
    }
  ]
}

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

The response will be a JSON object with key virtualServers containing an array of your virtual servers, each of which contain the following attributes:

Name Type Description
id integer The identifier of the virtual server resource
serverName string The name of the virtual serve
reference string A reference for the virtual server
administrativeInfo object Object containing administrative information
dataTrafficPack string Human-readable string for the datatraffic pack
dataTrafficLimit integer The datatraffic limit for the virtual server (in GB)
SLA string Human readable name of the SLA agreement
ipAddresses object Object containing an array of IP address information
type object Object containing information about the type of virtual server
state string State of the virtual server
template string Template used for the virtual server
attachedISO string Name of the ISO attached to the virtual server
macAddress string The MAC address of the virtual server

The administrativeInfo object contains the following attributes:

Name Type Description
customerNumber string You customer number
createdAt date Date when the virtual server is created
startDate date Contractual date for the virtual server
endDate date Contractual end date for the virtual server
billingFrequency string Applied billing frequency
contractTerm string Applied contract term
orderNumber string The order number for the virtual server

The ipAddresses object consists of array of IPs identified by IP having the following attributes:

Name Type Description
isNulled boolean Whether the IP is nulled or not
reverseDNS string The reverse DNS value for the IP

The type object contains the following attributes:

Name Type Description
id integer The identifier of the virtual server type
PlatformName string Description of the virtual server type

Retrieve a Virtual server

curl -X GET -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers/1234"
<?php

$resource = '/virtualServers/1234';
$apiKey   = '****-****-****-****';

$apiUrl   = 'https://api.leaseweb.com/v1';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers/1234'
headers = {"X-Lsw-Auth":"****-****-****-****"}

# Send synchronously
try:
  response = requests.get(apiUrl, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "virtualServers": [
    {
      "id":156829,
      "serverName":"LSWV030",
      "reference":"vps1",
      "administrativeInfo": {
        "customerNumber":"1301111110",
        "createdAt":"2013-08-14T00:00:00",
        "startDate":"2013-10-01T00:00:00",
        "endDate":null,
        "billingFrequency":"1 month(s)",
        "contractTerm":"1 month(s)",
        "orderNumber":"20130814185479"
      },
      "dataTrafficPack":"Datatraffic - 500 GB (Premium)",
      "dataTrafficLimit":500,"SLA":"Bronze - 24x7x4",
      "ipAddresses": [
        {
          "ip": "85.17.214.125",
          "isNulled": false,
          "reverseDNS": "hosted.by.leaseweb.com"
        },
        {
          "ip": "2001:1AF8:4100:A052:0024::",
          "isNulled": false,
          "reverseDNS": "hosted.by.leaseweb.com."
        }
      ],
      "type": {
        "Id": 6,
        "PlatformName": "Virtual Server"
      },
      "state":"Running",
      "template":"Debian 7 64 40",
      "attachedISO":null,
      "macAddress":"06:ae:8c:00:00:1b"
    }
  ]
}

To get information about a specific virtual server, send a GET request to /v1/virtualServers/{Id}.

The response will be a JSON object with key virtualServers containing the following attributes:

Name Type Description
id integer The identifier of the virtual server resource
serverName string The name of the virtual serve
reference string A reference for the virtual server
administrativeInfo object Object containing administrative information
dataTrafficPack string Human-readable string for the datatraffic pack
dataTrafficLimit integer The datatraffic limit for the virtual server (in GB)
SLA string Human readable name of the SLA agreement
ipAddresses object Object containing an array of IP address information
type object Object containing information about the type of virtual server
state string State of the virtual server
template string Template used for the virtual server
attachedISO string Name of the ISO attached to the virtual server
macAddress string The MAC address of the virtual server

The administrativeInfo object contains the following attributes:

Name Type Description
customerNumber string You customer number
createdAt date Date when the virtual server is created
startDate date Contractual date for the virtual server
endDate date Contractual end date for the virtual server
billingFrequency string Applied billing frequency
contractTerm string Applied contract term
orderNumber string The order number for the virtual server

The ipAddresses object consists of array of IPs identified by IP having the following attributes:

Name Type Description
isNulled boolean Whether the IP is nulled or not
reverseDNS string The reverse DNS value for the IP

The type object contains the following attributes:

Name Type Description
id integer The identifier of the virtual server type
PlatformName string Description of the virtual server type

Power on a Virtual server

curl -X POST -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers/12345/powerOn"
<?php
$resource = '/virtualServers/12345/powerOn';
$apiKey   = '****-****-****-****';
$apiUrl   = 'https://api.leaseweb.com/v1';

$data = array(
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers/12345/powerOn'
headers = {"X-Lsw-Auth":"****-****-****-****"}
data = {}

# Send synchronously
try:
  response = requests.post(apiUrl, data=data, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "asyncjob": {
    "jobid": "cs01.534d6613-9b20-46b8-bd0d-c218f9480d55"
  }
}

To power on the virtual server, send a POST request request to /v1/virtualServers/{Id}/powerOn. Powering on the virtual server 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 folowing attribute:

Name Type Description
jobid string An identifier for the asynchronous power on call

Power off a Virtual server

curl -X POST -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers/12345/powerOff"
<?php
$resource = '/virtualServers/12345/powerOff';
$apiKey   = '****-****-****-****';
$apiUrl   = 'https://api.leaseweb.com/v1';

$data = array(
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers/12345/powerOff'
headers = {"X-Lsw-Auth":"****-****-****-****"}
data = {}

# Send synchronously
try:
  response = requests.post(apiUrl, data=data, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "asyncjob": {
    "jobid": "cs01.534d6613-9b20-46b8-bd0d-c218f9480d55"
  }
}

To power off the virtual server, send a POST request request to /v1/virtualServers/{Id}/powerOff. Powering off the virtual server 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 folowing attribute:

Name Type Description
jobid string An identifier for the asynchronous power off call

Reboot a Virtual Server

curl -X POST -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers/12345/reboot"
<?php
$resource = '/virtualServers/12345/reboot';
$apiKey   = '****-****-****-****';
$apiUrl   = 'https://api.leaseweb.com/v1';

$data = array(
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers/12345/reboot'
headers = {"X-Lsw-Auth":"****-****-****-****"}
data = {}

# Send synchronously
try:
  response = requests.post(apiUrl, data=data, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "asyncjob": {
    "jobid": "cs01.534d6613-9b20-46b8-bd0d-c218f9480d55"
  }
}

To reboot the virtual server, send a POST request request to /v1/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 folowing attribute:

Name Type Description
jobid string An identifier for the asynchronous reboot call

Reinstall a Virtual Server

curl -X POST -H "X-Lsw-Auth: ****-****-****-****" "https://api.leaseweb.com/v1/virtualServers/12345/reinstall"
<?php
$resource = '/virtualServers/12345/reinstall';
$apiKey   = '****-****-****-****';
$apiUrl   = 'https://api.leaseweb.com/v1';

$data = array(
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $apiUrl . $resource);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Lsw-Auth: $apiKey"));
curl_setopt( $ch, CURLOPT_POST, true );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
$output = curl_exec($ch);

echo $output;
import requests

apiUrl = 'https://api.leaseweb.com/v1/virtualServers/12345/reinstall'
headers = {"X-Lsw-Auth":"****-****-****-****"}
data = {}

# Send synchronously
try:
  response = requests.post(apiUrl, data=data, headers=headers)
  content = response.text
  # Success
  print(content)
except requests.exceptions, e:
  # Exception
  print('Exception during request')

Response Body

{
  "asyncjob": {
    "jobid": "cs01.534d6613-9b20-46b8-bd0d-c218f9480d55"
  }
}

To reinstall the virtual server, send a POST request request to /v1/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 folowing attribute:

Name Type Description
jobid string An identifier for the asynchronous reinstall call