---
title: "Give a site its own VM"
description: "Gives a site its own VM, an always-on Ubuntu machine with sudo, and waits until it runs and serves the site."
canonical: "https://www.cool.computer/docs/api-reference/computers/give-a-site-its-own-vm"
---
# Give a site its own VM

> Gives a site its own VM, an always-on Ubuntu machine with sudo, and waits until it runs and serves the site.

```http
POST https://api.cool.computer/api/computers/{id}/vm
```

Gives a site its own VM, an always-on Ubuntu machine with sudo, and waits until it runs and serves the site. This cannot be undone: the VM uses 1 of the account's 20 VMs and memory from the account's 8 GiB, which all its VMs share, the published files move to /home/runtime/app and keep serving at the computer's URL, and publishing to it stops (409 computer_has_vm); change its files with the files API or exec instead. Repeating it is safe: a computer that already has its VM answers changed false, and if an earlier attempt left its link on the published site, repeating it also finishes moving the link (502 artifact_deploy_failed while that still fails). Exec, terminals, the port proxy and exposure need a VM and never give one. Only the computer's own account may give it one: someone it is shared with gets 403 owner_required. It takes no Idempotency-Key: repeating it is safe, and a retry after a lost answer reports changed false while the computer has its VM.

## Authorization

- A Cool Computers API key, user access token, or claimed agent access token in the Authorization header. Follow https://www.cool.computer/auth.md for agent registration and https://www.cool.computer/authentication.md for direct user credentials.

## Parameters

- `id` (path, string, at least 1 characters, required): The computer's name, such as agent-atlas, or its id (cmp_…). Every caller may use either, the computer's own runtime token included.

## Responses

- `200`: The computer with its VM; changed says whether this request attached it.
  - `application/json` (object)
    - `computer` (object, required)
      - `id` (string, required)
      - `hostname` (string, required)
      - `name` (string, required)
      - `ip` (string, required)
      - `status` (string, required): artifact (no VM), creating, running, stopped while its account's Pro has lapsed (its VM is stopped and deleted at auto_delete_at unless Pro returns; once Pro returns it can show running briefly until the reconciler has started its VM), or deleting from when its deletion begins until it is gone.
      - `url` (string, uri)
      - `email_address` (string, email)
      - `visibility` ("private" or "public", required)
      - `access` ("owner" or "can_use" or "claim_key", required): What the caller holds: owner, can_use for a computer shared with them, or claim_key in the response to a publish without an account, whose claim key republishes to the computer and claims it.
      - `copy_enabled` (boolean, required): People other than the owner may copy the computer into their own accounts (PUT /api/computers/{id}/copy-settings).
      - `site` (boolean, required): The URL serves the computer's published files: from the edge, or from its VM's built-in site server until a port is first exposed, when the program on it takes every path but the functions' for good.
      - `network_policy` (object, required): Outbound access policy. open allows public destinations, none blocks outbound access, and allowlist permits only the named public hosts. Private and reserved addresses remain blocked.
        - `mode` ("open" or "none" or "allowlist", required)
        - `allowed_hosts` (array of string, at most 100 items): Required and non-empty only when mode is allowlist. Each value is a hostname, public IP, or leading wildcard such as \*.example.com, without a scheme, port, path, or CIDR.
      - `created_at` (string, date-time, required)
      - `auto_delete_at` (string or null, date-time): When the computer is deleted by itself: its own auto-delete deadline, or, for a VM of an account whose Pro lapsed, when its stopped VMs are deleted, whichever comes first.
      - `creation_mode` (string)
    - `changed` (boolean, required)
- `401`: Unauthorized.
- `402`: Payment Required. `pro_required`: VMs need Pro; start Pro with cool billing upgrade, or fix a lapsed subscription with cool billing portal, or use the Account page.
- `403`: Forbidden. `owner_required`: only the computer's own account may give it a VM. `sign_in_required`: it was published without an account; sign in and claim it first.
- `404`: Not Found. `computer_not_found`: the computer does not exist or is not yours.
- `409`: Conflict. `account_memory_full`: the account's computers use its 8 GiB; stop a program or delete a computer, then retry. `publish_in_progress`: a publish of it is deploying; wait for Retry-After seconds, then retry. Otherwise inspect the problem code and resolution.
- `429`: Too Many Requests. If the problem code is api_request_rate_exceeded, wait for Retry-After seconds; other problem codes describe a separate limit.
- `500`: Internal Server Error.
- `502`: Bad Gateway. `linux_create_failed`: giving the site its VM failed and it stays a site, served as before; retry. `artifact_deploy_failed`: the site has its VM and keeps it, but its link did not move there yet; repeat this request to finish moving it, which the platform also retries.
- `503`: Service Unavailable. No host has room right now; retry after Retry-After seconds.
- `default`: A machine-readable API error with a stable code and recovery instruction.

An error is an `application/problem+json` document with a stable `code`; [API errors](/docs/api-reference/errors) says how to handle one.

## Example

```sh
curl -X POST "https://api.cool.computer/api/computers/$PARAM_ID/vm" \
  -H "authorization: Bearer $TOKEN"
```
