> ## 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 environment variables

> Updates encrypted environment variables. If env_keys changes for contract-owned KMS, requires two-phase flow with on-chain hash registration.



## OpenAPI

````yaml /openapi.json patch /api/v1/cvms/{cvm_id}/envs
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}/envs:
    patch:
      tags:
        - CVMs
      summary: Update environment variables
      description: >-
        Updates encrypted environment variables. If env_keys changes for
        contract-owned KMS, requires two-phase flow with on-chain hash
        registration.
      operationId: update_cvm_envs_api_v1_cvms__cvm_id__envs_patch
      parameters:
        - name: cvm_id
          in: path
          required: true
          schema:
            type: string
            title: Cvm Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: >-
                #/components/schemas/Body_update_cvm_envs_api_v1_cvms__cvm_id__envs_patch
      responses:
        '202':
          description: >-
            Update initiated, returns correlation_id and allowed_envs_changed
            flag
          content:
            application/json:
              schema: {}
        '401':
          description: Authentication required
        '403':
          description: CVM not in workspace
        '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 (env_keys changed, Phase 1)
        '466':
          description: Compose hash invalid or expired
        '467':
          description: Transaction verification failed
        '468':
          description: Compose hash not allowed on-chain
        '500':
          description: KMS configuration or RPC error
components:
  schemas:
    Body_update_cvm_envs_api_v1_cvms__cvm_id__envs_patch:
      properties:
        encrypted_env:
          type: string
          title: Encrypted Env
          description: Encrypted env blob as hex string
        env_keys:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Env Keys
          description: >-
            Allowed env var names. Changes trigger verification for
            contract-owned KMS.
        compose_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Compose Hash
          description: Hash from Phase 1 response (Phase 2 only)
        transaction_hash:
          anyOf:
            - type: string
            - type: 'null'
          title: Transaction Hash
          description: Transaction hash proving on-chain registration (Phase 2 only)
      type: object
      required:
        - encrypted_env
      title: Body_update_cvm_envs_api_v1_cvms__cvm_id__envs_patch
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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

````