# Share a port

> Give a port of the VM a URL, for the internet or for the devices of the tenant.

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

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

```python Python
import os

import requests

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

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

```json 201 (excerpt)
{
  "name": "web1",
  "port": 8000,
  "url": "https://web1-8000--acme.shakoapp.dev",
  "tcp": "tcp.shako.dev:10042",
  "warnings": []
}
```

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

**port** `integer, 1 to 65535` *required*

The port in the VM, 1 to 65535. A program must listen on it on 0.0.0.0, not on 127.0.0.1.

**access** `string (public, private)` (default: public)

public: anyone on the internet can open the URL. private: only the devices of the tenant can open it.

## Response

201 with [the shared port object](https://shako.dev/api/objects/exposed.md).

## Behavior

warnings in the answer says if no program listens on the port of an awake VM yet (then a request gets 502), or if the public port is usually a database's.

The errors: https://shako.dev/api/errors.md. All the endpoints of Ports: https://shako.dev/api/ports.md.
