Reference For: developers

API: vms

Operations of the vms tag of the native REST API.

Virtual machine lifecycle (long-running operations)

POST /v1/guest-agent/offer

Whether to offer installing the guest agent for a VM created from template.

The Ubuntu and Debian cloud images do not ship qemu-guest-agent; a VM created from them has no tools status, no guest addresses from the agent and no quiesced snapshots until the package is installed. This says when to offer the installation and what it adds; nothing changes until the create request sets guestAgent: true (or the caller puts the returned vendorData into its own guestinfo.vendordata).

CLI
kyvernon vm guest-agent-offer <template>

Request body

application/json: GuestAgentOfferRequest

NameTypeRequiredDescription
extraConfigobjectThe VM's extraConfig so far (guestinfo.userdata and friends).
templatestringyesThe template, image or guest OS the VM is created from (Ubuntu 24.04 LTS, debian-13, ubuntu64Guest).

Responses

StatusDescriptionSchema
200OKGuestAgentOffer

POST /v1/vms

Creates a VM in a folder.

CLI
kyvernon vm create --folder <id> --spec <file>

Request body

application/json: CreateVmRequest

NameTypeRequiredDescription
createDisksarray of DiskFileRequestDisk files the task creates before the VM record exists: empty qcow2 images, or copies or linked clones of an image (sourcePath). Each must be one of the disks of spec.config.disks (same datastore and path).
folderIdstringyesVM folder id (group-vN).
guestAgentbooleanInstall the guest agent through cloud-init: merges packages: [qemu-guest-agent] and runcmd: [systemctl enable --now qemu-guest-agent] into guestinfo.vendordata (kyvernon_vm_model::guestinfo::with_guest_agent). For images that lack the package (the Ubuntu and Debian cloud images); without it such a VM reports toolsNotInstalled. Never applied unless set: POST /v1/guest-agent/offer says when to offer it. Vendor data that is not #cloud-config is refused, not rewritten.
hoststring or nullHost to place the VM on (host-N). Without it the VM goes to the first connected host of the resource pool's cluster.
idempotencyKeystring or nullIdempotency key.
specVirtualMachineyesBody in the VirtualMachine schema, validated as a record (name, instance_uuid, resource_pool and config are required).

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody

POST /v1/vms/register

Registers an existing VM from a datastore path (POST /v1/vms/register, SOAP Folder.RegisterVM_Task). Restores inventory from .kyvernon-vm.json without recreating disks.

CLI
kyvernon vm register --folder <id> --path <path> [--resource-pool <id>]

Request body

application/json: RegisterVmRequest

NameTypeRequiredDescription
asTemplatebooleanRegister as a template.
folderIdstringyesDestination VM folder (group-vN).
hoststring or nullHost (host-N). Optional placement hint.
idempotencyKeystring or nullIdempotency key.
namestring or nullDisplay name; defaults to the name in the on-disk manifest.
pathstringyesDatastore path ([ds] name/name.vmx or [ds] name/.kyvernon-vm.json).
resourcePoolstring or nullResource pool (resgroup-N). Required unless asTemplate is true.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody

DELETE /v1/vms/{id}

Deletes a powered-off VM.

CLI
kyvernon vm delete <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/clone

Clones a virtual machine (full or linked).

CLI
kyvernon vm clone <id> --name <name>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: CloneVmRequest

NameTypeRequiredDescription
copyFirewallbooleanCopy the source's firewall: vNIC mode and profile, static group memberships, the rules of its own policy (same tenant only; Kyvernon.Firewall.ManagePolicies on the source). Without it the clone's vNICs start like new ones.
copyTagsbooleanAttach the source's tags to the clone (same tenant only; InventoryService.Tagging.AttachTag on the source).
datastorestring or nullTarget datastore for every disk. Defaults to each disk's current datastore. Linked clones require the same datastore as the source disks.
folderIdstring or nullDestination VM folder (group-vN). Defaults to the source's folder.
hoststring or nullHost (host-N). Defaults to the source's host.
idempotencyKeystring or nullIdempotency key.
linkedbooleanLinked clone (qcow2 child of a snapshot). Requires snapshot.
namestringyesName of the clone.
powerOnbooleanPower the clone on after creation.
resourcePoolstring or nullResource pool (resgroup-N). Defaults to the source's pool.
snapshotinteger (int32) or nullSnapshot key to clone from (required when linked is true).
templatebooleanMark the clone as a template.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody

GET /v1/vms/{id}/console/screenshot

The current frame of the VM's graphical console as a PNG (the summary thumbnail).

CLI
kyvernon vm console screenshot <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)
maxWidthqueryinteger (int32) or nullWidest image wanted in pixels (1..=1920); the host scales down by an integer factor. Absent: the guest's resolution.

Responses

StatusDescriptionSchema
200OKarray of integer (int32)
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
412error.console.powered_off, error.console.not_available (the VM has no graphical console), error.vm_not_placedErrorBody

POST /v1/vms/{id}/console/ticket

Issues a single-use console ticket (30 s) for the VM. The caller then opens the WebSocket at websocketPath on the same origin; the stream carries RFB (VNC) bytes in binary frames, which noVNC speaks directly.

CLI
kyvernon vm console ticket <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Responses

StatusDescriptionSchema
200OKConsoleTicketView
403Permission denied; args.privilege names the missing privilegeErrorBody
404Not found (or not visible to the caller)ErrorBody
412error.console.powered_off, error.vm_not_placedErrorBody
429error.console.rate_limitedErrorBody
503error.console.host_disconnectedErrorBody

POST /v1/vms/{id}/customize

Applies a named customization specification to a powered-off VM (POST /v1/vms/{id}/customize, SOAP CustomizeVM_Task).

Linux / cloud-init specs merge guestinfo.* via a reconfigure task; Windows specs submit offline virt-customize with the rendered unattend answer file.

CLI
kyvernon vm customize <id> --spec <name>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: CustomizeVmRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.
specstringyesName of a catalogue specification (GET /v1/customization/specs/{name}).

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/mark-as-template

Marks a powered-off VM as a template (POST /v1/vms/{id}/mark-as-template).

CLI
kyvernon vm mark-as-template <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Responses

StatusDescriptionSchema
204Done; no body
400Invalid argument; the error body names the fieldErrorBody
409Conflict: the object exists, or expectedVersion is staleErrorBody

POST /v1/vms/{id}/mark-as-vm

Converts a template back to a VM (POST /v1/vms/{id}/mark-as-vm).

CLI
kyvernon vm mark-as-vm <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: MarkAsVmRequest

NameTypeRequiredDescription
hoststring or nullHost (host-N). Defaults to the template's current host.
resourcePoolstring or nullResource pool (resgroup-N). Defaults to the template's current pool.

Responses

StatusDescriptionSchema
204Done; no body
400Invalid argument; the error body names the fieldErrorBody
409Conflict: the object exists, or expectedVersion is staleErrorBody

POST /v1/vms/{id}/power-off

Powers a VM off hard, at once: the guest is not asked. A VM that is already off stays off and the task succeeds. Use shutdown to let the guest shut down first.

CLI
kyvernon vm power-off <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: PowerRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/power-on

Powers a VM on.

CLI
kyvernon vm power-on <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: PowerRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/reconfigure

Changes the VM configuration. The body carries the whole configuration as read from GET /v1/vms/{id} with the changes made in it; config.change_version names that read. Requests made from the same read are merged (each adds its own disk or network adapter); a request made from a read that is no longer known answers 409 error.vm.concurrent_modification. Device counts, host capacity, datastore space and disk shrink are checked by the task (error.vm.too_many_devices, error.vm.exceeds_host_cpu, error.vm.exceeds_host_memory, error.datastore.insufficient_space, error.disk.shrink_not_supported).

CLI
kyvernon vm reconfigure <id> --config <file>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: ReconfigureVmRequest

NameTypeRequiredDescription
configVmConfigyesBody in the VmConfig schema (the full desired configuration).
createDisksarray of DiskFileRequestDisk files to create for disks config adds (empty images or from an image).
deleteDisksarray of DiskFileRequestDisk files to delete after they leave config.disks (detach and destroy). Omit a removed disk here to detach and keep the file on the datastore.
growDisksarray of DiskFileRequestDisks of config whose capacity grows: the file is grown to sizeBytes. On a running VM the host grows it online where the runtime can; otherwise the change applies at the next start (the task result says which).
idempotencyKeystring or nullIdempotency key.
namestring or nullNew display name (unique within the folder).

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef

POST /v1/vms/{id}/relocate

Relocates a VM (POST /v1/vms/{id}/relocate, SOAP RelocateVM_Task).

Cold storage relocate via datastore and/or per-disk disks requires a powered-off VM without snapshots; nics rebinds Ethernet network backing (SOAP deviceChange Edit). Host / pool / folder placement uses the same migrate task path.

CLI
kyvernon vm relocate <id> [--host <id>] [--resource-pool <id>] [--folder <id>] [--datastore <id>] [--disk KEY=DATASTORE]... [--nic KEY=NETWORK]...

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: RelocateVmRequest

NameTypeRequiredDescription
datastorestring or nullDestination datastore (datastore-N) for every disk not listed in disks.
disksarray of RelocateDiskLocatorPer-disk locators (diskKey + datastore). Overrides datastore for those keys.
folderIdstring or nullDestination VM folder (group-vN).
hoststring or nullDestination host (host-N). Optional; pool placement may choose one.
idempotencyKeystring or nullIdempotency key.
nicsarray of RelocateNicChangeEthernet network rebinds (nicKey + network). SOAP deviceChange Edit.
resourcePoolstring or nullDestination resource pool (resgroup-N).

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/reset

Resets a running VM.

CLI
kyvernon vm reset <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: PowerRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/resolve-migration

Resolves a VM fenced after a live migration with an unknown outcome (POST /v1/vms/{id}/resolve-migration, AgentOps resolve-migration).

The caller must have checked the destination. source-keeps resumes the source; destination-keeps removes the source instance and moves inventory placement to host. Never resume both.

CLI
kyvernon vm resolve-migration <id> --resolution <source-keeps|destination-keeps> [--host <id>]

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: ResolveMigrationRequest

NameTypeRequiredDescription
hoststring or nullDestination host (host-N). Required when resolution is destination-keeps so inventory placement moves off the source.
resolutionFenceResolutionViewyesWho keeps the guest (source-keeps or destination-keeps).

Responses

StatusDescriptionSchema
200OKResolveMigrationView
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

GET /v1/vms/{id}/serial-log

Reads the tail of the VM's serial console log from the host.

CLI
kyvernon vm serial-log <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)
maxBytesqueryinteger (int64) or nullMaximum bytes from the end of the log (default 65536, maximum 1048576).

Responses

StatusDescriptionSchema
200OKSerialLogView
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/shutdown

Shuts a VM down gracefully: the guest is asked to power off (guest agent, then the ACPI power button); when it has not gone down after timeoutSeconds (default 90) the VM is powered off hard. A guest that takes its time holds up no other virtual machine. A VM that is already off stays off and the task succeeds.

CLI
kyvernon vm shutdown <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: ShutdownRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.
timeoutSecondsinteger (int64) or nullHow long the guest gets to shut down before the VM is powered off hard (seconds, 1 to 3600; default 90).

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody

POST /v1/vms/{id}/snapshots

Creates a snapshot of a VM.

CLI
kyvernon vm snapshot create <id> --name <name>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: CreateSnapshotRequest

NameTypeRequiredDescription
descriptionstring or nullFree-text description.
idempotencyKeystring or nullIdempotency key.
memorybooleanCapture memory when the guest is powered on (resume on revert).
namestringyesDisplay name (1..=80 characters).
quiescebooleanQuiesce guest file systems when a guest agent is present.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
400Invalid argument; the error body names the fieldErrorBody

DELETE /v1/vms/{id}/snapshots

Removes every snapshot of a VM.

CLI
kyvernon vm snapshot remove-all <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef

DELETE /v1/vms/{id}/snapshots/{key}

Removes one snapshot (removeChildren query removes the subtree).

CLI
kyvernon vm snapshot remove <id> <key>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)
keypathinteger (int32)yesKey of the snapshot in the snapshot tree
removeChildrenquerybooleanAlso remove child snapshots

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef

POST /v1/vms/{id}/snapshots/{key}/rename

Renames a snapshot (POST /v1/vms/{id}/snapshots/{key}/rename, SOAP VirtualMachineSnapshot.RenameSnapshot). Synchronous; at least one of name or description is required.

CLI
kyvernon vm snapshot rename <id> <key> --name <name>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)
keypathinteger (int32)yesKey of the snapshot in the snapshot tree

Request body

application/json: RenameSnapshotRequest

NameTypeRequiredDescription
descriptionstring or nullNew free-text description (empty string clears it).
namestring or nullNew display name (1..=80 characters, no surrounding spaces).

Responses

StatusDescriptionSchema
204Done; no body
400Invalid argument; the error body names the fieldErrorBody
404Not found (or not visible to the caller)ErrorBody

POST /v1/vms/{id}/snapshots/{key}/revert

Reverts a VM to a snapshot.

CLI
kyvernon vm snapshot revert <id> <key>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)
keypathinteger (int32)yesKey of the snapshot in the snapshot tree

Request body

application/json: RevertSnapshotRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.
suppressPowerOnbooleanDo not power the guest on after a memory snapshot revert.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef

POST /v1/vms/{id}/suspend

Suspends a running VM.

CLI
kyvernon vm suspend <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Request body

application/json: PowerRequest

NameTypeRequiredDescription
idempotencyKeystring or nullIdempotency key.

Responses

StatusDescriptionSchema
202Accepted: the body names the task to poll (GET /v1/tasks/{id}/wait)TaskRef
404Not found (or not visible to the caller)ErrorBody
412Failed precondition; the error body says whichErrorBody

POST /v1/vms/{id}/unregister

Removes a powered-off VM from inventory without deleting its disk files (POST /v1/vms/{id}/unregister). Writes [ds] name/.kyvernon-vm.json when datastore files are reachable so SOAP RegisterVM_Task / native register can restore it.

CLI
kyvernon vm unregister <id>

Parameters

NameInTypeRequiredDescription
idpathstringyesId of the virtual machine (vm-N)

Responses

StatusDescriptionSchema
204Done; no body
400Invalid argument; the error body names the fieldErrorBody
409Conflict: the object exists, or expectedVersion is staleErrorBody

Version 0.1.