# VMs API

> Create, list, start, stop, pause, resume and delete flockvm VMs over the API, read their console log, and handle each error it can answer.

- URL: https://flockvm.com/docs/api/vms
- Section: API
- Last updated: 2026-11-10

The VMs of your organization, as on the dashboard's VM list. Every role can call these routes: members create and drive VMs like owners and admins. The rules are the dashboard's own, so a VM you create here is exactly the VM the **New VM** form would make.

The examples use `$FLOCKVM_API_KEY` for your [API key](https://flockvm.com/docs/api/overview#create-an-api-key). Each route below gives the [action](https://flockvm.com/docs/api/api-keys#actions) the key needs. A key restricted to some environments or VMs only lists and reaches those (and the VMs it created): any other VM answers `404`, as if it did not exist.

## The VM object

```json
{
  "id": "vm_x9n9td",
  "name": "web-1",
  "status": "running",
  "size": "small",
  "vcpu": 2,
  "memory_mb": 4096,
  "disk_gb": 50,
  "image": "ubuntu-26.04-agent",
  "region": "gra",
  "private_ip": "172.16.0.9",
  "ssh": {
    "host": "51.38.56.198",
    "port": 22008,
    "user": "user",
    "command": "ssh -p 22008 user@51.38.56.198"
  },
  "created_at": "2026-11-01T06:18:42.918Z",
  "started_at": "2026-11-01T06:18:42.918Z",
  "paused_at": null,
  "price_hour": 0.016,
  "seconds_billed": 16,
  "cost_usd": 0.0000711111111111111,
  "error": null,
  "environment": { "id": "env_g6dhdxjz", "name": "staging", "version": 4 },
  "runner": null,
  "restriction": null
}
```

`id` (string): The VM's id, `vm_…`. Paths take it: `/vms/vm_x9n9td`.

`name` (string): The name it was created with.

`status` (string): `starting`, `running`, `pausing`, `paused`, `stopping`, `stopped` or `failed`. See [Lifecycle](https://flockvm.com/docs/vms/lifecycle#states) for what each one allows.

`size` (string): `small`, `default`, `large` or `xlarge`, with its `vcpu`, `memory_mb` and `disk_gb`. See [Sizes](https://flockvm.com/docs/vms/sizes).

`image` (string): `ubuntu-26.04-agent` (Agent) or `ubuntu-26.04` (Minimal). Runner VMs show `ubuntu-26.04-runner`. A VM created before 2026-11-01 keeps its Ubuntu 24.04 image id, `ubuntu-24.04-agent` or `ubuntu-24.04`, for its whole life: it is listed and works as any other, but new VMs can no longer use those ids. See [Images](https://flockvm.com/docs/vms/images#vms-created-on-ubuntu-2404).

`region` (string): `gra` for France, the one region today.

`private_ip` (string or null): The VM's address on its own private network.

`ssh` (object): How to log in: the address of its region's host, the VM's own port, the login user (`user` on Agent, `root` on Minimal) and the whole `command`. See [Connect over SSH](https://flockvm.com/docs/vms/ssh).

`created_at` (string): When it was created.

`started_at` (string or null): When its current run started. `null` while it is stopped.

`paused_at` (string or null): When it was paused, while it is `paused`.

`price_hour` (number or null): The price per hour in USD, frozen when the VM was created.

`seconds_billed` (number): The seconds billed so far.

`cost_usd` (number): What they cost, in USD, unrounded.

`error` (string or null): Why the VM is `failed`, when it is.

`environment` (object or null): The [environment](https://flockvm.com/docs/vms/environments) and version the VM was created with. `null` for **No environment**.

`runner` (object or null): `{"repo": "acme/web", "job_id": 31442100020}` on a GitHub Actions runner VM. flockvm drives those: every action on them answers `409`.

`restriction` (object or null): `{"kind": "network", "reason": "…", "since": "…"}` when flockvm has cut the VM's outbound network. See [Acceptable use](https://flockvm.com/docs/security/acceptable-use).

## List VMs

`GET /vms` · Action: `vm.read`

```bash
curl https://flockvm.com/api/v1/vms \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
```

```jsonc
{
  "vms": [
    {
      "id": "vm_qmgj5z",
      "name": "ci-31442100020",
      "status": "running",
      "image": "ubuntu-26.04-runner",
      "runner": { "repo": "acme/web", "job_id": 31442100020 },
      // … every field of the VM object
    },
    {
      "id": "vm_fx7k2m",
      "name": "fix-flaky-tests",
      "status": "running",
      "runner": null,
      // …
    }
  ]
}
```

Every VM of the organization the key reaches, newest first, whoever created it. GitHub Actions runner VMs are listed too, with `runner` set. Deleted VMs are not.

## Create a VM

`POST /vms` · Action: `vm.create`, and `ssh_key.write` with `"save_key": true`

```bash
curl https://flockvm.com/api/v1/vms \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "web-1", "size": "small", "ssh_key_id": "key_ada_laptop"}'
```

```text
HTTP/1.1 201 Created
```

```json
{
  "id": "vm_x9n9td",
  "name": "web-1",
  "status": "starting",
  "size": "small",
  "vcpu": 2,
  "memory_mb": 4096,
  "disk_gb": 50,
  "image": "ubuntu-26.04-agent",
  "region": "gra",
  "private_ip": "172.16.0.9",
  "ssh": { "host": "51.38.56.198", "port": 22008, "user": "user", "command": "ssh -p 22008 user@51.38.56.198" },
  "created_at": "2026-11-01T06:18:42.918Z",
  "started_at": "2026-11-01T06:18:42.918Z",
  "paused_at": null,
  "price_hour": 0.016,
  "seconds_billed": 0,
  "cost_usd": 0,
  "error": null,
  "environment": { "id": "env_5fakhs47", "name": "base", "version": 1 },
  "runner": null,
  "restriction": null
}
```

The VM answers `starting` and turns `running` once SSH answers. Billing starts with `starting`.

`name` (string, required): 1 to 40 characters: lowercase letters, digits and dashes.

`size` (string, required): `small`, `default`, `large` or `xlarge`. `GET /regions` says which ones have room right now. See [Catalog](https://flockvm.com/docs/api/catalog).

`region` (string, default `gra`): Left out, the region marked `"default": true` in `GET /regions`: France (`gra`), the one region today. `par` is refused: the Paris region was retired on 2026-11-10.

`image` (string, default `ubuntu-26.04-agent`): Left out, the image marked `"default": true` in `GET /images`: the Agent image. `ubuntu-26.04` for Minimal. The Ubuntu 24.04 ids are refused with a `400` that names their replacement. See [Images](https://flockvm.com/docs/vms/images).

`ssh_key_id` (string): A key saved in your account, from [`GET /ssh-keys`](https://flockvm.com/docs/api/ssh-keys). Give this or `ssh_public_key`, not both.

`ssh_public_key` (string): A public key, the line of your `.pub` file: `ssh-ed25519 AAAA… you@laptop`. Same formats as the dashboard: see [SSH keys](https://flockvm.com/docs/vms/ssh-keys#accepted-key-formats).

`save_key` (boolean, default `false`): With `ssh_public_key`: also save the key to your account, as the form's **Save this key to my account** does.

`environment` (string, default `the default environment`): The environment's id (`env_…`) or name, such as `staging`. `"none"` for no environment: nothing of your organization goes into the VM, only `env`. Left out, the organization's default environment. Every region. See [Environments](https://flockvm.com/docs/vms/environments).

`env` (object of strings): Variables for this VM only, such as `{"DEBUG": "1"}`, merged over the environment's (the VM's value wins). Same rules and limits as the environment's variables. They still go in with `"none"` and with an environment that is **Safe for third parties**. Every region.

The same rules as the **New VM** form apply:

- A member can only use an environment whose **Members can use it** switch is on, or `"none"`. Otherwise: `403` with `field` `environment`.
- The organization needs its [free trial](https://flockvm.com/docs/billing/trial) started or its plan in order: see [Plan](https://flockvm.com/docs/billing/plan). Otherwise: `403`.
- During the trial, its limits apply: `small` and `default` only (`403 trial_size_not_allowed`), 2 VMs at once (`429 trial_vm_limit`), 5 starts a minute, 25 an hour, 75 a day (`429 trial_rate_limited`), 25 hours of VM time (`429 trial_compute_limit_reached`).
- A suspended organization cannot create VMs: `403` on every `/vms` route, reads included.

### Wait until it is running, then SSH in

```bash
id=$(curl -s https://flockvm.com/api/v1/vms \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "web-1", "size": "small", "ssh_key_id": "key_ada_laptop"}' | jq -r .id)

until [ "$(curl -s https://flockvm.com/api/v1/vms/$id \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" | jq -r .status)" = running ]; do
  sleep 3
done

$(curl -s https://flockvm.com/api/v1/vms/$id \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" | jq -r .ssh.command)
```

Stop waiting if `status` turns `failed`: `error` says why.

### Several VMs at once

Send one `POST /vms` per VM. They start in parallel. When the host has no room left for the size, the next one answers `409 capacity`: see [Limits](https://flockvm.com/docs/vms/limits).

```bash
for i in 1 2 3; do
  curl -s https://flockvm.com/api/v1/vms \
    -H "Authorization: Bearer $FLOCKVM_API_KEY" \
    -H "Content-Type: application/json" \
    -d "{\"name\": \"fix-auth-$i\", \"size\": \"small\", \"ssh_key_id\": \"key_ada_laptop\"}" \
    | jq -r '.ssh.command // .error.message'
done
```

## Get a VM

`GET /vms/{id}` · Action: `vm.read`

```bash
curl https://flockvm.com/api/v1/vms/vm_x9n9td \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
```

Answers the [VM object](#the-vm-object), with its current status.

## Start, stop, pause and resume

`POST /vms/{id}/start`, `POST /vms/{id}/stop`, `POST /vms/{id}/pause`, `POST /vms/{id}/resume` · Action: `vm.power`

```bash
curl -X POST https://flockvm.com/api/v1/vms/vm_x9n9td/pause \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
```

```jsonc
{
  "id": "vm_x9n9td",
  "name": "web-1",
  "status": "pausing",
  "paused_at": null,
  // … every field of the VM object
}
```

| Action | Path                    | From                                      | Answers    | Then                                                                                                          |
| ------ | ----------------------- | ----------------------------------------- | ---------- | ------------------------------------------------------------------------------------------------------------- |
| Pause  | `POST /vms/{id}/pause`  | `running`                                 | `pausing`  | `paused` once the memory snapshot is written (back to `running` if it could not be)                           |
| Resume | `POST /vms/{id}/resume` | `paused`                                  | `running`  | Nothing to wait for: the answer comes once the snapshot is restored, with the same processes, IP and SSH port |
| Stop   | `POST /vms/{id}/stop`   | `starting`, `running`, `paused`, `failed` | `stopping` | `stopped`, disk kept. Stopping a paused VM drops its snapshot                                                 |
| Start  | `POST /vms/{id}/start`  | `stopped`, `failed`                       | `starting` | `running` once SSH answers: a cold boot on the same disk                                                      |

No body. The answer is the VM right after the action. Poll [`GET /vms/{id}`](#get-a-vm) to see pause, stop and start settle. An action the state does not allow answers `409 conflict`:

```json
{ "error": { "code": "conflict", "message": "cannot pause a VM that is stopped" } }
```

Resume can also answer `409 conflict` when the pause snapshot is missing: the VM is then `stopped` with its disk intact, and start boots it again (its memory state is lost).

Start, resume and pause can answer `409 capacity`, without `field`, when the host has no room right now: not enough memory or vCPU to start or resume the VM, or not enough disk for the memory snapshot of a pause. Try again later, or pause or stop another VM first.

Start and resume need the free trial started or the plan in order, like creating a VM: otherwise `403`. During the trial they count as starts, with the same limits as creating. Pause and stop don't. What each action keeps and costs: [Lifecycle](https://flockvm.com/docs/vms/lifecycle).

## Delete a VM

`DELETE /vms/{id}` · Action: `vm.delete-own` for a VM this key created, `vm.delete` for any VM

```bash
curl -X DELETE https://flockvm.com/api/v1/vms/vm_x9n9td \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
```

```text
HTTP/1.1 204 No Content
```

A key with **Create and use VMs** (`vm.delete-own`) deletes only the VMs it created itself: any other VM answers `403 insufficient_scope` with `field` `vm.delete`.

Deletes the VM in any state, with its disk and its pause snapshot (a runner VM answers `409`: flockvm deletes it when its job ends). There is no undo and no backup: see [Deleting a VM deletes its data](https://flockvm.com/docs/security/isolation#deleting-a-vm-deletes-its-data).

## Console log

`GET /vms/{id}/logs` · Action: `vm.logs`

```bash
curl "https://flockvm.com/api/v1/vms/vm_fx7k2m/logs?tail=5" \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
```

```json
{
  "lines": [
    "resize2fs 1.47.0 (5-Feb-2023)",
    "Filesystem at /dev/vda is mounted on /; on-line resizing required",
    "old_desc_blocks = 1, new_desc_blocks = 7",
    "The filesystem on /dev/vda is now 13107200 (4k) blocks long.",
    ""
  ]
}
```

The last lines of the VM's serial console, oldest first: what the **Console** section of the VM page shows. `tail` is how many, from 1 to 1000 (200 when left out). See [Monitoring](https://flockvm.com/docs/vms/monitoring).

## Errors

| Status | `code`                        | Example `message`                                                                                                                                                                     | When                                                                                                                                               |
| ------ | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| 400    | `bad_request`                 | "Name: 1 to 40 characters, lowercase letters, digits and dashes." (`field`: `name`)                                                                                                   | A field is missing, of the wrong type, or breaks a rule. `field` names it.                                                                         |
| 400    | `bad_request`                 | "Unknown field "colour". Fields: name, size, region, image, ssh_key_id, ssh_public_key, save_key, environment, env."                                                                  | A field the API does not know.                                                                                                                     |
| 400    | `bad_request`                 | "Give ssh_key_id (a key saved in your account, GET /api/v1/ssh-keys) or ssh_public_key."                                                                                              | No SSH key, or both.                                                                                                                               |
| 400    | `bad_request`                 | "Pick a size." (`field`: `size`), "Pick a region.", "Pick an image."                                                                                                                  | A size, region or image that is not offered to your organization.                                                                                  |
| 400    | `bad_request`                 | "ubuntu-24.04 (Ubuntu 24.04) is no longer offered for new VMs: use ubuntu-26.04. VMs created from it keep their image." (`field`: `image`)                                            | An Ubuntu 24.04 image id: `ubuntu-24.04-agent` becomes `ubuntu-26.04-agent`, `ubuntu-24.04` becomes `ubuntu-26.04`.                                |
| 400    | `bad_request`                 | "tail: a whole number from 1 to 1000." (`field`: `tail`)                                                                                                                              | `tail` out of range.                                                                                                                               |
| 401    | `unauthorized`                | "This API key was revoked."                                                                                                                                                           | See [Errors](https://flockvm.com/docs/api/overview#errors).                                                                                        |
| 403    | `insufficient_scope`          | "This API key cannot create VMs: it needs vm.create." (`field`: `vm.create`)                                                                                                          | The key's actions do not cover the route. `field` is the action it needs. See [API keys and scopes](https://flockvm.com/docs/api/api-keys#errors). |
| 403    | `forbidden`                   |                                                                                                                                                                                       | Create with a key restricted to environments, without one of them in `environment`.                                                                |
| 403    | `forbidden`                   | "Only owners and admins can create VMs with the environment staging. Pass another one open to members, or "none" for no environment." (`field`: `environment`)                        | A member and an environment not open to members, named or the default one.                                                                         |
| 403    | `forbidden`                   | "Start the 7-day free trial or the plan in Settings › Billing to create or start VMs. Card required, nothing charged for 7 days, then $18/month, which comes back as $18 of VM time." | Create, start or resume without the free trial started or the plan in order, or with no money left. The exact message follows the billing state.   |
| 403    | `forbidden`                   | "This organization is suspended. Contact the flockvm team."                                                                                                                           | The organization is suspended.                                                                                                                     |
| 403    | `trial_size_not_allowed`      |                                                                                                                                                                                       | Create during the free trial with `large` or `xlarge`.                                                                                             |
| 404    | `not_found`                   | "No VM with this id."                                                                                                                                                                 | No such VM, a malformed id, a VM of another organization, or one the key's restrictions do not reach, for a read as for an action.                 |
| 404    | `not_found`                   | "This SSH key is not in your account." (`field`: `ssh_key_id`)                                                                                                                        | A saved key that is not yours.                                                                                                                     |
| 404    | `not_found`                   | "No environment with this id or name in this organization (GET /api/v1/environments)." (`field`: `environment`)                                                                       | An unknown environment.                                                                                                                            |
| 404    | `not_found`                   | "No such action: POST /api/v1/vms/{id}/start\|stop\|pause\|resume."                                                                                                                   | Any other action.                                                                                                                                  |
| 409    | `conflict`                    | "cannot pause a VM that is stopped"                                                                                                                                                   | The state does not allow the action.                                                                                                               |
| 409    | `conflict`                    | "This VM runs a CI job: flockvm deletes it when the job ends."                                                                                                                        | An action on a GitHub Actions runner VM.                                                                                                           |
| 409    | `capacity`                    | "Not enough room on this host for large: it needs 16384 MB RAM and 8 vCPU, 11544 MB and 0 vCPU are free." (`field`: `size`)                                                           | Create: the region has no room for this size now. Try a smaller size, or later.                                                                    |
| 409    | `capacity`                    | "not enough memory on this host: 4096 MiB needed, 2048 MiB free for VMs"                                                                                                              | Start, resume or pause: the host has no room for this VM (or for its memory snapshot) now. No `field`. Try later, or pause or stop another VM.     |
| 429    | `trial_vm_limit`              |                                                                                                                                                                                       | Create, start or resume during the free trial with 2 VMs already running or starting, CI runner VMs included.                                      |
| 429    | `trial_rate_limited`          |                                                                                                                                                                                       | Create, start or resume during the free trial, past 5 starts in a minute, 25 in an hour or 75 in a day.                                            |
| 429    | `trial_compute_limit_reached` |                                                                                                                                                                                       | Create, start or resume during the free trial once its 25 hours of VM time are used.                                                               |
| 503    | `unavailable`                 |                                                                                                                                                                                       | The host or the billing did not answer. Try again.                                                                                                 |

Every create, action and delete is in the [audit log](https://flockvm.com/docs/team/audit-log) (`vm.created`, `vm.paused`…), with the key that made it.

## Next steps

- [Catalog](https://flockvm.com/docs/api/catalog): The regions, sizes and images to create with.
- [Environments](https://flockvm.com/docs/api/environments): What every new VM starts with.
- [Lifecycle](https://flockvm.com/docs/vms/lifecycle): What pause, stop and delete keep and cost.
- [Connect over SSH](https://flockvm.com/docs/vms/ssh): `~/.ssh/config`, file copies, port forwarding.
