# Create a VM

> Create a VM and boot it. Every field but name is optional.

`POST /v1/tenants/{tenant}/vms`

```bash curl
curl -X POST "https://api.shako.dev/v1/tenants/acme/vms" \
  -H "Authorization: Bearer $SHAKO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"web1","size":"small"}'
```

```python Python
import os

import requests

response = requests.post(
    "https://api.shako.dev/v1/tenants/acme/vms",
    headers={"Authorization": f"Bearer {os.environ['SHAKO_API_KEY']}"},
    json={
        "name": "web1",
        "size": "small",
    },
)
response.raise_for_status()
print(response.json())
```

```javascript JavaScript
const response = await fetch("https://api.shako.dev/v1/tenants/acme/vms", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.SHAKO_API_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "name": "web1",
    "size": "small"
  }),
});
if (!response.ok) throw new Error(await response.text());
console.log(await response.json());
```

```json 201 (excerpt)
{
  "name": "web1",
  "tenant": "acme",
  "state": "awake",
  "ssh": "web1.acme.shako.dev",
  "vcpus": 1,
  "mem_mib": 2048,
  "disk_gb": 10
}
```

Authenticate with `Authorization: Bearer <API key>` on `https://api.shako.dev`. Role: contributor or owner.

## Path parameters

**tenant** `string` *required*

The tenant's name, from GET /v1/tenants.

## Request body

**name** `string` *required*

The new VM's name: a-z, 0-9 and single hyphens, starting with a letter, at most 31 characters. It is in the VM's SSH name and in the URLs of its public ports.

**size** `string (small, mid, large, xl)` (default: small)

The size: small (1 vCPU, 2 GB memory, 10 GB disk), mid (2 vCPU, 4 GB memory, 20 GB disk), large (4 vCPU, 8 GB memory, 40 GB disk), xl (4 vCPU, 16 GB memory, 80 GB disk).

**cpus** `integer, 1 to 256`

Custom vCPUs: 1 or an even number. They replace the vCPUs of the size.

**memory** `string`

Custom memory, for example "3G" or "2560M". The disk is 5 GB for each GB of memory. It replaces the memory of the size.

**image** `string` (default: the current release)

The image release, for example "2026.10.27.1".

**sleep** `string (auto, never)` (default: auto)

When the VM sleeps. auto: when it is quiet. never: it stays on, and it restarts after a reboot or a crash. With both, the sleep and wake endpoints work at once.

**idle** `string` (default: 15m)

The quiet time before the VM sleeps, for example "15m" or "2h".

**agents** `string[] (claude, codex, opencode, pi, kiro, openclaw, hermes)` (default: [])

The AI agents or coding agents to put in the VM: claude, codex, opencode, pi, kiro, openclaw, hermes.

**desktop** `boolean` (default: false)

true: a screen and a shared browser, for browser use and computer use by the agents. It needs an agent and 4 GB of memory or more (size mid or bigger).

**role** `string (contributor, none)` (default: contributor)

The VM's role in its tenant. contributor: from the VM, the shako commands and SSH to the other VMs of the tenant work. none: they do not. SSH into the VM, the internet and its URLs work with both.

## Response

201 with [the VM object](https://shako.dev/api/objects/vm-view.md).

## Behavior

The answer comes at once, with the VM creating: the box makes its disk and boots it. Ask GET for the VM until its state is awake (its SSH works then), or failed, with the reason in last_error. A VM of the tenant may not have the name already (409 conflict). The VMs of a tenant have a limit (403 quota), and the tenant needs credit (402 no_credit).

The errors: https://shako.dev/api/errors.md. All the endpoints of VMs: https://shako.dev/api/vms.md.
