Skip to content

POST /api/appvm/vms

Updated

Create an AppVM from an image that has already been imported on the Lite host.

PropertyValue
Scopereadwrite
Request bodyJSON
Success201 Created

Endpoint

POST ${baseUrl}/api/appvm/vms
readwrite

Create an AppVM from an already imported OCI image.

Use your host URL and API key as shell variables:

baseUrl="https://agent.example.com"
VIRT_AGENT_API_KEY="<your-api-key>"

cURL template

curl --request POST "${baseUrl}/api/appvm/vms" \
  --header "Authorization: Bearer ${VIRT_AGENT_API_KEY}" \
  --header "Content-Type: application/json" \
  --data @- <<'JSON'
{
"vm_id": "${id}",
"image_id": "${imageId}",
"vcpus": 2,
"memory_mb": 2048,
"disk_gib": 12,
"auto_boot": true,
"restart_policy": "on-failure",
"env": [
  "PORT=8080"
]
}
JSON
ObjectFieldTypeRequiredDescription
HeaderAuthorizationbearer tokenyesBearer <api-key> from a readwrite key.
Bodyvm_idstringnoStable VM id. Omit to let the agent generate one.
image_idstringyesAppVM image id from GET /api/appvm/images response field images[].id. The image must be ready, not still importing.
vcpusintegeryesvCPU count. Must be at least 1.
memory_mbintegeryesMemory in MiB. Must be at least 64.
disk_gibintegeryesRoot disk size in GiB. Must be at least 1.
network_idstringnoHost network id from GET /api/networks. Omit to use the default VM network.
ipstringconditionallyStatic guest IPv4 address without prefix. Required with prefix and gateway; omit all three for DHCP.
prefixintegerconditionallyIPv4 prefix length, 1..32. Required with ip and gateway; omit all three for DHCP.
gatewaystringconditionallyStatic IPv4 gateway. Required with ip and prefix; omit all three for DHCP.
dnsarray of stringsnoDNS server IPs for static mode. Must be empty or omitted in DHCP mode.
hostnamestringnoGuest hostname. Omit to derive an appvm-* hostname from the generated MAC address. Empty after trimming is treated as omitted.
auto_bootbooleannoDefault true. When false, create the AppVM without booting it.
keepalivebooleannoDefault false. When true, overrides the image entrypoint with a long-running keepalive shell.
envarray of stringsnoOperator-provided environment overrides in KEY=VALUE form. Values are visible in VM views.
secret_envarray of stringsnoSecret environment overrides in KEY=VALUE form. Values are sent to the guest but redacted from VM views.
restart_policyenumnoDefault no. Accepted values: no, on-failure, always.
data_volumesarray of objectsnoPersistent ext4 data volumes mounted inside the AppVM rootfs. Maximum 8.
disk_bps_totalintegernoRoot disk bandwidth limit in bytes per second. Omit or pass 0 for no limit.
disk_iops_totalintegernoRoot disk IOPS limit. Omit or pass 0 for no limit.
Static network groupip + prefix + gateway omittedshapenoDHCP mode. The guest obtains address and DNS from the upstream lease.
ip + prefix + gateway presentshapeyes for static modeStatic mode. The guest receives the exact IPv4 config over vsock.
partial static fieldsshapeinvalidRejected with 400 BAD_REQUEST.
env[] / secret_env[]item formstringyes for each itemEach item must be KEY=VALUE.
keystringyesMust match [A-Za-z_][A-Za-z0-9_]*.
valuestringyesMust not contain NUL, newline, or carriage return.
countlimityesEach list can contain at most 100 entries.
sizelimityesEach entry can be at most 8192 bytes.
redactionbehavioryessecret_env values are never returned in VM views; only keys are visible.
data_volumes[]size_gibintegeryesVolume size in GiB. Must be at least 1.
mountpointstringyesAbsolute mount path inside the guest rootfs, for example /var/lib/data. Must not be /, contain empty segments, ., .., NUL, or control characters. Maximum 256 characters. Mountpoints must be unique.
StatusBodyDescription
201 CreatedobjectAppVM was created. If auto_boot is omitted, the agent also attempted to boot it.
FieldTypeDescription
idstringCreated VM id.
modestringAlways appvm.
image_idstringSource AppVM image id.
bootedbooleanWhether the request asked the agent to boot the VM. This is true when auto_boot is omitted.

Use GET /api/appvm/vms/{id} after creation for the full VmView, including network state, AppVM workload status, redacted environment view, health, restart policy, data mounts, and discovered IP.

Terminal window
baseUrl="https://agent.example.com"
VIRT_AGENT_API_KEY="<your-api-key>"
curl --request POST "${baseUrl}/api/appvm/vms" \
--header "Authorization: Bearer ${VIRT_AGENT_API_KEY}" \
--header "Content-Type: application/json" \
--data @- <<'JSON'
{
"vm_id": "demo-api-appvm",
"image_id": "nginx_latest",
"vcpus": 2,
"memory_mb": 2048,
"disk_gib": 12,
"auto_boot": true,
"restart_policy": "on-failure",
"env": [
"PORT=8080"
],
"secret_env": [
"APP_SECRET=<redacted>"
],
"data_volumes": [
{
"size_gib": 10,
"mountpoint": "/var/lib/app"
}
]
}
JSON
{
"id": "demo-api-appvm",
"mode": "appvm",
"image_id": "nginx_latest",
"booted": true
}
StatusCodeDescription
400BAD_REQUESTValidation failed, image id was not found, static network fields were incomplete, DNS was provided in DHCP mode, env values were invalid, or data volume mountpoints were invalid.
401UNAUTHORIZEDAPI key is missing or invalid.
403FORBIDDENKey is read-only or endpoint is outside the key allowlist.
409ALREADY_EXISTS, CONFLICT, or capacity conflictVM id already exists, AppVM image import is still in progress, or host admission rejected the requested resources.
422noneJSON body could not be deserialized, for example a required field is missing or has the wrong type. This response is plain text, not the Virtainer JSON error envelope.
500CH_ERROR, NETWORK_ERROR, STORAGE_ERROR, or INTERNALHost-side creation, disk, network, AppVM template, or boot work failed.