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

# Create a new VM



## OpenAPI

````yaml /api-reference/openapi.yml post /project/{project_id}/location/{location}/vm/{vm_reference}
openapi: 3.0.3
info:
  description: API for managing resources on Ubicloud
  title: Clover API
  version: 0.1.0
  contact:
    url: https://www.ubicloud.com/
    email: support@ubicloud.com
  license:
    name: GNU Affero General Public License v3.0 (AGPL-3.0)
    url: https://www.gnu.org/licenses/agpl-3.0.en.html
servers:
  - url: https://api.ubicloud.com
security:
  - BearerAuth: []
tags:
  - description: Firewall Operations
    name: Firewall
  - description: Firewall Rule Operations
    name: Firewall Rule
  - description: Inference API Key Operations
    name: Inference Api Key
  - description: Inference Endpoint Operations
    name: Inference Endpoint
  - description: Load Balancer Operations
    name: Load Balancer
  - description: Login Operations
    name: Login
  - description: Machine Image Operations
    name: Machine Image
  - description: Postgres Database Operations
    name: Postgres Database
  - description: Postgres Firewall Rule Operations
    name: Postgres Firewall Rule
  - description: Postgres Metric Destination
    name: Postgres Metric Destination
  - description: Postgres Log Destination
    name: Postgres Log Destination
  - description: Private Subnet Operations
    name: Private Subnet
  - description: Project Operations
    name: Project
  - description: Virtual Machine Operations
    name: Virtual Machine
  - description: Private Location Operations
    name: Private Location
  - description: Kubernetes Cluster Operations
    name: Kubernetes Cluster
  - description: SSH Public Key Operations
    name: SSH Public Key
  - description: GitHub Operations
    name: GitHub
  - description: Audit Log Operations
    name: Audit Log
paths:
  /project/{project_id}/location/{location}/vm/{vm_reference}:
    parameters:
      - $ref: '#/components/parameters/project_id'
      - $ref: '#/components/parameters/location'
      - $ref: '#/components/parameters/vm_reference'
    post:
      tags:
        - Virtual Machine
      summary: Create a new VM
      operationId: createVM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                boot_image:
                  description: Boot image of the VM
                  type: string
                init_script:
                  description: VM init script
                  type: string
                enable_ip4:
                  description: Enable IPv4
                  type: boolean
                private_subnet_id:
                  description: ID of the private subnet
                  type: string
                public_key:
                  description: >-
                    Public SSH key for the VM, or name of registered SSH public
                    key
                  type: string
                size:
                  description: Size of the VM
                  type: string
                storage_size:
                  description: Requested storage size in GiB
                  type: integer
                gpu:
                  description: Requested GPU count and type, in the form of "count:type"
                  type: string
                unix_user:
                  description: Unix user of the VM
                  type: string
              additionalProperties: false
              required:
                - public_key
      responses:
        '200':
          $ref: '#/components/responses/Vm'
        default:
          $ref: '#/components/responses/Error'
components:
  parameters:
    project_id:
      description: ID of the project
      in: path
      name: project_id
      required: true
      schema:
        type: string
        example: pjkkmx0f2vke4h36nk9cm8v8q0
        pattern: ^pj[0-9a-hj-km-np-tv-z]{24}$
    location:
      description: The Ubicloud location/region
      in: path
      name: location
      required: true
      schema:
        type: string
        example: eu-central-h1
    vm_reference:
      description: Virtual machine ID or name
      examples:
        id:
          value: vmn30gjk1d1e2jj34v9x0dq4rp
        name:
          value: virtual-machine-name
      in: path
      name: vm_reference
      required: true
      schema:
        $ref: '#/components/schemas/Reference'
  responses:
    Vm:
      description: A VM
      content:
        application/json:
          schema:
            type: object
            additionalProperties: false
            allOf:
              - $ref: '#/components/schemas/Vm'
              - additionalProperties: false
                properties:
                  firewalls:
                    description: List of firewalls
                    type: array
                    items:
                      $ref: '#/components/schemas/Firewall'
                  private_ipv4:
                    description: Private IPv4 address
                    type: string
                    format: ipv4
                  private_ipv6:
                    description: Private IPv6 address
                    type: string
                    format: ipv6
                  subnet:
                    description: Subnet of the VM
                    type: string
                  unix_user:
                    description: Unix user of the VM
                    type: string
                  gpu:
                    description: GPU configuration
                    type: string
                required:
                  - firewalls
                  - private_ipv4
                  - private_ipv6
                  - subnet
                  - unix_user
    Error:
      description: An error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Reference:
      description: Resource ID or name
      type: string
      pattern: ^[a-z0-9](?:[a-z0-9\-]{0,61}[a-z0-9])?$
    Vm:
      type: object
      properties:
        boot_image:
          description: Boot image of the VM
          type: string
        id:
          description: ID of the VM
          type: string
          example: vmhfy8gff8c67hasb0eez2k1pd
          pattern: ^vm[0-9a-hj-km-np-tv-z]{24}$
        ip4:
          description: IPv4 address
          type: string
          format: ipv4
          nullable: true
        ip4_enabled:
          description: Whether IPv4 is enabled
          type: boolean
        ip6:
          description: IPv6 address
          type: string
          format: ipv6
          nullable: true
        location:
          description: Location of the VM
          type: string
          example: eu-central-h1
        name:
          description: Name of the VM
          type: string
          example: my-vm-name
        size:
          description: Size of the underlying VM
          type: string
        state:
          description: State of the VM
          type: string
        storage_size_gib:
          description: Storage size in GiB
          type: integer
        unix_user:
          description: Unix user of the VM
          type: string
      additionalProperties: false
      required:
        - boot_image
        - id
        - ip4
        - ip4_enabled
        - ip6
        - location
        - name
        - size
        - state
        - storage_size_gib
        - unix_user
    Firewall:
      type: object
      properties:
        description:
          description: Description of the firewall
          type: string
        firewall_rules:
          description: List of firewall rules
          type: array
          items:
            $ref: '#/components/schemas/FirewallRule'
        id:
          description: ID of the firewall
          type: string
          example: fwfg7td83em22qfw9pq5xyfqb7
          pattern: ^fw[0-9a-hj-km-np-tv-z]{24}$
        location:
          description: Location of the the firewall
          type: string
        name:
          description: Name of the firewall
          type: string
      additionalProperties: false
      required:
        - description
        - firewall_rules
        - id
        - location
        - name
    Error:
      type: object
      properties:
        error:
          type: object
          additionalProperties: false
          properties:
            code:
              type: integer
              example: 401
            message:
              type: string
              example: There was an error logging in
            type:
              type: string
              example: InvalidCredentials
            details:
              type: object
              nullable: true
          required:
            - code
            - message
            - type
      additionalProperties: false
      required:
        - error
    FirewallRule:
      type: object
      properties:
        cidr:
          description: CIDR of the firewall rule
          type: string
        id:
          description: ID of the firewall rule
          type: string
          example: fraz0q3vbrpa7pkg7zbmah9csn
          pattern: ^fr[0-9a-hj-km-np-tv-z]{24}$
        port_range:
          description: Port range of the firewall rule
          type: string
        protocol:
          description: Protocol of the firewall rule (tcp or udp)
          type: string
          enum:
            - tcp
            - udp
        description:
          description: Description of the firewall rule
          type: string
      additionalProperties: false
      required:
        - cidr
        - id
        - port_range
        - protocol
        - description
  securitySchemes:
    BearerAuth:
      bearerFormat: JWT
      scheme: bearer
      type: http

````