Start using our API in 5 minutes.

Learn how to use our API with our quick API guide.

Step 1: Generate your API Key

LeaseWeb offers several different APIs, each using a unique API key to verify your API requests.

In order to access our API, you will need to issue your requests against these URLs:

Step 2: Authenticate your API call

Each API request needs to be authenticated. At this moment each API provides a different method to authenticate your requests.

LeaseWeb API

To authenticate your call, add your API key to the request header `X-Lsw-Auth`.

LeaseWeb CDN API

To use this API you must use the secret key provided in LeaseWebs CDN Control Panel and authenticate at each call.

The algorithm used for authentication is the following:

  1. Get the URI you want to access
  2. Get the current timestamp (Must be in UTC timezone)
  3. sha1(key + timestamp + URI)
  4. Append timestamp to the URL
  5. Append signature to the URL

In PHP, this would look like this:

$secret = 'mySecretKey';
$customer_number = '1234567890';
$zone_id = '100';
$path = '/zones/push/' . $customer_number . '/' . $zone_id;
$time = time();
$signature = sha1($secret.$time.$path);
$full_path = ''.$path.'/'.$time.'/'.$signature;

Step 3: Make your first API call

Now that you know how to authenticate an API call, it is time to make your first test call. In this example, you will retrieve a list of Bare Metal Servers you currently have at LeaseWeb.

To begin, your first request may look like this:

$resource = '/bareMetals/v2/servers';
$apiKey   = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx';
$apiUrl   = '';

$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;

Step 4: Get to know the API

Now that you learned how to use our API, you may want to take a look to our complete API References.