The Virtual Machines API allows you to manage your Swiftor VMs, including creation, deletion, and state management (starting/stopping).
Authentication Required
All VM endpoints require JWT authentication. See the Authentication Guide for details.
GET /vms
) Returns a list of all VMs owned by the authenticated user.
{
"vms": [
{
"id": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"vmlabel": "NewVM",
"region": "AU",
"os": {
"distribution": "ubuntu",
"desktop": "xfce"
},
"specs": {
"cpu": 2,
"ram": 4,
"storage": true
},
"enabled": false // Indicates if the VM is currently running or stopped
}
// ... other VMs
]
}
POST /vms/create
) Creates a new virtual machine record in the database with the specified configuration.
Note: The VM is created in a stopped state (enabled: false
) and is not started automatically. Use the Start VM
endpoint to activate it.
{
"config": {
"vmlabel": "MyWebServer",
"region": { "code": "AU" },
"password": "your-secure-password",
"storageType": "persistent"
},
"os": {
"distribution": { "code": "ubuntu" },
"desktop": "xfce",
"cpu": 2,
"ram": 4
}
}
config.vmlabel
(string, required): A user-friendly name for the VM.config.region.code
(string, required): The region code (e.g., "AU", "US").config.password
(string, required): The password for the default VM user. This will be stored securely as a VM_PASSWORD
secret associated with the VM.config.storageType
(string, optional): Set to "persistent"
to enable persistent storage for the VM's primary volume (usually /config
). If omitted or different, storage will be ephemeral. When persistent storage is enabled, the necessary host directory structure is created upon VM creation.os.distribution.code
(string, required): The Linux distribution identifier. See the table below for available options.os.desktop
(string, optional): The desktop environment for webtop-based images (e.g., "kde", "xfce"). Required if distribution
is a webtop base like "ubuntu", "debian", "fedora".os.cpu
(integer, required): The number of vCPU cores allocated.os.ram
(integer, required): The amount of RAM in GB allocated.os.distribution.code
) The following image types are available. Base Webtop images require specifying an os.desktop
environment (e.g., kde
, xfce
).
Code (os.distribution.code ) | Type | Description | Notes |
---|---|---|---|
ubuntu | Base Webtop | Standard Ubuntu | Requires os.desktop . Default Port: 3000 (KasmVNC) |
debian | Base Webtop | Standard Debian | Requires os.desktop . Default Port: 3000 (KasmVNC) |
fedora | Base Webtop | Standard Fedora | Requires os.desktop . Default Port: 3000 (KasmVNC) |
kali | Premade | Kali Linux (Penetration Testing) | Default Port: 3000 (KasmVNC) |
blender | Premade | Blender (3D Graphics) | Default Port: 3000 (KasmVNC) |
code-server | Premade | VS Code in the browser | Default Port: 8443. Includes /config/workspace volume. |
emulatorjs | Premade | Retro Game Emulation | Default Port: 80. Additional route: /manage on port 3000. Includes /data volume. |
phpmyadmin | Premade | MySQL Web Admin | Default Port: 80. |
krita | Premade | Krita (Digital Painting) | Default Port: 3000 (KasmVNC) |
steamos | Premade | SteamOS-like Environment | Default Port: 3000 (KasmVNC). Allows user-defined port forwarding. |
minecraft | Premade | MineOS (Minecraft Server Mgmt) | Default Port: 8443 (Web UI). Additional route: /minecraft on port 25565. |
Resource Limits
While limits aren't checked at creation time, ensure your selections adhere to your subscription plan's limits (CPU, RAM, Storage, Concurrent VMs), as these will be enforced when attempting to start the VM.
Plan | CPU | RAM | Storage |
---|---|---|---|
Core | 1 | 2GB | 2GB |
Hacker | 4 vCPU | 8GB | 30GB |
Engineer | 8 vCPU | 16GB | 150GB |
Returns the newly created VM object, reflecting its initial configuration and state (enabled: false
).
{
"message": "VM created successfully",
"vm": {
"id": "generated-uuid-4",
"user_id": "user-supabase-id",
"vmlabel": "MyWebServer",
"region": "AU",
"os": {
"distribution": "ubuntu",
"desktop": "xfce"
},
"specs": {
"cpu": 2,
"ram": 4,
"storage": true // True because storageType was "persistent"
},
"enabled": false
}
}
GET /vms/start/{vmid}
) Initiates the startup process for a stopped virtual machine specified by its vmid
.
400 Bad Request
) is returned if these checks fail.enabled: true
in the database immediately, but the actual provisioning and boot-up may take several moments.GET /vms
endpoint or the Swiftor dashboard to confirm when it's fully running.{
"message": "VM start process initiated successfully in the background."
}
GET /vms/stop/{vmid}
) Gracefully stops a running virtual machine specified by its vmid
. The VM's status will be updated to enabled: false
.
Data Persistence
If the VM was created without persistent storage (config.storageType
was not set to "persistent"
), all data within the VM's primary volume (e.g., /config
) will be lost when it is stopped. Data on explicitly attached persistent volumes (configured via the image) will remain.
GET /vms/delete/{vmid}
) Permanently deletes a virtual machine and its associated storage (if persistent).
Irreversible Action
VM deletion cannot be undone. All associated data, including secrets, networking configurations, and persistent storage volumes, will be permanently lost.
/vms/secrets
) Manage environment variables for your VMs. These secrets are injected into the running container.
GET /vms/secrets
) Retrieves all secrets defined for the authenticated user's VMs.
Returns an object where keys are VM IDs and values are objects containing the key-value pairs of secrets for that VM.
{
"secrets": {
"1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f": {
"API_KEY": "your-api-key-value",
"DATABASE_URL": "your-db-url"
},
"another-vm-id": {
"SECRET_TOKEN": "another-secret-value"
}
}
}
POST /vms/secrets
) Adds a new secret or updates the value of an existing secret for a VM.
{
"vmid": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"key": "NEW_SECRET_KEY",
"value": "its-secret-value"
}
vmid
(string): The ID of the target VM.key
(string): The name of the environment variable.value
(string): The value of the environment variable.--env-add
). The secret will be applied immediately or when the VM (re)starts.{
"message": "Secret added successfully",
"vmid": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"key": "NEW_SECRET_KEY"
}
DELETE /vms/secrets/{vmid}/{key}
) Removes an existing secret from a VM.
{vmid}
: The ID of the VM.{key}
: The key (name) of the secret to remove.--env-rm
). The removal takes effect immediately or upon VM restart.{
"message": "Secret removed successfully",
"vmid": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"key": "NEW_SECRET_KEY"
}
/vms/networking
) Manage subdomain mappings to expose specific ports within your VMs via https://{name}-{vmid}.swiftor.io
.
GET /vms/networking
) Retrieves all active subdomain mappings for the authenticated user's VMs.
Returns an object where keys are VM IDs and values are objects containing the mappings for that VM. Each mapping key is the chosen name (subdomain prefix).
{
"networking": {
"1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f": {
"myapp": {
"subdomain": "myapp", // The chosen name
"internal_port": 5001
},
"api": {
"subdomain": "api",
"internal_port": 8080
}
},
"another-vm-id": {
"web": {
"subdomain": "web",
"internal_port": 3000
}
}
}
}
POST /vms/networking
) Creates a new subdomain mapping for a VM.
{
"vmid": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"name": "myapp",
"internal_port": 5001
}
vmid
(string): The ID of the target VM.name
(string): The desired subdomain prefix. The final URL will be https://{name}-{vmid}.swiftor.io
.internal_port
(integer): The port number inside the VM container that the subdomain should point to.{
"message": "Subdomain mapping added successfully", // Or similar message if VM is stopped
"subdomain": "myapp.1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f.swiftor.io",
"internal_port": 5001
}
DELETE /vms/networking/{vmid}/{name}
) Removes an existing subdomain mapping.
{vmid}
: The ID of the VM.{name}
: The name (subdomain prefix) of the mapping to remove.{
"message": "Subdomain mapping removed successfully",
"vmid": "1aa62e52-e61c-4ae3-9ac2-c9cb1f46d25f",
"name": "myapp"
}