updateXxxx method targets a single aspect of the CVM and calls a dedicated API endpoint. patchCvm is the unified method that can update multiple fields in a single request. Use patchCvm when you need to change several settings atomically; use the individual updateXxxx methods when you only need to change one thing.
updateCvmResources
PATCH /cvms/{cvmId}/resources
Updates CVM compute resources (vCPU, memory, disk).
Parameters:
Returns: Updated CVM details.
Example:
updateCvmVisibility
PATCH /cvms/{cvmId}/visibility
Updates CVM visibility settings (public listing, public TCB info).
Parameters:
Returns: Updated CVM details.
updatePreLaunchScript
PATCH /cvms/{cvmId}/pre-launch-script
Updates the pre-launch script for a CVM.
Parameters:
Returns: Union type:
{ status: "in_progress", message, correlation_id }— update accepted{ status: "precondition_required", message, compose_hash, app_id, device_id, kms_info }— on-chain KMS requires compose hash registration first
For CVMs using on-chain KMS, this function may return
precondition_required. You must register the compose_hash on-chain using addComposeHash before retrying with the compose_hash and transaction_hash parameters.updateOsImage
PATCH /cvms/{cvmId}/os-image
Updates the OS image for a CVM. The CVM will restart with the new image.
Parameters:
Returns: Updated CVM details.
getAvailableOsImages
GET /os-images
Returns the list of available OS images.
Parameters: None (optional filters).
Returns: GetAvailableOSImagesResponse — array of OS image variants with version info.
Example:
refreshCvmInstanceId is unreleased — added after @phala/cloud v0.2.4. It will be available in a future release.refreshCvmInstanceId
POST /cvms/{cvmId}/refresh-instance-id
Generates a new instance ID for a CVM. This invalidates the old instance ID.
Parameters:
Returns:
InstanceIdRefreshResult with the new instance_id.
refreshCvmInstanceIds is unreleased — added after @phala/cloud v0.2.4. It will be available in a future release.refreshCvmInstanceIds
POST /cvms/refresh-instance-ids
Generates new instance IDs for multiple CVMs in a single request.
Parameters:
Returns:
RefreshCvmInstanceIdsResponse — batch results.
provisionCvmComposeFileUpdate
POST /cvms/{cvmId}/compose_file/provision
Provisions a compose file update — the first phase of a two-phase compose file change. Returns a compose_hash needed for the commit step.
Parameters:
Returns:
ProvisionCvmComposeFileUpdateResult
Example:
commitCvmComposeFileUpdate
POST /cvms/{cvmId}/compose_file/commit
Commits a compose file update — the second phase. For on-chain KMS, the compose_hash must be registered on-chain before calling this.
Parameters:
Returns:
CommitCvmComposeFileUpdate — update details.
patchCvm
PATCH /cvms/{cvmId}
Applies partial updates to a CVM via the unified PATCH endpoint. Only fields present in the request body are applied, giving you true PATCH semantics. You can update compose files, environment variables, resources, visibility, and OS images all in a single call.
For CVMs with on-chain KMS (ETHEREUM/BASE), any change that affects the compose hash triggers a two-phase flow. The first call returns { requiresOnChainHash: true, composeHash, ... } with the hash you need to register on-chain. After registration, call confirmCvmPatch with the transaction proof.
Parameters:
Returns: Discriminated union on
requiresOnChainHash:
Accepted (requiresOnChainHash: false):
Hash required (
requiresOnChainHash: true):
Example — simple update (PHALA KMS):
confirmCvmPatch
PATCH /cvms/{cvmId} (with X-Compose-Hash and X-Transaction-Hash headers)
Completes the second phase of an on-chain KMS CVM update. Call this after patchCvm returns { requiresOnChainHash: true } and you have registered the compose hash on-chain via addComposeHash.
Parameters:
Returns:
ConfirmCvmPatchResult
Example:
commitCvmUpdate
POST /cvms/{cvmId}/commit-update
Completes a two-phase CVM update using a one-time commit token. This enables multisig workflows where the on-chain signer is different from the original API caller. The token is generated when you call patchCvm with prepareOnly: true.
Parameters:
Returns:
CommitCvmUpdateResult
Example:

