Automate Your Server Platform Using The Leaseweb API

This blog is about using the Leaseweb API to automate the management of your dedicated servers running with Leaseweb – including examples of how to deploy your dedicated servers without even logging in once! While this article focuses solely on dedicated servers, we also have many API calls for specifically managing your cloud(s) at Leaseweb.


Did you know Leaseweb provides access to more than 150 backend features to manage and control your platform? We develop our systems with an ‘API-first’ philosophy, meaning that anything you do via our Customer Portal can also be done via the API (or more!). Many of these functions will help you when deploying a new dedicated server.

Getting Started

Let’s started by exploring what we can do with the API. Full disclaimer: it doesn’t matter if you are a newbie in the world of API calls or an expert – we have documented everything clearly and with plenty of examples to make your life easier. Detailed API information and examples of five different programming languages (including Ruby, PHP and Python) can be found on the Leaseweb developer website. We have also documented how to access the API on our developer website.

Once you have created your API key you can begin exploring different possibilities. Some options we provide that programmatically control your dedicated server platform via our API are:

  • Server management: fully manage your dedicated servers, including OS install, power cycle, hardware scan, etc.
  • Private Network: add or remove servers from the Private Network.
  • Floating IPs: control which servers the Floating IPs are routed to.
  • IP Management: see which IP is assigned to which server, null route IPs, or set reverse DNS entries.


Assume I have a server farm that consists of several dedicated servers, each with its own Internet uplink public IP. The servers are interconnected on the backend using Private Networking, while the Floating IPs are used to quickly redirect traffic to a different server for disaster recovery purposes.

What are some of the basic API calls I could use to control my farm? Let me give you some examples.

(Re)Installation of an Operating System

Using a POST operation, I can request a reinstall of the OS:

I also need to know the different parameters (payload) like serverID and OperatingSystemID, which can be retrieved via different API calls. In the payload area I can specify what the partition layout should be so that the OS will be installed to my exact specifications.

Custom Operating System Image

Alternatively, it is possible to install your own custom installation image using PXE boot while using the API to set the DHCP option. This will include it in the DHCP lease for the server.

Once the server boots, it will get a DHCP lease and will retrieve the installation image from the URL specified in the DHCP option. For more information, check out our Knowledge Base article that explains this feature in more detail.

Other Features

Some other nice features to control the server farm include possibilities to:

  •  Power cycle a server

This will turn the power off and on for the PDU that the server is connected to.

  • Show which IPs (including Floating IPs) are assigned to a server or are null-routed

  • Perform a hardware scan (reboots the server) and get hardware inventory of a server

  • Inspect how much data traffic a server is doing, both up and downstream

Private Networking

Servers in the same metro data center area (which in most cases means Leaseweb data centers that are relatively close to each other) have the possibility to be connected to the Leaseweb Private Network. This backend network provides a secure and unmetered layer-2 connection between all servers with port speeds of up to 10Gbps.

I am able to check if a server is already connected to my assigned Private Network by using the Inspect Private Network operation. This gives me a list (array) of server IDs that are connected.

If needed, I can add or remove a server from the PN or change the port speed.

Floating IPs

Floating IPs provide the possibility to dynamically reroute traffic to a different server (anchor IP). It is possible automate this process using the API. Assuming a Floating IP definition has already been defined and traffic is routed to my first server AnchorIP, I can use a PUT request to change the AnchorIP to my 2nd server.

A good example would be to embed this in a monitoring system. Once the monitoring system detects a ‘server unavailable’, it can automatically redirect traffic to the standby server using this API call.


While this blog is too short to sum up all the possibilities and features that are possible, it should give you some idea of what a powerful mechanism the API can be to automate and manage your environment.