Overview
Cloud Server Shared CPU is the ideal cloud on-demand service for testing, development, staging and for those who need to create and destroy cloud machines with on-demand billing, quickly and with optimized costs.
This section delves into the Rest API functionality of the services:
- Cloud Server Shared CPU
- Cloud Server High Memory
- Cloud Server GPU
Create Your First Server via API.
Creating a Virtual Server via API is very easy, and this page has all the information you need to quickly instantiate a virtual Server
In this guide the command line software curl is used to make our calls but any client HTTP client can replace it without problems such as Postman or Bruno
Execute login
As a first step we need to log in on our services and generate a JWT token login. The explanation of what a JWT token is is external to this guide and is not necessary for using our services. It can be thought of as a key that identifies who generated it and who uses it.
To generate it we need to perform the following request:
curl -X POST https://api.seeweb.it/ecs/v2/login \
-H 'Content-Type: application/json' \
-d '{
"username": "*username*",
"password": "*password*"
}'
The response if credentialed, will be similar to the following:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtc2ciOiJXcm9uZyBQbGFjZSBkdWRlPyJ9.vBb9pIUYaxiGtO-7HY6hzBXH-q7L0GJS8stz2VYqb90",
"expire": 1728560902,
"status": "ok"
}
The token in the body of the response is precisely the user's JWT token, and the expire field indicates its expiration
In case you want to know when the token will no longer be valid, you can copy the value of expire and enter it at Unix Timestamp Converter
Or simply use the following Calculator
->
Info
For more information on user management, you can consult Account.
You can also use API-Tokens to authenticate to our services, to do this see API Tokens
Create a Server
Una volta ottenuto il Token JWT è possibile procedere alla creazione, per test creeremo un Server ubuntu di piccola taglia nel datacenter di Frosinone
Obtain Available Plans
As a first step, it is necessary to view and identify the plan of interest and can be done with the following request:
curl -X GET https://api.seeweb.it/ecs/v2/plans \
-H 'Authorization: Bearer *il tuo token*'
The answer will be similar to the following:
{
"status": "ok",
"plans": [
{
"id": 1,
"name": "eCS1",
"cpu": "1",
"ram": "1024",
"disk": "20",
"gpu": "0",
"gpu_label": null,
"hourly_price": 0.019,
"montly_price": 14.0,
"windows": false,
"host_type": "ECS",
"available": true,
"available_regions": [
{
"id": 2,
"location": "it-mi2",
"description": "Milano"
},
{
"id": 3,
"location": "it-fr2",
"description": "Frosinone"
},
{
"id": 6,
"location": "ch-lug1",
"description": "Lugano"
},
{
"id": 7,
"location": "bg-sof1",
"description": "Sofia"
}
]
},
{
"id": 7,
"name": "eCS2",
"cpu": "2",
"ram": "2048",
"disk": "40",
"gpu": "0",
"gpu_label": null,
"hourly_price": 0.032,
"montly_price": 23.0,
"windows": false,
"host_type": "ECS",
"available": true,
"available_regions": [
{
"id": 2,
"location": "it-mi2",
"description": "Milano"
},
{
"id": 3,
"location": "it-fr2",
"description": "Frosinone"
},
{
"id": 6,
"location": "ch-lug1",
"description": "Lugano"
}
]
}
]
}
Obtain available regions
Having identified the plan of interest (in our case eCS1), we can proceed to check its availability in the various datacenters.
curl -X POST https://api.seeweb.it/ecs/v2/regions/availables
-H 'Content-Type: application/json'
-H 'Authorization: Bearer *token*'
-d '{
"plan": "eCS1"
}'
The answer will be similar to the following:
{
"status": "ok",
"regions": [
[
"ch-lug1",
"it-fr2",
"it-mi2",
"bg-sof1"
]
]
}
It is therefore possible to find that the 'eCS1' plan can be activated in the datacenter named 'it-fr2' located in Frosinone Italy.
Obtain available OS
Next, it is necessary to identify an operating system of interest:
curl -X POST https://api.seeweb.it/ecs/v2/images/basics
-H 'Content-Type: application/json'
-H 'Authorization: Bearer *token*'
The answer will be similar to the following:
{
"status": "ok",
"images": [
{
"id": 408,
"name": "debian-9",
"creation_date": "2019-10-02T16:48:18+00:00",
"active_flag": true,
"status": "CD",
"uuid": "a1fa433a-ef1a-4b09-8571-514474847495",
"description": "Debian Linux 9",
"notes": "Debian Linux distribution",
"public": true,
"cloud_image": false,
"so_base": "debian",
"api_version": "v4",
"version": "9"
},
{
"id": 409,
"name": "ubuntu-1604",
"creation_date": "2019-10-02T16:48:18+00:00",
"active_flag": true,
"status": "CD",
"uuid": "87098cfe-9e2c-4020-acd3-c91e46fe46a9",
"description": "Ubuntu Linux 16.04 LTS",
"notes": "Ubuntu Linux distribution",
"public": true,
"cloud_image": false,
"so_base": "ubuntu",
"api_version": "v4",
"version": "1604"
},
{
"id": 509,
"name": "ubuntu-2204",
"creation_date": "2022-09-02T12:38:46+00:00",
"active_flag": true,
"status": "CD",
"uuid": "2d41e9c4-280d-423b-8110-9d14173f601c",
"description": "Ubuntu Linux 22.04 LTS",
"notes": "Ubuntu Linux 22.04 LTS",
"public": true,
"cloud_image": false,
"so_base": "ubuntu",
"api_version": "v4",
"version": "2204"
},
{
"id": 411,
"name": "windows-2012r2",
"creation_date": "2019-10-02T16:48:18+00:00",
"active_flag": true,
"status": "CD",
"uuid": "618c4587-812e-4e9c-bb1c-c7976f671477",
"description": "Windows Server 2012 R2",
"notes": "Windows Server 2012 R2 Standard Edition",
"public": true,
"cloud_image": false,
"so_base": "windows",
"api_version": "v4",
"version": "2012"
}
]
}
In case you want to use the operating system 'Ubuntu Linux 22.04 LTS' you need the code 'ubuntu-2204'
Create a new Server
As a final step, you can proceed to creation:
curl -X POST https://api.seeweb.it/ecs/v2/servers
-H 'Content-Type: application/json'
-H 'Authorization: Bearer *token*'
-d '{
"plan": "eCS1",
"image": "ubuntu-2204",
"location": "it-fr2",
"notes": "my-first-server"
}'
The answer will be similar to the following:
{
"status": "ok",
"action_id": 37430,
"server": {
"name": "ec205827",
"ipv4": "",
"ipv6": "",
"group": null,
"plan": "eCS1",
"plan_size": {
"core": "1",
"ram": "1024",
"disk": "20",
"gpu": "0",
"gpu_label": null,
"host_type": "ECS"
},
"reserved_plans": [],
"is_reserved": false,
"reserved_until": "",
"support": null,
"location": "it-fr2",
"location_label": "Frosinone",
"notes": "my-first-server",
"so": "ubuntu-2204",
"so_label": "Ubuntu Linux 22.04 LTS",
"creation_date": "2024-10-24T14:43:13.150586+00:00",
"deletion_date": null,
"active_flag": false,
"status": "Booting",
"progress": 0,
"api_version": "v4",
"user": "eCS00099"
}
}
Monitor Creation
To monitor the creation of the server you can use the 'action_id' field received in the previous request (in the example: '37430').
You can do this with the following request:
curl -X GET https://api.seeweb.it/ecs/v2/actions/37430 \
-H 'Authorization: Bearer *il tuo token*'
The answer will be similar to the following:
{
"status": "ok",
"action": {
"id": 37430,
"status": "in-progress",
"user": "eCS00099",
"created_at": "2024-10-24T14:43:13.611722+00:00",
"started_at": "2024-10-24T14:43:13.611449+00:00",
"completed_at": null,
"resource": "ec205827",
"resource_type": "ECS",
"type": "create_server",
"progress": 25
}
}
You can monitor the action until the status becomes 'completed':
{
"status": "ok",
"action": {
"id": 37430,
"status": "completed",
"user": "eCS00099",
"created_at": "2024-10-24T14:43:13.611722+00:00",
"started_at": "2024-10-24T14:43:13.611449+00:00",
"completed_at": "2024-10-24T14:52:13.611449+00:00",
"resource": "ec205827",
"resource_type": "ECS",
"type": "create_server",
"progress": 100
}
}
View the Server
You can now view the Server created using the following prompt:
curl -X GET https://api.seeweb.it/ecs/v2/servers/ec205827 \
-H 'Authorization: Bearer *il tuo token*'
And getting:
{
"status": "ok",
"server": {
"name": "ec205827",
"ipv4": "213.171.185.95",
"ipv6": "2001:4b7e:0100:025d::1",
"group": null,
"plan": "eCS1",
"plan_size": {
"core": "1",
"ram": "1024",
"disk": "20",
"gpu": "0",
"gpu_label": null,
"host_type": "ECS"
},
"reserved_plans": [],
"is_reserved": false,
"reserved_until": "",
"support": null,
"location": "it-fr2",
"location_label": "Frosinone",
"notes": "my-first-server",
"so": "ubuntu-2204",
"so_label": "Ubuntu Linux 22.04 LTS",
"creation_date": "2024-10-24T14:51:03.360567+00:00",
"deletion_date": null,
"active_flag": true,
"status": "Booted",
"progress": 100,
"api_version": "v4",
"user": "seeweb_test",
"virttype": "KVM"
}
}
What to do if Server status is 'Customizing'
If you go to check the 'status' of the Server as soon as the action is marked as 'completed' the Server may be still in the 'Customizing' state. This status indicates that the Server has been created but customization is still being done on it, Some functions may therefore not be available, just wait a few minutes and wait for the status to change to 'Booted'.