Logo
OpenScaler

Create a New VM

Create a virtual machine with given parameters. If the creation process was started, the response will be sent as server events (SEE), where each event contains the following information :

  • first event of type progress will contain progress info (percentage and message) about last performed action. these events will have
  • the last event will contain the actual response (successful or not), where the event's type (string) is the status of the response (e.g. 200, 400), and the event's data is the response payload.
POST
/v1/vms

Authorization

AuthorizationRequiredBearer <token>

OAuth Authentication

OpenScaler API uses OAuth, a standard for secure authorization. To access the API, obtain a token via the OpenScaler Platform.

Use the access_token in the Authorization header for requests:

Authorization: Bearer <token>

Always keep your token secure and do not share it with anyone.

In: header

Request Body

application/jsonOptional
bodypredefined size | custom size
curl -X POST "https://api.alpha.openscaler.net/v1/vms" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{
    "size": "b-1-500mb-10",
    "project_id": "default",
    "name": "my-example-computer",
    "description": "My example computer (generated from API)",
    "region": "alg1",
    "distro": "debian-13",
    "attached_disks": [
      {
        "sizeGB": 5
      }
    ],
    "ssh_keys": [
      "ssh-rsa ...key1...= user@host",
      "ssh-rsa ...key2...= user@host"
    ],
    "password": "strong_password",
    "cloud_init_user_data": "",
    "sequence_id": 123
  }'

The creation progress will return:

  • a list of progress events containing progress information about the VM, these followed one of the events below
  • 200 event containing the VM information if the VM was created successfully
  • 400 or 500 event containing the error message if the VM creation failed

Note that these events are in plain-text form, not JSON, but will contain the fields described below, for example:

event: progress
data: {"progress": 20.0, "message": "creation on progress"}

"event: 200\ndata: {\"id\": 31, \"sequence_id\": 123, \"name\": \"my-example-computer\", \"user_id\": \"2abb7c25-a2d5-42ac-a776-e8ac5dfb16c3\", \"project_id\": \"default\", \"uuid\": \"cc3ccab2-0ae2-11ef-9136-6a0922f6458b\", \"region\": \"alg1\", \"description\": \"My example computer (generated from API)\", \"distro\": \"debian-13\", \"vcpus\": 1, \"storageGB\": 50, \"memoryMB\": 2048, \"transferGB\": 2048, \"vpc_id\": 20, \"created_at\": \"2024-05-05T13:24:27\", \"updated_at\": \"2024-05-05T13:24:27\", \"size\": \"b-1-500mb-10\", \"state\": \"running\", \"disks\": [{\"is_main_disk\": true, \"capacityBytes\": 53687091200, \"allocationBytes\": 26843545600, \"path\": \"/\", \"target_device\": \"vda\"}, {\"is_main_disk\": false, \"capacityBytes\": 5368709120, \"allocationBytes\": 2684354560, \"path\": \"/mnt/vdc1\", \"target_device\": \"vdc\"}], \"network\": {\"resource_type\": \"vm\", \"mac\": \"02:00:00:00:00:14\", \"private_ip\": \"10.0.20.2\", \"vpc_subnet\": \"10.0.20.0/24\", \"vpc_id\": 20, \"region\": \"alg1\", \"public_ip\": \"10.99.88.77\", \"public_ip_ports\": [{\"description\": \"SSH port for VM 31 (internal port 22)\", \"port\": 9057, \"internal_port\": 22}, {\"description\": \"HTTP port for VM 31 (internal port 80)\", \"port\": 9058, \"internal_port\": 80}, {\"description\": \"HTTPS port for VM 31 (internal port 443)\", \"port\": 9059, \"internal_port\": 443}]}, \"price_hourly\": 0.01786, \"price_monthly\": 12.0}\n"