> ## 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.

# Batch refresh CVM instance IDs

> Resolves and persists missing instance_id values. Admin can pass cross-workspace CVM IDs.



## OpenAPI

````yaml /openapi.json patch /api/v1/cvms/instance-ids
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/instance-ids:
    patch:
      tags:
        - CVMs
      summary: Batch refresh CVM instance IDs
      description: >-
        Resolves and persists missing instance_id values. Admin can pass
        cross-workspace CVM IDs.
      operationId: handle_batch_refresh_cvm_instance_ids_api_v1_cvms_instance_ids_patch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchInstanceIdRefreshRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchInstanceIdRefreshResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    BatchInstanceIdRefreshRequest:
      properties:
        cvm_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Cvm Ids
          description: Optional CVM identifiers. Admin can pass cross-workspace IDs.
        running_only:
          type: boolean
          title: Running Only
          description: Only process CVMs with status=running
          default: true
        missing_only:
          type: boolean
          title: Missing Only
          description: Only process CVMs with missing instance_id
          default: true
        overwrite:
          type: boolean
          title: Overwrite
          description: Overwrite existing instance_id when different
          default: false
        limit:
          type: integer
          maximum: 500
          minimum: 1
          title: Limit
          description: Max CVMs to process in one request
          default: 100
        dry_run:
          type: boolean
          title: Dry Run
          description: Preview changes without persisting
          default: false
      type: object
      title: BatchInstanceIdRefreshRequest
    BatchInstanceIdRefreshResponse:
      properties:
        total:
          type: integer
          title: Total
        scanned:
          type: integer
          title: Scanned
        updated:
          type: integer
          title: Updated
        unchanged:
          type: integer
          title: Unchanged
        skipped:
          type: integer
          title: Skipped
        conflicts:
          type: integer
          title: Conflicts
        errors:
          type: integer
          title: Errors
        items:
          items:
            $ref: '#/components/schemas/InstanceIdRefreshResult'
          type: array
          title: Items
      type: object
      required:
        - total
        - scanned
        - updated
        - unchanged
        - skipped
        - conflicts
        - errors
        - items
      title: BatchInstanceIdRefreshResponse
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    InstanceIdRefreshResult:
      properties:
        cvm_id:
          type: integer
          title: Cvm Id
        identifier:
          type: string
          title: Identifier
        status:
          type: string
          enum:
            - updated
            - unchanged
            - skipped
            - conflict
            - error
          title: Status
        old_instance_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Old Instance Id
        new_instance_id:
          anyOf:
            - type: string
            - type: 'null'
          title: New Instance Id
        source:
          type: string
          enum:
            - teepod_state
            - teepod_info
            - gateway
            - none
          title: Source
          default: none
        verified_with_gateway:
          type: boolean
          title: Verified With Gateway
          default: false
        reason:
          anyOf:
            - type: string
            - type: 'null'
          title: Reason
      type: object
      required:
        - cvm_id
        - identifier
        - status
      title: InstanceIdRefreshResult
    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

````