---
title: "Apply staged CVM changes"
method: POST
path: "/api/v1/cvms/{cvm_id}/draft/apply"
tags: ["CVMs", "cvms-draft"]
---

# Apply staged CVM changes

`POST /api/v1/cvms/{cvm_id}/draft/apply`

## Request

- Base URL: `https://cloud-api.phala.com`
- URL: `https://cloud-api.phala.com/api/v1/cvms/{cvm_id}/draft/apply`
- Auth: none declared
- TypeScript: <https://skmtc.dev/phala/apis/phala-cloud-api/docs/api/v1/cvms/:cvm_id/draft/apply/post.ts> (a function with typed inputs; its response is checked against the schema)

Applies every staged change as one PATCH /cvms/{cvm_id}: one VMM update and at most one restart; a stopped CVM stays stopped. Rejected with ERR-03-053 when the CVM's compose changed since the first change was staged. Accepts the same X-Compose-Hash, X-Transaction-Hash and X-Prepare-Only headers and returns the same responses as PATCH /cvms/{cvm_id}; the staged changes are kept until an apply dispatches them. A phase 2 apply is rejected with ERR-03-054 when changes were staged after its phase 1; apply again without the headers to prepare them. An update committed through a commit token (POST /cvms/{cvm_id}/commit-update) does not clear them: the next apply is then rejected with ERR-03-053, and the staged changes must be discarded.

## Path parameters

- `cvm_id` string, required

## Headers

- `X-Compose-Hash` string, nullable
- `X-Transaction-Hash` string, nullable
- `X-Prepare-Only` string, nullable

## Request body

- ApplyCvmDraftRequest
  - `base_compose_hash` string, nullable: The CVM compose hash the caller reviewed the changes against. Defaults to the draft's base; after ERR-03-053, send its current_compose_hash to apply anyway.

## Response `202`

Successful Response

- unknown

## Other responses

- `404`: ERR-03-052: the CVM has no staged changes
- `409`: ERR-03-053: the CVM's compose changed since the changes were staged; ERR-03-054: changes were staged after the apply's phase 1; or another operation is in progress
- `422`: Validation Error
- `465`: Compose hash registration required (Phase 1)

## Changes

- **2026-11-07** `c71a8dc90391`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/phala/apis/phala-cloud-api/changes/api/v1/cvms/:cvm_id/draft/apply/post.md)

---

[API](https://skmtc.dev/phala/apis/phala-cloud-api.md) - [All operations](https://skmtc.dev/phala/apis/phala-cloud-api/llms.txt) - [OpenAPI document](https://skmtc.dev/phala/apis/phala-cloud-api/revisions/c71a8dc90391?raw)
