Skip to main content
CVM lifecycle methods manage the full journey of a Confidential Virtual Machine, from initial provisioning through daily operations to deletion. All methods accept a context.Context as the first parameter and return Go-idiomatic (result, error) pairs.

ProvisionCVM

POST /cvms Provisions a new CVM by reserving resources and generating a compose hash. This is the first step of the two-phase deployment flow. The returned AppID and ComposeHash are needed to commit the provision.
ProvisionCVMRequest fields: Additional typed fields include KMSContractID, AppID, EnvKeys, Ports, GPUs, EncryptedEnv, and UserConfig. ComposeFile also supports fields such as Runner, BashScript, AllowedEnvs, Requirements, and PortPolicy. ProvisionCVMRequest.KMSType and ProvisionCVMRequest.SSHAuthorizedKeys remain in the Go type, but the current backend ignores these top-level fields. Use KMS to select the KMS type and SSHKeyIDs to authorize registered SSH keys. For slice fields with omitzero, a nil slice is omitted and an explicitly empty slice is sent as []. ComposeFile.EncryptedEnv has been removed. For creation, set ProvisionCVMRequest.EncryptedEnv instead. For changes to a CVM’s encrypted environment, use UpdateCVMEnvs. ComposeFile.InitScript uses ComposeInitScripts, a string slice. It decodes historical single-string and array responses and encodes as an array. The server ignores compose_file.init_script during creation; use ProvisionCVMRequest.InitScripts to select platform-owned scripts. Returns: *ProvisionCVMResponse with AppID, ComposeHash, AppEnvEncryptPubkey, and other provisioning details. Example:

CommitCVMProvision

POST /cvms Commits a provisioned CVM, triggering deployment. Pass the provision response’s Token, or supply its AppID and ComposeHash.
CommitCVMProvisionRequest fields: Returns: *CommitCVMProvisionResponse with ID, Name, and Status. Use the CvmID() helper method to get the ID as a string. Example — full two-phase deploy:

StartCVM

POST /cvms/{cvmId}/start Starts a stopped CVM. This method retries automatically on transient errors.
Parameters: Returns: *CVMActionResponse with ID, Name, and Status.

StopCVM

POST /cvms/{cvmId}/stop Force-stops a CVM immediately. Use ShutdownCVM if you need a graceful stop.
Parameters: Returns: *CVMActionResponse

ShutdownCVM

POST /cvms/{cvmId}/shutdown Gracefully shuts down a CVM, allowing containers to stop cleanly before powering off.
Parameters: Returns: *CVMActionResponse

RestartCVM

POST /cvms/{cvmId}/restart Restarts a CVM. By default, the restart is graceful. Set Force: true to skip the graceful shutdown phase.
Parameters: RestartCVMOptions fields:

DeleteCVM

DELETE /cvms/{cvmId} Permanently deletes a CVM and all its data. Returns only an error (no response body).
Parameters:
This action is irreversible. All data associated with the CVM will be permanently deleted.

ReplicateCVM

POST /cvms/{cvmId}/replicas Creates a replica of an existing CVM. You can optionally target a specific node. The new CVM inherits the source’s configuration.
Parameters: ReplicateCVMOptions fields:
You can also replicate a CVM within an app context using ReplicateAppCVM(ctx, appID, vmUUID, opts), which ensures the replica is associated with the correct application.