# Rename a VM

> Give a VM a new name. Its SSH name and the URLs of its public ports change, and the old ones stop.

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

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

```python Python
import os

import requests

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

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

```json 200 (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.

**name** `string` *required*

The VM's name.

## Request body

**new_name** `string` *required*

The new name, by the rule of a new VM's name. The VM's SSH name and the URLs of its public ports change too, and the old ones stop at once.

## Response

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

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