The base URL for this API is: https://api.leaseweb.com/cloud/v2
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 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.
limit | integer Default: 10 Limit the number of results returned |
offset | integer Default: 0 Return results starting from the given offset |
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'
{- "virtualServers": [
- {
- "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": {
- "id": "30000778",
- "startsAt": "2016-02-01T00:00:00+0200",
- "endsAt": "2017-01-31T00:00:00+0200",
- "billingCycle": 12,
- "billingFrequency": "MONTH",
- "pricePerFrequency": 4.7,
- "currency": "EUR"
}, - "hardware": {
- "cpu": {
- "cores": 1
}, - "memory": {
- "unit": "MB",
- "amount": 1024
}, - "storage": {
- "unit": "GB",
- "amount": 40
}
}, - "iso": null,
- "ips": [
- {
- "ip": "10.11.116.130",
- "version": 4,
- "type": "PUBLIC"
}
]
}, - {
- "id": "301708",
- "reference": null,
- "customerId": "1301178860",
- "dataCenter": "AMS-01",
- "cloudServerId": null,
- "state": "STOPPED",
- "firewallState": "ENABLED",
- "template": "CentOS 7.0 64 60 20140711T1039",
- "serviceOffering": "M",
- "sla": "Bronze",
- "contract": {
- "id": "30000779",
- "startsAt": "2016-02-01T00:00:00+0200",
- "endsAt": "2017-01-31T00:00:00+0200",
- "billingCycle": 12,
- "billingFrequency": "MONTH",
- "pricePerFrequency": 4.7,
- "currency": "EUR"
}, - "hardware": {
- "cpu": {
- "cores": 2
}, - "memory": {
- "unit": "MB",
- "amount": 2048
}, - "storage": {
- "unit": "GB",
- "amount": 60
}
}, - "iso": {
- "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
- "name": "Knoppix",
- "displayName": "Knoppix"
}, - "ips": [
- {
- "ip": "10.11.116.132",
- "version": 4,
- "type": "PUBLIC"
}
]
}
], - "_metadata": {
- "totalCount": 2,
- "offset": 0,
- "limit": 10
}
}
virtualServerId required | string Example: 123242 Id of the virtual server |
curl --request GET \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242 \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "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": {
- "id": "30000778",
- "startsAt": "2016-02-01T00:00:00+0200",
- "endsAt": "2017-01-31T00:00:00+0200",
- "billingCycle": 12,
- "billingFrequency": "MONTH",
- "pricePerFrequency": 4.7,
- "currency": "EUR"
}, - "hardware": {
- "cpu": {
- "cores": 1
}, - "memory": {
- "unit": "MB",
- "amount": 1024
}, - "storage": {
- "unit": "GB",
- "amount": 40
}
}, - "iso": {
- "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
- "name": "Knoppix",
- "displayName": "Knoppix"
}, - "ips": [
- {
- "ip": "10.11.116.130",
- "version": 4,
- "type": "PUBLIC"
}
]
}
virtualServerId required | string Example: 123242 Id of the virtual server |
reference required | string The reference description for the virtual server |
{- "reference": "My reference"
}
{- "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": {
- "id": "30000778",
- "startsAt": "2016-02-01T00:00:00+0200",
- "endsAt": "2017-01-31T00:00:00+0200",
- "billingCycle": 12,
- "billingFrequency": "MONTH",
- "pricePerFrequency": 4.7,
- "currency": "EUR"
}, - "hardware": {
- "cpu": {
- "cores": 1
}, - "memory": {
- "unit": "MB",
- "amount": 1024
}, - "storage": {
- "unit": "GB",
- "amount": 40
}
}, - "iso": {
- "id": "9eadbe14-69be-4dee-8f56-5ebb23bb3c33",
- "name": "Knoppix",
- "displayName": "Knoppix"
}, - "ips": [
- {
- "ip": "10.11.116.130",
- "version": 4,
- "type": "PUBLIC"
}
]
}
The power on call is an asynchronous call, meaning the power on will be performed as soon as possible.
virtualServerId required | string Example: 123242 Id of the virtual server |
curl --request POST \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/powerOn \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
- "name": "virtualServers.powerOn",
- "status": "PENDING",
- "createdAt": "2016-12-31T01:00:59+00:00"
}
The power off call is an asynchronous call, meaning the power off will be performed as soon as possible.
virtualServerId required | string Example: 123242 Id of the virtual server |
curl --request POST \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/powerOff \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
- "name": "virtualServers.powerOff",
- "status": "PENDING",
- "createdAt": "2016-12-31T01:00:59+00:00"
}
The reboot call is an asynchronous call, meaning the reboot will be performed as soon as possible.
virtualServerId required | string Example: 123242 Id of the virtual server |
curl --request POST \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/reboot \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
- "name": "virtualServers.reboot",
- "status": "PENDING",
- "createdAt": "2016-12-31T01:00:59+00:00"
}
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.
virtualServerId required | string Example: 123242 Id of the virtual server |
operatingSystemId required | string Id of the operating system that needs to be used for reinstallation. |
{- "operatingSystemId": "CENTOS_7_64_PLESK"
}
{- "id": "cs01.237daad0-2aed-4260-b0e4-488d9cd55607",
- "name": "virtualServers.reinstall",
- "status": "PENDING",
- "createdAt": "2016-12-31T01:00:59+00:00"
}
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.
virtualServerId required | string Example: 123242 Id of the virtual server |
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 |
{- "username": "root",
- "password": "my_secret_password",
- "type": "OPERATING_SYSTEM"
}
{- "errorCode": "ACCESS_DENIED",
- "errorMessage": "The access token is expired or invalid."
}
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.
virtualServerId required | string Example: 123242 Id of the virtual server |
credentialType required | string Enum: "OPERATING_SYSTEM" "CONTROL_PANEL" Type of credential pair |
limit | integer Default: 10 Limit the number of results returned |
offset | integer Default: 0 Return results starting from the given offset |
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'
{- "credentials": [
- {
- "type": "OPERATING_SYSTEM",
- "username": "root"
}
], - "_metadata": {
- "totalCount": 1,
- "offset": 0,
- "limit": 10
}
}
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.
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. |
curl --request GET \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/credentials/%7BcredentialType%7D/%7Busername%7D \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "type": "OPERATING_SYSTEM",
- "username": "root",
- "password": "password123"
}
virtualServerId required | string Example: 123242 Id of the virtual server |
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. |
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'
{- "_metadata": {
- "from": "2016-01-01T00:00:00+00:00",
- "to": "2016-01-31T23:59:59+00:00",
- "granularity": "DAY",
- "aggregation": "SUM"
}, - "metrics": {
- "DATATRAFFIC_UP": {
- "unit": "B",
- "values": [
- {
- "timestamp": "2016-01-01T23:59:59+00:00",
- "value": 900
}, - {
- "timestamp": "2016-01-31T23:59:59+00:00",
- "value": 2500
}
]
}, - "DATATRAFFIC_DOWN": {
- "unit": "B",
- "values": [
- {
- "timestamp": "2016-01-01T23:59:59+00:00",
- "value": 90
}, - {
- "timestamp": "2016-01-31T23:59:59+00:00",
- "value": 250
}
]
}
}
}
Retrieves all the supported operating system templates for the specified virtual server
virtualServerId required | string Id of the virtual server |
curl --request GET \ --url https://api.leaseweb.com/cloud/v2/virtualServers/%7BvirtualServerId%7D/templates \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "_metadata": {
- "totalCount": 2,
- "limit": 10,
- "offset": 0
}, - "templates": [
- {
- "id": "WINDOWS_SERVER_2012_R2_STANDARD_64",
- "name": "Windows Server 2012 R2 Standard (64-bit)"
}, - {
- "id": "CENTOS_7_64_PLESK",
- "name": "CentOS 7 (64-bit) Plesk"
}
]
}
virtualServerId required | string Example: 123242 Id of the virtual server |
limit | integer Default: 10 Limit the number of results returned |
offset | integer Default: 0 Return results starting from the given offset |
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'
{- "snapshots": [
- {
- "id": "5ab92117-4801-4f86-ad3a-8c5b12ba1b18",
- "name": "snapshot1",
- "state": "READY",
- "created_at": "2023-02-21T14:44:02+00:00"
}, - {
- "id": "5ab92117-5709-4f86-ad3a-8c5b12ba1b18",
- "name": "snapshot2",
- "state": "READY",
- "created_at": "2023-02-21T14:46:02+00:00"
}
], - "_metadata": {
- "totalCount": 2,
- "offset": 0,
- "limit": 10
}
}
To create a snapshot, the VPS must be Running and have a General Purpose (GP) pack
virtualServerId required | string Example: 123242 Id of the virtual server |
name required | string The snapshot name, starting with letters, containing only letters, numbers and spaces |
{- "name": "Snapshot 1"
}
{- "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
- "name": "virtualServer.createVMSnapshot",
- "status": "PENDING",
- "createdAt": "2023-02-23T15:52:54+00:00"
}
virtualServerId required | string Example: 123242 Id of the virtual server |
snapshotId required | string Example: 8083e330-9888-4ae6-8f11-d372c5a50e63 The snapshot's UUID |
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'
{- "id": "8083e330-9888-4ae6-8f11-d372c5a50e63",
- "name": "Snapshot 1",
- "state": "READY",
- "created_at": "2023-02-24T09:33:01+00:00"
}
virtualServerId required | string Example: 123242 Id of the virtual server |
snapshotId required | string Example: 8083e330-9888-4ae6-8f11-d372c5a50e63 The snapshot's UUID |
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'
{- "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
- "name": "virtualServer.deleteVMSnapshot",
- "status": "PENDING",
- "createdAt": "2023-02-23T15:52:54+00:00"
}
Restore the VPS state (disk and memory) to the snapshot. The VPS must be running in order to have its snapshot restored
virtualServerId required | string Example: 123242 Id of the virtual server |
snapshotId required | string The snapshot's UUID |
curl --request POST \ --url https://api.leaseweb.com/cloud/v2/virtualServers/123242/snapshots/%7BsnapshotId%7D/restore \ --header 'X-LSW-Auth: REPLACE_KEY_VALUE'
{- "id": "2e78c712-ba58-4078-95ad-ba86617c9f54",
- "name": "virtualServer.restoreVMSnapshot",
- "status": "PENDING",
- "createdAt": "2023-02-23T15:52:54+00:00"
}