Skip to content

API

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.

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. Each route below gives the action 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

{
  "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
}
idstring

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

namestring

The name it was created with.

statusstring

starting, running, pausing, paused, stopping, stopped or failed. See Lifecycle for what each one allows.

sizestring

small, default, large or xlarge, with its vcpu, memory_mb and disk_gb. See Sizes.

imagestring

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.

regionstring

gra for France, the one region today.

private_ipstring or null

The VM's address on its own private network.

sshobject

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.

created_atstring

When it was created.

started_atstring or null

When its current run started. null while it is stopped.

paused_atstring or null

When it was paused, while it is paused.

price_hournumber or null

The price per hour in USD, frozen when the VM was created.

seconds_billednumber

The seconds billed so far.

cost_usdnumber

What they cost, in USD, unrounded.

errorstring or null

Why the VM is failed, when it is.

environmentobject or null

The environment and version the VM was created with. null for No environment.

runnerobject or null

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

restrictionobject or null

{"kind": "network", "reason": "…", "since": "…"} when flockvm has cut the VM's outbound network. See Acceptable use.

List VMs

GET /vms · Action: vm.read

curl https://flockvm.com/api/v1/vms \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
{
  "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

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"}'
HTTP/1.1 201 Created
{
  "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.

namestringrequired

1 to 40 characters: lowercase letters, digits and dashes.

sizestringrequired

small, default, large or xlarge. GET /regions says which ones have room right now. See Catalog.

regionstringdefault: 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.

imagestringdefault: 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.

ssh_key_idstring

A key saved in your account, from GET /ssh-keys. Give this or ssh_public_key, not both.

ssh_public_keystring

A public key, the line of your .pub file: ssh-ed25519 AAAA… you@laptop. Same formats as the dashboard: see SSH keys.

save_keybooleandefault: false

With ssh_public_key: also save the key to your account, as the form's Save this key to my account does.

environmentstringdefault: 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.

envobject 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 started or its plan in order: see 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

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.

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

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

Answers 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

curl -X POST https://flockvm.com/api/v1/vms/vm_x9n9td/pause \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
{
  "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} to see pause, stop and start settle. An action the state does not allow answers 409 conflict:

{ "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.

Delete a VM

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

curl -X DELETE https://flockvm.com/api/v1/vms/vm_x9n9td \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
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.

Console log

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

curl "https://flockvm.com/api/v1/vms/vm_fx7k2m/logs?tail=5" \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
{
  "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.

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.
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.
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 (vm.created, vm.paused…), with the key that made it.

Next steps