Virtual Servers API (v2)

The base URL for this API is: https://api.leaseweb.com/cloud/v2

Errors

The API uses standard HTTP status codes to indicate the success or failure of the API call. The response will be JSON. Most APIs use the following format:

{
"errorCode" : "APP00800",
"errorMessage" : "The connection with the DB cannot be established.",
"correlationId" : "550e8400-e29b-41d4-a716-446655440000",
"userMessage" : "Cannot handle your request at the moment. Please try again later.",
"reference" : "http://developer.leaseweb.com/errors/APP00800"
}

Authentication

Authentication for the APIs is required. To authenticate your call, you will need to sent your API key as X-LSW-Auth header.

You can generate API keys in the Customer Portal.

Virtual servers

List virtual servers

Authorizations:
query Parameters
limit
integer
Default: 10

Limit the number of results returned

offset
integer
Default: 0

Return results starting from the given offset

Responses

Request samples

curl --request GET \
  --url 'https://api.leaseweb.com/cloud/v2/virtualServers?limit=SOME_INTEGER_VALUE&offset=SOME_INTEGER_VALUE' \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "virtualServers": [
    ],
  • "_metadata": {
    }
}

Inspect a virtual server

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Responses

Request samples

curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242 \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "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": {
    },
  • "hardware": {
    },
  • "iso": {
    },
  • "ips": [
    ]
}

Update a virtual server

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Request Body schema: application/json
reference
required
string

The reference description for the virtual server

Responses

Request samples

Content type
application/json
{
  • "reference": "My reference"
}

Response samples

Content type
application/json
{
  • "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": {
    },
  • "hardware": {
    },
  • "iso": {
    },
  • "ips": [
    ]
}

Power on

The power on call is an asynchronous call, meaning the power on will be performed as soon as possible.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Responses

Request samples

curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/powerOn \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  • "name": "virtualServers.powerOn",
  • "status": "PENDING",
  • "createdAt": "2016-12-31T01:00:59+00:00"
}

Power off

The power off call is an asynchronous call, meaning the power off will be performed as soon as possible.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Responses

Request samples

curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/powerOff \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  • "name": "virtualServers.powerOff",
  • "status": "PENDING",
  • "createdAt": "2016-12-31T01:00:59+00:00"
}

Reboot

The reboot call is an asynchronous call, meaning the reboot will be performed as soon as possible.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Responses

Request samples

curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/reboot \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  • "name": "virtualServers.reboot",
  • "status": "PENDING",
  • "createdAt": "2016-12-31T01:00:59+00:00"
}

Reinstall

The virtual server will be reinstalled with any supported operating system. The reinstall call is an asynchronous call, meaning the reinstall will be performed as soon as possible. To get the list of supported operating system please check the api documentation for templates.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Request Body schema: application/json
operatingSystemId
required
string

Id of the operating system that needs to be used for reinstallation.

Responses

Request samples

Content type
application/json
{
  • "operatingSystemId": "CENTOS_7_64_PLESK"
}

Response samples

Content type
application/json
{
  • "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
  • "name": "virtualServers.reinstall",
  • "status": "PENDING",
  • "createdAt": "2016-12-31T01:00:59+00:00"
}

Update credentials of a virtual machine

This API call will only update the password displayed for your machine in the customer portal. It will not make any changes to the root password of your machine.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Request Body schema: application/json
username
required
string

Username of the virtual server (mostly root)

password
required
string

Password of the virtual server

type
required
string
Enum: "OPERATING_SYSTEM" "CONTROL_PANEL"

Type of credentials

Responses

Request samples

Content type
application/json
{
  • "username": "root",
  • "password": "my_secret_password",
  • "type": "OPERATING_SYSTEM"
}

Response samples

Content type
application/json
{
  • "errorCode": "ACCESS_DENIED",
  • "errorMessage": "The access token is expired or invalid."
}

List credentials

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 password is not returned in this call, you must use the endpoint to get a credential by the username to retrieve it.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

credentialType
required
string
Enum: "OPERATING_SYSTEM" "CONTROL_PANEL"

Type of credential pair

query Parameters
limit
integer
Default: 10

Limit the number of results returned

offset
integer
Default: 0

Return results starting from the given offset

Responses

Request samples

curl --request GET \
  --url 'https://api.leaseweb.com/cloud/v2/virtualServers/123242/credentials/%7BcredentialType%7D?limit=SOME_INTEGER_VALUE&offset=SOME_INTEGER_VALUE' \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "credentials": [
    ],
  • "_metadata": {
    }
}

Inspect user credentials

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.

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

credentialType
required
string
Enum: "OPERATING_SYSTEM" "CONTROL_PANEL"

Type of credential pair

username
required
string

Name of the user in your server.

Responses

Request samples

curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/credentials/%7BcredentialType%7D/%7Busername%7D \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "type": "OPERATING_SYSTEM",
  • "username": "root",
  • "password": "password123"
}

Inspect datatraffic metrics

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

query Parameters
granularity
string
Enum: "NONE" "5MIN" "HOUR" "DAY" "MONTH" "YEAR"

Specify the preferred interval for each metric. If granularity is omitted from the request, only one metric is returned.

aggregation
string
Value: "SUM"

Aggregate each metric using the given aggregation function.

from
date

Start of date interval in RFC3339 format.

The returned data will include everything up from - and including - the specified date time.

to
date

End of date interval in RFC3339 format.

The returned data will include everything up until - but not including - the specified date time.

Responses

Request samples

curl --request GET \
  --url 'https://api.leaseweb.com/cloud/v2/virtualServers/123242/metrics/datatraffic?granularity=SOME_STRING_VALUE&aggregation=SOME_STRING_VALUE&from=SOME_DATE_VALUE&to=SOME_DATE_VALUE' \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "_metadata": {
    },
  • "metrics": {
    }
}

List templates

Retrieves all the supported operating system templates for the specified virtual server

Authorizations:
path Parameters
virtualServerId
required
string

Id of the virtual server

Responses

Request samples

curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/%7BvirtualServerId%7D/templates \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "_metadata": {
    },
  • "templates": [
    ]
}

List snapshots

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

query Parameters
limit
integer
Default: 10

Limit the number of results returned

offset
integer
Default: 0

Return results starting from the given offset

Responses

Request samples

curl --request GET \
  --url 'https://api.leaseweb.com/cloud/v2/virtualServers/123242/snapshots?limit=SOME_INTEGER_VALUE&offset=SOME_INTEGER_VALUE' \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "snapshots": [
    ],
  • "_metadata": {
    }
}

Create snapshot

To create a snapshot, the VPS must be Running and have a General Purpose (GP) pack

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

Request Body schema: application/json
name
required
string

The snapshot name, starting with letters, containing only letters, numbers and spaces

Responses

Request samples

Content type
application/json
{
  • "name": "Snapshot 1"
}

Response samples

Content type
application/json
{
  • "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
  • "name": "virtualServer.createVMSnapshot",
  • "status": "PENDING",
  • "createdAt": "2023-02-23T15:52:54+00:00"
}

Get snapshot

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

snapshotId
required
string
Example: 8083e330-9888-4ae6-8f11-d372c5a50e63

The snapshot's UUID

Responses

Request samples

curl --request GET \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/snapshots/8083e330-9888-4ae6-8f11-d372c5a50e63 \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "8083e330-9888-4ae6-8f11-d372c5a50e63",
  • "name": "Snapshot 1",
  • "state": "READY",
  • "created_at": "2023-02-24T09:33:01+00:00"
}

Delete snapshot

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

snapshotId
required
string
Example: 8083e330-9888-4ae6-8f11-d372c5a50e63

The snapshot's UUID

Responses

Request samples

curl --request DELETE \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/snapshots/8083e330-9888-4ae6-8f11-d372c5a50e63 \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
  • "name": "virtualServer.deleteVMSnapshot",
  • "status": "PENDING",
  • "createdAt": "2023-02-23T15:52:54+00:00"
}

Restore snapshot

Restore the VPS state (disk and memory) to the snapshot. The VPS must be running in order to have its snapshot restored

Authorizations:
path Parameters
virtualServerId
required
string
Example: 123242

Id of the virtual server

snapshotId
required
string

The snapshot's UUID

Responses

Request samples

curl --request POST \
  --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/snapshots/%7BsnapshotId%7D/restore \
  --header 'x-lsw-auth: REPLACE_KEY_VALUE'

Response samples

Content type
application/json
{
  • "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
  • "name": "virtualServer.restoreVMSnapshot",
  • "status": "PENDING",
  • "createdAt": "2023-02-23T15:52:54+00:00"
}