# Creating and Deleting a VM

## Create a VM via the API

Use the `POST /v3/flexVM/clouds/{cloudUuid}/vms` endpoint with a JSON body.

**Example request:**

```http
POST /v3/flexVM/clouds/{cloudUuid}/vms
Host: api.i3d.net
PRIVATE-TOKEN: YOUR_API_KEY
Content-Type: application/json

{
  "description": "DB1 VM",
  "image_name": "ubuntu-2404-server-amd64",
  "instance_type_name": "vm.gpu.1rtx4000.30c.240g",
  "name": "development.ubuntu-2404",
  "ssh_keys": [
    "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTuRa6Gtysdg2EF+SIXheVFVpHJrKYs4kWfNoHQg8ZG6PH4= ecdsa-key-20240131"
  ],
  "tags": [
    "project:odyssey",
    "env:build"
  ]
}
```

{% hint style="info" %}
Response (201 Created) returns the VM object including its vmUuid and initial status (provisioning).\
The VM will transition through provisioning → starting → running.\
You can monitor its status using the GET VM endpoint.
{% endhint %}

## Create a VM with Terraform

Similar to the API endpoint, you'll need an API token for using the Terraform provider. The procedure is documented in [API v3 Authentication](/game-hosting/overview/apiv3-authentication.md)

**Example Usage:**

```hcl
resource "i3dnet_flexvm_vm" "my-vm" {
  cloud_id           = "019256ab-1554-73a7-b091-f024b0a724ea"
  name               = "test-gaming-vm1"
  description        = "Test Gaming VM 1"
  instance_type_name = "vm.gpu.1rtx4000.30c.240g"
  image_name         = "ubuntu-2404-server-amd64"
  ssh_keys           = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHwdgjY0AlmkeLknBpoVmJg/quNSifyBHEK1MREpV4Ri john.doe@i3d.net"]
}
```

## Deleting a VM

Use the `DELETE /v3/flexVM/clouds/{cloudUuid}/vms/{vmUuid}` endpoint with a JSON body.

**Example request:**

```http
DELETE /v3/flexVM/clouds/{cloudUuid}/vms/{vmUuid}
Host: api.i3d.net
PRIVATE-TOKEN: YOUR_API_KEY
Content-Type: application/json
{
}
```

{% hint style="danger" %}
The VM LVM disk and NVMe passthrough disk will be immediately wiped
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.i3d.net/compute/flexvm/creating-and-deleting-a-vm.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
