> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phala.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Update CVM

> Unified PATCH endpoint for CVM updates. Only fields present in the request body are applied. Handles resource resize, compose configuration, visibility, environment, and OS image updates. For contract-owned KMS, compose-hash-affecting changes require two-phase flow with on-chain hash registration.



## OpenAPI

````yaml /openapi.json patch /api/v1/cvms/{cvm_id}
openapi: 3.1.0
info:
  title: Phala Cloud API
  version: 0.1.0
servers:
  - url: https://cloud-api.phala.com
security: []
tags:
  - name: CVMs
    description: Confidential Virtual Machine (CVM) lifecycle management on Phala Network
  - name: Apps
    description: App template management and CVM deployment from app blueprints
  - name: Webhooks
    description: Manage webhook endpoints and monitor delivery history
  - name: SSH Keys
    description: SSH public key management for CVM access
  - name: KMS
    description: >-
      Key Management Service — key derivation, on-chain anchoring, and
      inspection
  - name: Instance Types
    description: Available hardware configurations for CVM deployment
  - name: Attestations
    description: Remote attestation and TEE verification endpoints
paths:
  /api/v1/cvms/{cvm_id}:
    patch:
      tags:
        - CVMs
      summary: Update CVM
      description: >-
        Unified PATCH endpoint for CVM updates. Only fields present in the
        request body are applied. Handles resource resize, compose
        configuration, visibility, environment, and OS image updates. For
        contract-owned KMS, compose-hash-affecting changes require two-phase
        flow with on-chain hash registration.
      operationId: update_cvm_endpoint_api_v1_cvms__cvm_id__patch
      parameters:
        - name: cvm_id
          in: path
          required: true
          schema:
            type: string
            title: Cvm Id
        - name: X-Compose-Hash
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Compose hash from Phase 1 response (Phase 2 only)
            title: X-Compose-Hash
          description: Compose hash from Phase 1 response (Phase 2 only)
        - name: X-Transaction-Hash
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Transaction hash proving on-chain registration (Phase 2 only)
            title: X-Transaction-Hash
          description: Transaction hash proving on-chain registration (Phase 2 only)
        - name: X-Prepare-Only
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: >-
              When 'true', generate a commit token for multisig workflows
              instead of expecting immediate on-chain registration
            title: X-Prepare-Only
          description: >-
            When 'true', generate a commit token for multisig workflows instead
            of expecting immediate on-chain registration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateCvmRequest'
      responses:
        '202':
          description: Update initiated, track via correlation_id
          content:
            application/json:
              schema: {}
        '400':
          description: Invalid request or terms violation
        '401':
          description: Authentication required
        '403':
          description: CVM not in workspace or GPU rental managed
        '404':
          description: CVM not found
        '409':
          description: Another operation in progress
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '465':
          description: Compose hash registration required (Phase 1)
        '466':
          description: Compose hash invalid or expired
        '467':
          description: Transaction verification failed
        '468':
          description: Compose hash not allowed on-chain
components:
  schemas:
    UpdateCvmRequest:
      properties:
        docker_compose_file:
          anyOf:
            - type: string
            - type: 'null'
          title: Docker Compose File
          description: Docker Compose YAML content
        pre_launch_script:
          anyOf:
            - type: string
            - type: 'null'
          title: Pre Launch Script
          description: Shell script executed before containers start
        allowed_envs:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Allowed Envs
          description: Allowed environment variable names (env_keys)
        public_logs:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Public Logs
          description: Expose container logs publicly
        public_sysinfo:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Public Sysinfo
          description: Expose system info publicly
        public_tcbinfo:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Public Tcbinfo
          description: Expose TCB attestation info publicly
        encrypted_env:
          anyOf:
            - type: string
            - type: 'null'
          title: Encrypted Env
          description: Encrypted environment variables as hex string
        user_config:
          anyOf:
            - type: string
            - type: 'null'
          title: User Config
          description: User configuration string
        gpus:
          anyOf:
            - $ref: '#/components/schemas/GpuConfig'
            - type: 'null'
          description: GPU configuration
        vcpu:
          anyOf:
            - type: integer
            - type: 'null'
          title: Vcpu
          description: Number of vCPUs
        memory:
          anyOf:
            - type: integer
            - type: 'null'
          title: Memory
          description: Memory in MB
        disk_size:
          anyOf:
            - type: integer
            - type: 'null'
          title: Disk Size
          description: Disk size in MB
        image:
          anyOf:
            - type: string
            - type: 'null'
          title: Image
          description: OS image name or slug from available-os-images
        shutdown_timeout:
          anyOf:
            - type: integer
              maximum: 1200
              minimum: 10
            - type: 'null'
          title: Shutdown Timeout
          description: Timeout in seconds for graceful shutdown. null means no timeout.
        allow_force_stop:
          type: boolean
          title: Allow Force Stop
          description: >-
            When true, falls back to hard stop if graceful shutdown times out.
            Use for zombie CVMs that are unresponsive to shutdown signals.
          default: false
      type: object
      title: UpdateCvmRequest
      description: PATCH request body — all fields optional, only set fields are applied.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    GpuConfig:
      properties:
        gpus:
          items:
            $ref: '#/components/schemas/GpuSpec'
          type: array
          title: Gpus
        attach_mode:
          anyOf:
            - type: string
              enum:
                - listed
                - all
            - type: string
          title: Attach Mode
          default: listed
      type: object
      required:
        - gpus
      title: GpuConfig
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    GpuSpec:
      properties:
        slot:
          type: string
          title: Slot
        product_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Product Id
      type: object
      required:
        - slot
      title: GpuSpec

````