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

# Create a Basic VM

> Create a Basic VM with a local system disk and a shared-CPU flavor.

## Customer Portal

A Basic VM uses shared CPU. The type includes the local SSD together with the vCPU and memory. Select the region, the image, and the type to create one.

1\. Log in to the [Gcore Customer Portal](https://portal.gcore.com) and open **Basic VMs**.

2\. Click **Create Basic VM**.

![Basic VMs page with Create Basic VM](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/basic-vms-page.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=df20ef19a5136ba94df8eb7be787ca10)

3\. Select a region.

![Region card for a Basic VM](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-region.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=1bec3c29b52326b80f76533c9777fc24)

4\. Select an image. The login user depends on that image. Ubuntu uses `ubuntu`.

![Ubuntu and CentOS image cards](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-image.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=c02fb418e8d3f9c3922b1a476e866b46)

![SSH login shown for the selected image](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-image-login.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=975d5a47eac164791c7d396670788b26)

5\. Select a type for the vCPU, memory, and local SSD you need. These types share the host and have no SLA. One type is 1 vCPU, 1 GiB, and 25 GiB SSD.

![Shared-CPU sizes for a Basic VM](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-type.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=4ef142f39d8a2303e582d0e2eb7976fa)

6\. Select an SSH key.

![Required SSH key field](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-ssh-key.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=daeaf8d8ec7b5d19da336ae886ec7d6c)

7\. (Optional) The network starts on the Gcore public pool, with a new port, one IPv4 address, and **Included Basic DDoS Protection**. Open **Advanced settings** to use another network, add tags, or set user data. Up to five networks can be added.

![Default public network in Advanced settings](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-advanced.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=d93a5e871e1f4296d35809a2fbe8b1e3)

8\. Set the quantity. Up to 10 VMs can be created at a time.

![Quantity control for Basic VMs](https://mintcdn.com/gcore/KcLJOgb4Y9HJAr3C/images/docs/cloud/virtual-instances/create-a-basic-vm/create-quantity.png?fit=max\&auto=format\&n=KcLJOgb4Y9HJAr3C\&q=85\&s=7dcbf6d0d3ceaf2de1c879cce3d9300f)

9\. Click **Create Basic VM**. The VM is listed with status Active.

10\. Log in with the SSH key from step 6 and the user from step 4. For Ubuntu, the login is `ssh ubuntu@ipaddress`. Replace `ipaddress` with the address assigned to the VM.

## REST API

Send `region_id` in the body and attach a port that already exists in that same region. Use that region for the image, the flavor, and the VM.

> [!NOTE]
>
> An [API token](https://docs.gcore.com/account-settings/api-tokens.md) is required, along with a [project ID](https://docs.gcore.com/api-reference/cloud/projects/list-projects.md) and a pre-created [port](https://docs.gcore.com/cloud/networking/ip-address/create-a-port.md) in the target region.

`REGION_ID` is the numeric ID of a region that supports Basic VMs. Query the [regions API](https://docs.gcore.com/api-reference/cloud/regions/list-regions.md) and filter for regions where `has_basic_vm` is true.

```bash theme={null}
export GCORE_API_KEY="{YOUR_API_KEY}"
export GCORE_CLOUD_PROJECT_ID="{YOUR_PROJECT_ID}"
export REGION_ID="{REGION_ID}"
export PORT_ID="{YOUR_PORT_ID}"
export SSH_KEY_ID="{YOUR_SSH_KEY_ID}"
```

## Step 1. Select an image

Query the public images for the region and save the ID of a Linux image.

```bash theme={null}
curl "https://api.gcore.com/cloud/v1/images/$GCORE_CLOUD_PROJECT_ID/$REGION_ID?visibility=public" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

```bash theme={null}
export IMAGE_ID="{IMAGE_ID}"
```

## Step 2. Select an SSH key

List the keys in the project and copy `id` into `SSH_KEY_ID`. The create request adds that key to the image user, so you can log in with it. Ubuntu uses the user `ubuntu`.

```bash theme={null}
curl "https://api.gcore.com/cloud/v1/ssh_keys/$GCORE_CLOUD_PROJECT_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

## Step 3. List Basic VM flavors

Filter the list with `region_ids` and copy a flavor whose `region_id` is that same region. `disk_gib` is the local SSD that flavor creates, and `name` is the value for `FLAVOR_NAME`.

```bash theme={null}
curl "https://api.gcore.com/cloud/v1/projects/$GCORE_CLOUD_PROJECT_ID/basic_vms/flavors?region_ids=$REGION_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

The API returns:

```json theme={null}
{
  "results": [
    {"name": "g2s-shared-1-1-25", "vcpus": 1, "ram_mib": 1024, "disk_gib": 25, "region_id": 124}
  ]
}
```

```bash theme={null}
export FLAVOR_NAME="g2s-shared-1-1-25"
```

## Step 4. Create the Basic VM

The flavor creates the local boot disk, so this request has no volume fields. `region_id` is the same value as `REGION_ID` and as the flavor's `region_id`.

| Parameter | Required | Description |
| - | - | - |
| `region_id` | Yes | Numeric ID of the target region. |
| `flavor_name` | Yes | Shared-CPU flavor name from Step 3. |
| `image_id` | Yes | Linux image ID from Step 1 |
| `interfaces[].port_id` | Yes | Port in the same region. Several entries attach several network interfaces |
| `name` | No | Display name. If omitted, Gcore assigns one |
| `ssh_key_id` | No | SSH key ID from Step 2. The request below sends it |
| `user_data` | No | Base64-encoded cloud-init script. |
| `tags` | No | Key-value map of labels. |

```bash theme={null}
curl -X POST "https://api.gcore.com/cloud/v1/projects/$GCORE_CLOUD_PROJECT_ID/basic_vms" \
  -H "Authorization: APIKey $GCORE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "region_id": '"$REGION_ID"',
    "flavor_name": "'"$FLAVOR_NAME"'",
    "image_id": "'"$IMAGE_ID"'",
    "ssh_key_id": "'"$SSH_KEY_ID"'",
    "interfaces": [{"port_id": "'"$PORT_ID"'"}]
  }'
```

The API returns:

```json theme={null}
{"tasks": ["11111111-1111-4111-8111-111111111111"]}
```

Copy `tasks[0]` from that response.

```bash theme={null}
export TASK_ID="{YOUR_TASK_ID}"
```

Poll `GET /cloud/v1/tasks/` every 5 seconds until `state` is `FINISHED`, then read the VM ID from `created_resources.basic_vm`.

```bash theme={null}
curl "https://api.gcore.com/cloud/v1/tasks/$TASK_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

When complete:

```json theme={null}
{
  "state": "FINISHED",
  "created_resources": {
    "basic_vm": ["a1b2c3d4-..."]
  }
}
```

```bash theme={null}
export BASIC_VM_ID="{BASIC_VM_ID}"
```

## Step 5. Get Basic VM details

Each interface is the port and the address on that port. `region_id` is the region from Step 4. Log in as the image user with the key from Step 2. For Ubuntu, the address in this response is the host in `ssh ubuntu@203.0.113.10`.

```bash theme={null}
curl "https://api.gcore.com/cloud/v1/projects/$GCORE_CLOUD_PROJECT_ID/basic_vms/$BASIC_VM_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

The API returns:

```json theme={null}
{
  "id": "a1b2c3d4-...",
  "name": "my-basic-vm",
  "status": "active",
  "region_id": 124,
  "flavor_name": "g2s-shared-1-1-25",
  "ssh_key_id": "{SSH_KEY_ID}",
  "interfaces": [
    {
      "port_id": "e5f6a7b8-...",
      "ip_assignments": [
        {"ip_address": "203.0.113.10", "floating_ip": null}
      ]
    }
  ]
}
```

## Change the Basic VM

Rename the VM, change its tags, or replace its ports. This request is separate from creation.

| Field | Description |
| - | - |
| `name` | New display name. |
| `tags` | Merge-patch map. A `null` value removes the key. |
| `interfaces[]` | Full list of port IDs. Ports in the list but not currently attached are attached; ports currently attached but not in the list are detached. |

```bash theme={null}
curl -X PATCH "https://api.gcore.com/cloud/v1/projects/$GCORE_CLOUD_PROJECT_ID/basic_vms/$BASIC_VM_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-basic-vm-renamed"}'
```

The API returns:

```json theme={null}
{"tasks": ["c7d8e9f0-..."]}
```

Poll the task until `state` is `FINISHED`.

## Delete the Basic VM

Delete removes the VM and the local boot disk the flavor created. The ports are detached and stay in the project.

```bash theme={null}
curl -X DELETE "https://api.gcore.com/cloud/v1/projects/$GCORE_CLOUD_PROJECT_ID/basic_vms/$BASIC_VM_ID" \
  -H "Authorization: APIKey $GCORE_API_KEY"
```

The API returns:

```json theme={null}
{"tasks": ["f1a2b3c4-..."]}
```

Poll the task until `state` is `FINISHED`.
