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

# Update VM

> Updates a Virtual Machine's display name (hostname).




## OpenAPI

````yaml https://spec.speakeasy.com/latitude/latitude/latitude-sh-api-with-code-samples patch /virtual_machines/{virtual_machine_id}
openapi: 3.0.1
info:
  title: Latitude.sh API
  version: '2023-06-01'
  description: >-
    The Latitude.sh API is a RESTful API to manage your Latitude.sh account. It
    allows you to perform the same actions as the Latitude.sh dashboard.
servers:
  - url: https://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
  - url: http://api.latitude.sh
    variables:
      latitude_api_key:
        default: <insert your api key here>
security: []
tags:
  - name: API keys
  - name: Billing
  - name: Elastic Ips
  - name: Events
  - name: Firewalls
  - name: IP Addresses
  - name: Kubernetes Clusters
  - name: Operating Systems
  - name: Plans
  - name: Private Networks
  - name: Projects
  - name: Regions
  - name: Roles
  - name: SSH Keys
  - name: Servers
  - name: Block Storage
  - name: Filesystem Storage
  - name: Object Storage
  - name: Tags
  - name: Teams
  - name: Team members
  - name: Traffic
  - name: User data
  - name: User profile
  - name: VPN Sessions
  - name: Virtual machines
  - name: Virtual machine backups
  - name: Virtual machine restores
paths:
  /virtual_machines/{virtual_machine_id}:
    patch:
      tags:
        - Virtual machines
      summary: Update VM
      description: |
        Updates a Virtual Machine's display name (hostname).
      operationId: update-virtual-machine
      parameters:
        - name: virtual_machine_id
          in: path
          required: true
          examples:
            Success:
              value: vm_7vYAZqGBdMQ94
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/virtual_machine_update_payload'
            examples:
              Success:
                summary: Success
                value:
                  data:
                    type: virtual_machines
                    id: vm_7vYAZqGBdMQ94
                    attributes:
                      name: my-updated-vm
          application/vnd.api+json:
            schema:
              $ref: '#/components/schemas/virtual_machine_update_payload'
            examples:
              Success:
                summary: Success
                value:
                  data:
                    type: virtual_machines
                    id: vm_7vYAZqGBdMQ94
                    attributes:
                      name: my-updated-vm
        required: true
      responses:
        '200':
          description: Success
          content:
            application/vnd.api+json:
              examples:
                Success:
                  value:
                    data:
                      id: vm_7vYAZqGBdMQ94
                      type: virtual_machines
                      attributes:
                        name: my-updated-vm
                        status: Running
                        created_at: '2026-01-14T15:57:15+00:00'
                        primary_ipv4: 10.0.0.25
                        operating_system: null
                        site: london-2193
                        billing: hourly
                        plan:
                          id: plan_VE1Wd3VQOXnZJ
                          name: c3.small.x86-143
                        specs:
                          vcpu: 16
                          ram: 128 GB
                          storage: 100 GB
                          nic: 1 x 1 Gbps
                          gpu: 1 x NVIDIA H100 Tensor Core GPU
                        team:
                          id: team_GpZboxNev1U2pxpmKwWAc8e01vpp
                          name: 702 Team
                          slug: 702-team
                          description: 702 Team
                          address: >-
                            Suite 729 8171 Albina Forges, Eldridgeberg, CA
                            26345-3293
                          status: verified
                          currency:
                            id: cur_AW6Q2D9lqKLpr
                            code: BRL
                            name: Brazilian Real
                            currency_id: null
                        project:
                          id: proj_W6Q2D9ZQOKLpr
                          name: Aerodynamic Wool Watch
                          slug: aerodynamic-wool-watch
                          description: Intelligent Paper Shirt
                          billing_type: Normal
                          billing_method: Normal
                          bandwidth_alert: false
                          environment: null
                          billing:
                            subscription_id: null
                            type: Normal
                            method: Normal
                          stats:
                            databases: 0
                            ip_addresses: 0
                            prefixes: 0
                            servers: 0
                            storages: 0
                            virtual_machines: 1
                            vlans: 0
              schema:
                $ref: '#/components/schemas/virtual_machine'
        '202':
          description: >-
            Accepted. Returned for a vertical upgrade (`plan` change). The
            resize runs asynchronously: the VM is powered off, resized, and
            powered back on. The response body reflects the VM at the start of
            the resize.
          content:
            application/vnd.api+json:
              schema:
                $ref: '#/components/schemas/virtual_machine'
        '404':
          description: Not Found
        '409':
          description: Conflict. Returned when a resize is already in progress for the VM.
        '422':
          description: Unprocessable Entity
      security:
        - Bearer: []
      x-codeSamples:
        - lang: python
          label: Python (SDK)
          source: |-
            import latitudesh_python_sdk
            from latitudesh_python_sdk import Latitudesh
            import os


            with Latitudesh(
                bearer=os.getenv("LATITUDESH_BEARER", ""),
            ) as latitudesh:

                res = latitudesh.virtual_machines.update_virtual_machine(virtual_machine_id="vm_7vYAZqGBdMQ94", data={
                    "type": latitudesh_python_sdk.VirtualMachineUpdatePayloadType.VIRTUAL_MACHINES,
                    "id": "vm_7vYAZqGBdMQ94",
                    "attributes": {
                        "name": "my-updated-vm",
                    },
                })

                # Handle response
                print(res)
        - lang: go
          label: Go (SDK)
          source: "package main\n\nimport(\n\t\"context\"\n\t\"os\"\n\tlatitudeshgosdk \"github.com/latitudesh/latitudesh-go-sdk\"\n\t\"github.com/latitudesh/latitudesh-go-sdk/models/components\"\n\t\"log\"\n)\n\nfunc main() {\n    ctx := context.Background()\n\n    s := latitudeshgosdk.New(\n        latitudeshgosdk.WithSecurity(os.Getenv(\"LATITUDESH_BEARER\")),\n    )\n\n    res, err := s.VirtualMachines.UpdateVirtualMachine(ctx, \"vm_7vYAZqGBdMQ94\", components.VirtualMachineUpdatePayload{\n        Data: components.VirtualMachineUpdatePayloadData{\n            Type: components.VirtualMachineUpdatePayloadTypeVirtualMachines,\n            ID: latitudeshgosdk.Pointer(\"vm_7vYAZqGBdMQ94\"),\n            Attributes: components.VirtualMachineUpdatePayloadAttributes{\n                Name: latitudeshgosdk.Pointer(\"my-updated-vm\"),\n            },\n        },\n    })\n    if err != nil {\n        log.Fatal(err)\n    }\n    if res.VirtualMachine != nil {\n        // handle response\n    }\n}"
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Latitudesh } from "latitudesh-typescript-sdk";

            const latitudesh = new Latitudesh({
              bearer: process.env["LATITUDESH_BEARER"] ?? "",
            });

            async function run() {
              const result = await latitudesh.virtualMachines.updateVirtualMachine({
                virtualMachineId: "vm_7vYAZqGBdMQ94",
                virtualMachineUpdatePayload: {
                  data: {
                    type: "virtual_machines",
                    id: "vm_7vYAZqGBdMQ94",
                    attributes: {
                      name: "my-updated-vm",
                    },
                  },
                },
              });

              console.log(result);
            }

            run();
components:
  schemas:
    virtual_machine_update_payload:
      type: object
      properties:
        data:
          type: object
          properties:
            type:
              type: string
              enum:
                - virtual_machines
            id:
              type: string
            attributes:
              type: object
              properties:
                name:
                  type: string
                  description: The new display name (hostname) for the Virtual Machine
                tags:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: >-
                    Array of tag IDs to assign to the VM. Replaces all existing
                    tags.
                billing:
                  type: string
                  enum:
                    - hourly
                    - monthly
                    - yearly
                  description: >-
                    Target billing cycle. Upgrades only (hourly → monthly →
                    yearly); downgrades and reserved-project changes return 422.
                plan:
                  type: string
                  description: >-
                    Target plan slug for a vertical upgrade. Upgrades only (cpu,
                    memory, and/or storage must scale up; nothing may shrink).
                    The VM is powered off to apply the new resources and powered
                    back on. Must be sent on its own (cannot be combined with
                    name, tags, or billing). Returns 202 Accepted.
          required:
            - type
            - attributes
      required:
        - data
    virtual_machine:
      type: object
      properties:
        data:
          $ref: '#/components/schemas/virtual_machine_attributes'
        meta:
          type: object
    virtual_machine_attributes:
      type: object
      properties:
        id:
          type: string
        type:
          type: string
          enum:
            - virtual_machines
        attributes:
          type: object
          properties:
            name:
              type: string
            created_at:
              type: string
            status:
              type: string
              description: >-
                Current lifecycle status of the VM, derived from the underlying
                KubeVirt phase/printable status and capitalized. This is an open
                set that may grow over time — do not treat it as a closed enum.
                Known values include: Running, Starting, Stopped, Stopping,
                Failed, Off, Error, Rebooting, Deleting, Destroying, Configuring
                network, Scheduling, Scheduled, Provisioning.
            primary_ipv4:
              type: string
              nullable: true
            operating_system:
              type: object
              nullable: true
              description: The operating system installed on the virtual machine
              properties:
                name:
                  type: string
                  description: The full name of the operating system
                slug:
                  type: string
                  description: The unique slug identifier for the operating system
                version:
                  type: string
                  description: The version of the operating system
                features:
                  type: object
                  description: Features supported by this operating system
                  properties:
                    raid:
                      type: boolean
                      description: Whether RAID is supported
                    ssh_keys:
                      type: boolean
                      description: Whether SSH keys are supported
                    user_data:
                      type: boolean
                      description: Whether user data is supported
                    rescue:
                      type: boolean
                      description: Whether rescue mode is supported
                    workflow:
                      type: boolean
                      description: Whether workflow is supported
                distro:
                  type: object
                  description: Distribution information
                  properties:
                    name:
                      type: string
                      description: The name of the Linux distribution
                    slug:
                      type: string
                      description: The slug of the Linux distribution
                    series:
                      type: string
                      description: The distribution series code name
            credentials:
              type: object
              nullable: true
              description: >-
                SSH credentials for connecting to the virtual machine. Only
                available when the VM is running. Opt-in extra field: request
                via `extra_fields[virtual_machines]=credentials`.
              properties:
                username:
                  type: string
                  nullable: true
                  description: >-
                    The SSH username for the VM, determined by the operating
                    system (e.g., ubuntu, centos, ec2-user). Defaults to ubuntu
                    if not specified by the OS. Returns null when the VM is not
                    running.
                host:
                  type: string
                  nullable: true
                password:
                  type: string
                  nullable: true
                ssh_keys:
                  type: array
                  nullable: true
                  items:
                    type: object
                    properties:
                      id:
                        type: string
                      name:
                        type: string
                      fingerprint:
                        type: string
                      public_key:
                        type: string
                      created_at:
                        type: string
                      updated_at:
                        type: string
            site:
              type: string
              nullable: true
            billing:
              type: string
              nullable: true
            user_data:
              type: string
              nullable: true
              description: Encoded ID of the user data record applied to this VM, if any
            plan:
              type: object
              properties:
                id:
                  type: string
                name:
                  type: string
            specs:
              type: object
              properties:
                vcpu:
                  type: integer
                  nullable: true
                ram:
                  type: string
                  nullable: true
                storage:
                  type: string
                  nullable: true
                nic:
                  type: string
                  nullable: true
                gpu:
                  type: string
                  nullable: true
            tags:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  name:
                    type: string
                  description:
                    type: string
                    nullable: true
                  color:
                    type: string
                    nullable: true
            team:
              $ref: '#/components/schemas/team_include'
            project:
              $ref: '#/components/schemas/project_include'
            pending_restart:
              type: boolean
              description: >-
                Opt-in extra field. Request via
                `extra_fields[virtual_machines]=pending_restart`.
    team_include:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        description:
          type: string
          nullable: true
        address:
          type: string
          nullable: true
        currency:
          type: object
          properties:
            id:
              type: string
            code:
              type: string
            name:
              type: string
            currency_id:
              type: integer
              nullable: true
        status:
          type: string
          nullable: true
        feature_flags:
          type: array
          items:
            type: string
        limits:
          type: object
          properties:
            bare_metal:
              type: integer
              nullable: true
            bare_metal_gpu:
              type: integer
              nullable: true
            virtual_machine:
              type: integer
              nullable: true
            virtual_machine_gpu:
              type: integer
              nullable: true
            elastic_ip:
              type: integer
              nullable: true
            virtual_network:
              type: integer
              nullable: true
            database:
              type: integer
              nullable: true
            filesystem:
              type: integer
              nullable: true
            block_storage:
              type: integer
              nullable: true
    project_include:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        description:
          type: string
          nullable: true
        billing_type:
          type: string
          nullable: true
        provisioning_type:
          type: string
          nullable: true
        billing_method:
          type: string
          nullable: true
        bandwidth_alert:
          type: boolean
        environment:
          type: string
          nullable: true
        billing:
          type: object
          properties:
            subscription_id:
              type: string
              nullable: true
            type:
              type: string
            method:
              type: string
        stats:
          type: object
          properties:
            databases:
              type: integer
            ip_addresses:
              type: integer
            prefixes:
              type: integer
            servers:
              type: integer
            storages:
              type: integer
            virtual_machines:
              type: integer
            vlans:
              type: integer
  securitySchemes:
    Bearer:
      type: apiKey
      name: Authorization
      in: header

````