LeaseWeb Pay-as you-go Bare Metal

This endpoint describes LeaseWeb’s Pay-as-you-go Bare Metal servers.

Pay-as-you-go Bare Metal Servers are paid by the hour. You can order or destroy a Bare Metal server through our API as described below.

When buying a Pay-as-you-go Bare Metal a server will be added to your account immediately.

Most of the API calls that work for normal Bare Metal and Dedicated Servers also work for Pay-as-you-go Bare Metal Servers.

If you want to find out some more extensive documentation, you can check the Knowledge base.

Please note that:


Instances

List all your Pay-as-you-go instances

curl --request GET \
  --url https://api.leaseweb.com/v1/instances \
  --header 'x-lsw-auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/instances",
  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", "/v1/instances", headers=headers)

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

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

url = URI("https://api.leaseweb.com/v1/instances")

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 Body

  {
  "_metadata": {
    "limit": 10,
    "offset": 0,
    "totalCount": 1
  },
  "instances": [
  {
    "bareMetalId": 1234,
    "customerNumber": "0123456789",
    "model": 111209,
    "pricePerGb": 0.1,
    "pricePerHour": 0.69,
    "startedAt": "2015-08-19T14:18:41+0000"
  }   
  ]
}

To retrieve a list of all of you active (and optionally destroyed) Pay-as-you-go instances send a GET request to /v1/payAsYouGo/bareMetals/instances.

The response will be a JSON object with key instances containing all your purchased Pay-as-you-go servers with the following attributes:

Name Type Description
bareMetalId string The identifier of the Bare Metal resource
customerNumber string Your customer number
model integer The number of the model that you purchased
pricePerGb number Displays the price that is billed per Gb of traffic
pricePerHour number Displays the price that is billed per hour of instance usage
startedAt string String containing the time in which the instance started to run
destroyedAt string (Optional) If the instance is destroyed, shows the time in which was destroyed

Create a new Pay-as-you-go instance

curl --request POST \
  --url https://api.leaseweb.com/v1/instances \
  --header 'x-lsw-auth: 213423-2134234-234234-23424' \
  --data '{\n  "model" : 12345\n}\n'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/instances",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "{\n  \"model\" : 12345\n}\n",
  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")

payload = "{\n  \"model\" : 12345\n}\n"

headers = { 'x-lsw-auth': "213423-2134234-234234-23424" }

conn.request("POST", "/v1/instances", payload, headers)

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

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

url = URI("https://api.leaseweb.com/v1/instances")

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'
request.body = "{\n  \"model\" : 12345\n}\n"

response = http.request(request)
puts response.read_body

To create a new Pay-as-you-go instance, send a POST request to /v1/payAsYouGo/bareMetals/instances. This assigns a Pay-as-you-go instance to your LeaseWeb account. Note that the server is not preinstalled with any operating system.

To install an operating system you can either use our /install API call or our /leases call if you have your own ipxe server (or use our customer portal).

The request must contain the following form parameter:

Name Type Description
model integer The number of the model that you want to purchase

On success the response would be a JSON object with the following attributes:

Name Type Description
bareMetalId string The identifier of the Bare Metal resource
customerNumber string Your customer number
model integer The number of the model that you purchased
pricePerGb number Displays the price that is billed per Gb of traffic
pricePerHour number Displays the price that is billed per hour of instance usage
startedAt string String containing the time in which the instance started to run

Retrieve information about a Pay-as-you-go instance.

curl --request GET \
  --url https://api.leaseweb.com/v1/instances/12345 \
  --header 'x-lsw-auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/instances/12345",
  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", "/v1/instances/12345", headers=headers)

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

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

url = URI("https://api.leaseweb.com/v1/instances/12345")

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 Body

  {
"usage": {
  "from": "2015-10-19T09:44:06+00:00",
  "to": "2015-10-19T09:46:20+00:00",
  "hoursTotal": 1,
  "dataTrafficTotal": 0,
  "hourlyCosts": 0.051,
  "dataTrafficCosts": 0,
  "totalCosts": 0.051
  },
  "bareMetalId": 1234,
  "customerNumber": "0123456789",
  "model": 111209,
  "pricePerGb": 0.1,
  "pricePerHour": 0.69,
    "startedAt": "2015-08-19T14:18:41+0000"
}

To get detailed information about a specific Pay-as-you-go instance, like data traffic usage, send a GET request to /v1/payAsYouGo/bareMetals/instances/{bareMetalId}.

Remark: The first hour of a Pay-as-you-go instance is free of charge, if used for at least 2 hours. Find out more about our billing structure in the Knowledge base.

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

Name Type Description
bareMetalId string The identifier of the Bare Metal resource
customerNumber string Your customer number
model integer The number of the model that you purchased
pricePerGb number Displays the price that is billed per Gb of traffic
pricePerHour number Displays the price that is billed per hour of instance usage
startedAt string String containing the time in which the instance started to run
destroyedAt string (Optional) If the instance is destroyed, shows the time in which was destroyed
usage object Information about the instance relative to the current month (explained below)

The object usage has the following attributes:

Name Type Description
from string Time in which the instance started to run
to string If the instance is terminated, is the same than destroyedAt. Otherwise, returns the time of the request
hoursTotal integer Number of total running hours
dataTrafficTotal number Amount of used data traffic (expressed in Gb)
hourlyCosts number Result of pricePerHour × hoursTotal
dataTrafficCosts number Result of pricePerGb × dataTrafficTotal
totalCosts number Result of hourlyCosts + dataTrafficCosts

Destroy an active Pay-as-you-go instance

curl --request POST \
  --url https://api.leaseweb.com/v1/instances/12345/destroy \
  --header 'x-lsw-auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/instances/12345/destroy",
  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", "/v1/instances/12345/destroy", headers=headers)

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

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

url = URI("https://api.leaseweb.com/v1/instances/12345/destroy")

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

To destroy a specific Pay-as-you-go instance, send a POST request to /v1/payAsYouGo/bareMetals/instances/{bareMetalId}/destroy. This call will immediately start the wiping process and cannot be undone.

Destroying your instance will delete all data. We strongly recommend you to back up all your data before.

On success the reponse will be a HTTP 204 No Content.

Models

List all the models available for ordering

curl --request GET \
  --url https://api.leaseweb.com/v1/models \
  --header 'x-lsw-auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/models",
  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", "/v1/models", headers=headers)

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

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

url = URI("https://api.leaseweb.com/v1/models")

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 Body

  {
  "_metadata": {
    "limit": 0,
    "offset": 0,
    "totalCount": 1
  },
  "models": [
    {
      "case": "HP DL180 G6",
      "count": 1,
      "cpu": {
          "count": 2,
          "label": "Intel Quad Core E5620"
      },
      "hdd": {
          "combinedDiskSize": 2000,
          "disks": [
              {
                  "count": 2,
                  "size": 1000,
                  "total": 2000,
                  "type": "SATA2"
              }
          ],
          "label": "2x1TB SATA2"
      },
      "id": 111209,
      "label": "HP DL180 G6/2x Intel Quad Core E5620/32GB DDR3/2x1TB SATA2",
      "location": "AMS-01",
      "price": 0.051,
      "pricePerGb": 0.1,
      "privateNetwork": true,
      "ram": {
          "amount": 32,
          "label": "32GB DDR3",
          "type": "DDR3"
        }
    }
  ]
}

To retrieve a list of the currently available Pay-as-you-go models, send a GET request to /v1/payAsYouGo/bareMetals/models.

The response will be a JSON object with key models with a list of available Pay-as-you-go models and the following attributes:

Name Type Description
case string Server brand and model
count integer Number of available models of this type
cpu object Object containing processor label and number of CPUs
hdd object Object containing number, size and type of Hard Disk Drive for the current model
id integer Model id
label string Contains all the specifications for the current model
location string Data center where the server is located
price number Price per hour of the server
pricePerGb number Price that would be billed per Gb of traffic
privateNetwork boolean Shows if the current server has Private Network capabilities or not
ram object Object containing amount (in GB) and type of RAM

The cpu object contains the following attributes:

Name Type Description
count integer Number of CPUs
label string CPU brand and model

The ram object contains the following attributes:

Name Type Description
amount integer Number of GBs that the RAM does have
type string Type of RAM
label string Contains all the specifications of the current ram

The hdd object contains the following attributes:

Name Type Description
combinedDiskSize integer Total size (in GBs) from all the disks
disks array Array of objects containing information of hdd
label string Contains all the specifications of the current hdd

The disks array contains objects with the following attributes:

Name Type Description
count integer Number of disks of this type
size integer Size (in GBs) of each disk
type string Type of the disk
total integer Result of count × size

Retrieve information about a single model

curl --request GET \
  --url https://api.leaseweb.com/v1/models/12345 \
  --header 'x-lsw-auth: 213423-2134234-234234-23424'
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://api.leaseweb.com/v1/models/12345",
  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", "/v1/models/12345", headers=headers)

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

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

url = URI("https://api.leaseweb.com/v1/models/12345")

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 Body

  {
  "case": "HP DL180 G6",
  "count": 1,
  "cpu": {
      "count": 2,
      "label": "Intel Quad Core E5620"
  },
  "hdd": {
      "combinedDiskSize": 2000,
      "disks": [
          {
              "count": 2,
              "size": 1000,
              "total": 2000,
              "type": "SATA2"
          }
      ],
      "label": "2x1TB SATA2"
  },
  "id": 111209,
  "label": "HP DL180 G6/2x Intel Quad Core E5620/32GB DDR3/2x1TB SATA2",
  "location": "AMS-01",
  "price": 0,
  "privateNetwork": true,
  "ram": {
      "amount": 32,
      "label": "32GB DDR3",
      "type": "DDR3"
  },
  "unitId": 209
}

To get information about a single Pay-as-you-go model, send a GET request to /v1/payAsYouGo/bareMetals/models/{id}.

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

Name Type Description
case string Server brand and model
count integer Number of available models of this type
cpu object Object containing processor label and number of CPUs
hdd object Object containing number, size and type of Hard Disk Drive for the current model
id integer Model id
label string Contains all the specifications for the current model
location string Data center where the server is located
price number Price per hour of the server
pricePerGb number Price that would be billed per Gb of traffic
privateNetwork boolean Shows if the current server has Private Network capabilities or not
ram object Object containing amount (in GB) and type of RAM

The cpu object contains the following attributes:

Name Type Description
count integer Number of CPUs
label string CPU brand and model

The ram object contains the following attributes:

Name Type Description
amount integer Number of GBs that the RAM does have
type string Type of RAM
label string Contains all the specifications of the current ram

The hdd object contains the following attributes:

Name Type Description
combinedDiskSize integer Total size (in GBs) from all the disks
disks array Array of objects containing information of hdd
label string Contains all the specifications of the current hdd

The disks array contains objects with the following attributes:

Name Type Description
count integer Number of disks of this type
size integer Size (in GBs) of each disk
type string Type of the disk
total integer Result of count × size