VM Creation API
Complete guide to creating virtual machines in VergeOS, including basic creation, recipe-based configurations, drives, devices, and network interfaces
This guide covers creating virtual machines in VergeOS, from basic VM creation through adding drives, devices, and network interfaces. The VergeOS API provides comprehensive endpoints for VM creation and hardware configuration.
Stage: VM Creation (1 of 4) Input: API credentials, cluster info, VM specifications Output: VM key (42) + Machine key (54) Next: Use keys for power management Common Next Steps:
Power on VM →
VM Power ManagementConfigure settings →
VM ConfigurationAdvanced operations →
VM Advanced Operations
This Document Helps With
"How to create a VM via API"
"Adding drives during VM setup"
"Attaching GPU/PCI devices to VMs"
"VM creation with cloud-init"
"Understanding VM vs machine keys"
"Setting up network interfaces for new VMs"
"Recipe-based VM provisioning"
"Bulk VM creation automation"
"Infrastructure as code VM deployment"
Quick Reference
Primary Endpoints
Create VM:
POST /api/v4/vmsAdd Drive:
POST /api/v4/machine_drivesAdd Device:
POST /api/v4/machine_devicesAdd NIC:
POST /api/v4/machine_nics
Key Parameters
name: VM identifier (required)cluster: Target cluster IDmachine: Machine ID from VM creation (for hardware additions)resource_group: UUID for device passthrough
Authentication
Next Steps
After VM creation → Power Management (VM Power Management)
API Quick Reference
Create VM
POST
/api/v4/vms
Returns both
Initial creation
Add Drive
POST
/api/v4/machine_drives
Machine key
Hardware
Add Device
POST
/api/v4/machine_devices
Machine key
GPU/PCI passthrough
Add NIC
POST
/api/v4/machine_nics
Machine key
Network interface
Power On
POST
/api/v4/vm_actions
VM key
Control
Check Status
GET
/api/v4/machine_status/{id}
Machine key
Monitor
Troubleshooting Index
409 Conflict: VM name exists, already running, permission denied
400 Bad Request: Invalid parameters, missing required fields, invalid JSON
507 Insufficient Storage: Tier full, reduce size, choose different tier
403 Forbidden: API key permissions, cluster access denied
404 Not Found: Invalid cluster ID, missing media source, invalid resource group
422 Unprocessable Entity: Invalid drive interface, unsupported media type
Prerequisites
Valid VergeOS API credentials with VM management permissions
Understanding of VergeOS concepts: clusters, vnets, media sources, and resource groups
Basic knowledge of REST API principles and JSON formatting
Authentication
All VM creation operations require authentication using either:
API Key: Include in the
Authorizationheader asBearer YOUR_API_KEYBasic Authentication: Username and password for interactive sessions
Session Token: For web-based integrations
Basic VM Creation
POST /api/v4/vms
Description: Creates a new virtual machine with the specified configuration.
Request Parameters:
name
string
Yes
Unique VM name
description
string
No
VM description
cluster
string
No
Target cluster ID (numeric string)
ram
integer
No
RAM in MB (default: 1024)
cpu_cores
integer
No
Number of CPU cores (default: 1)
guest_agent
string
No
Enable guest agent ("true"/"false")
console_pass_hash
string
No
Console password hash (empty string if not used)
video
string
No
Video adapter type (virtio, std, cirrus, etc.)
rtc_base
string
No
RTC base setting (utc, localtime)
uefi
string
No
Enable UEFI boot ("true"/"false")
Request Body Example:
Response Example:
Response Fields:
location
string
API endpoint for the created VM
dbpath
string
Database path for the VM record
$row
integer
Database row number
$key
string
VM ID (used for subsequent API calls)
response.machine
string
Machine ID (used for drives, NICs, devices)
Error Responses:
400 Bad Request: Invalid configuration parameters409 Conflict: VM name already exists403 Forbidden: Insufficient permissions
VM Key vs Machine Key
VM key (e.g., "42"): Use for VM settings like CPU, RAM, console
Machine key (e.g., "54"): Use for hardware like drives, NICs, devices
You get both keys in the VM creation response
Recipe-Based VM Creation
VergeOS supports complex VM creation using recipes that include drives, network interfaces, and devices.
Complete VM with Recipe Configuration
Adding Drives
Drives must be created separately after VM creation using the machine drives endpoint.
POST /api/v4/machine_drives
Request Parameters:
machine
string
Yes
Machine ID from VM creation
name
string
No
Drive name
media
string
No
Media type (disk, cdrom, import, clone, efidisk)
interface
string
No
Drive interface (virtio-scsi, ide, ahci, etc.)
disksize
integer
No
Disk size in bytes (for new disks)
preferred_tier
string
No
Storage tier (1-5)
media_source
string
No
Source media ID (for import/clone/cdrom)
show_pt
string
No
Override Preferred Tier ("true"/"false") - overrides media source's default tier
Creating a Boot Drive
Response Example:
Attaching CDROM/ISO
Response Example:
Importing from Media Source
Adding Devices (GPU, PCI Passthrough, etc.)
POST /api/v4/machine_devices
Description: Attaches hardware devices like GPUs, PCI devices, USB devices, or TPM to a virtual machine.
Request Parameters:
machine
string
Yes
Machine ID
resource_group
string
Yes
Resource group UUID for the device
settings_args
object
No
Device-specific settings (empty object for basic passthrough)
PCI Passthrough GPU
Response Example:
Finding Resource Groups
The resource_group parameter identifies the specific hardware device to attach. Use these endpoints to find available resource group UUIDs:
GET /api/v4/resource_groups- General hardware devices (GPUs, PCI devices, USB, etc.)GET /api/v4/node_nvidia_vgpu_devices- NVIDIA vGPU devices specifically
Finding Available Devices
Adding Network Interfaces
POST /api/v4/machine_nics
Request Parameters:
machine
string
Yes
Machine ID
vnet
string
Yes
Virtual network ID (key of the target network)
name
string
No
NIC name
interface
string
No
NIC interface type (virtio, e1000, etc.)
enabled
boolean
No
NIC enabled state
Example:
Response Example:
Complete VM Creation Example
Here's a complete workflow for creating a VM with drives, devices, and network interfaces:
Last updated
Was this helpful?