Skip to content

API

Environments API

Create and change environments over the API: switches, variables, secret files and GitHub repositories, with values readable only through reveal.

An environment is what every new VM of your organization starts with: environment variables, secret files, agent credentials and GitHub repositories. These routes do what the dashboard's Environment page does, with the same rules and limits.

  • Every role can read environments: names, switches, variable keys with the last four characters of their values, file paths and sizes.
  • Only owners and admins can create, change, delete and reveal. A member's key gets 403 on those, whatever environment it names.
  • Values never come back, except from POST /environments/{ref}/reveal.
  • {ref} is an environment's id (env_…) or its name.
  • Each route below gives the action the key needs: environment.read to read, environment.write to change, environment.reveal to reveal. A key restricted to some environments lists and reads only those: any other answers 404.

Environments are kept on the host in France, the server that runs the VMs.

The environment object

{
  "id": "env_g6dhdxjz",
  "name": "staging",
  "is_default": false,
  "safe_for_third_parties": false,
  "secrets": true,
  "agent_credentials": true,
  "members_can_use": false,
  "github_repos": true,
  "version": 4,
  "created_at": "2026-11-01T06:19:16.779Z",
  "updated_at": "2026-11-01T06:19:19.795Z",
  "vars": [
    { "key": "STRIPE_KEY", "last4": "4242", "updated_at": "2026-11-01T06:19:17.771Z" }
  ],
  "files": [
    { "path": "app/.env", "size": 44, "updated_at": "2026-11-01T06:19:18.654Z" },
    { "path": "app/cert.pem", "size": 28, "updated_at": "2026-11-01T06:19:18.887Z" }
  ],
  "repos": [],
  "versions": [
    { "version": 4, "created_at": "2026-11-01T06:19:18.887Z", "vms": 0 },
    { "version": 3, "created_at": "2026-11-01T06:19:18.654Z", "vms": 0 },
    { "version": 2, "created_at": "2026-11-01T06:19:17.771Z", "vms": 0 },
    { "version": 1, "created_at": "2026-11-01T06:19:16.779Z", "vms": 0 }
  ]
}
is_defaultboolean

The environment a new VM gets when environment is left out. Exactly one environment is the default.

safe_for_third_partiesboolean

When true, nothing of the organization goes into its VMs, whatever the sections say. See Safe for third parties.

secretsboolean

The Secrets section: variables and secret files. Off, they stay out of new VMs, and what you saved is kept.

agent_credentialsboolean

The Agent credentials section: the organization's Anthropic key as ANTHROPIC_API_KEY.

github_reposboolean

The GitHub repositories section: repos, cloned into new VMs.

members_can_useboolean

Whether members may create VMs with it. Off, only owners and admins can.

versionnumber

The latest version. A VM keeps the version it was created with. See Versions.

varsarray

Each variable's key, the last four characters of its value (last4) and when it was set. Never the value. last4 is "" for a value under 8 characters, which it would show half of or more.

filesarray

Each secret file's path, relative to the login user's home, and its size in bytes. Never the content.

reposarray

The GitHub repositories cloned into new VMs: {"repo": "acme/web", "updated_at": "…"}.

versionsarray

The recent versions, newest first, with how many existing VMs use each one.

List environments

GET /environments · Action: environment.read

curl https://flockvm.com/api/v1/environments \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
{
  "environments": [
    {
      "id": "env_5fakhs47",
      "name": "base",
      "is_default": true,
      "members_can_use": true,
      "version": 1,
      // … every field of the environment object
    }
  ],
  "agent_key": null
}

The default environment first, then the others by name. agent_key is the organization's Anthropic API key for Agent credentials: {"name", "last4", "updated_at"}, or null when none is saved. It is set in the dashboard only.

Create an environment

POST /environments · Action: environment.write

curl https://flockvm.com/api/v1/environments \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "staging"}'
HTTP/1.1 201 Created
{
  "id": "env_g6dhdxjz",
  "name": "staging",
  "is_default": false,
  "safe_for_third_parties": false,
  "secrets": true,
  "agent_credentials": true,
  "members_can_use": true,
  "github_repos": true,
  "version": 1,
  "created_at": "2026-11-01T06:19:16.779Z",
  "updated_at": "2026-11-01T06:19:16.779Z",
  "vars": [],
  "files": [],
  "repos": [],
  "versions": [{ "version": 1, "created_at": "2026-11-01T06:19:16.779Z", "vms": 0 }]
}

name: 1 to 40 characters among lowercase letters, digits and dashes, unique in the organization. none is reserved: in POST /vms, "environment": "none" means no environment.

Get an environment

GET /environments/{ref} · Action: environment.read

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

Answers the environment object.

Change an environment

PATCH /environments/{ref} · Action: environment.write

curl -X PATCH https://flockvm.com/api/v1/environments/staging \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"members_can_use": false}'

Send only what changes. The answer is the environment after the change.

Field Type What it does New version
name string Renames it. VMs that use it keep working. No
is_default true Makes it the default. false is refused: make another one the default instead. No
members_can_use boolean Lets members create VMs with it, or not. No
safe_for_third_parties boolean Keeps everything of the organization out of its VMs. Yes
secrets, agent_credentials, github_repos boolean Turns a section on or off. Yes
repos array of strings The whole list of repositories, as "owner/name", up to 10. [] removes them all. Yes

Repositories come through the flockvm GitHub App: only those it can reach are accepted. Connect it in the dashboard first, see GitHub repositories.

curl -X PATCH https://flockvm.com/api/v1/environments/staging \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"repos": ["acme/web"]}'

Delete an environment

DELETE /environments/{ref} · Action: environment.write

curl -X DELETE https://flockvm.com/api/v1/environments/staging \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
HTTP/1.1 204 No Content

The default environment cannot be deleted: make another one the default first. VMs created with the environment keep what they got.

Variables

PUT /environments/{ref}/vars/{KEY}, DELETE /environments/{ref}/vars/{KEY} · Action: environment.write

Set a variable, or replace its value:

curl -X PUT https://flockvm.com/api/v1/environments/staging/vars/STRIPE_KEY \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"value": "sk_test_51Hx9demo4242"}'
{
  "id": "env_g6dhdxjz",
  "name": "staging",
  "version": 2,
  "vars": [{ "key": "STRIPE_KEY", "last4": "4242", "updated_at": "2026-11-01T06:19:17.771Z" }],
  // … every field of the environment object
}

Delete one:

curl -X DELETE https://flockvm.com/api/v1/environments/staging/vars/STRIPE_KEY \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"

Both answer the environment, with its new version. Keys: a letter or _, then letters, digits or _, up to 128 characters, not starting with FLOCK_. Values: a string up to 32 KiB.

Load a whole .env file with the CLI: it reads KEY=value and export KEY=value lines, skips comments, and unquotes quoted values.

flockvm env set --from-dotenv .env --env staging

Without the CLI, let a real .env parser read the file rather than a shell loop, which would keep quotes and trailing comments in the values and miss export lines. Node 20.12 and later has one built in:

// load-env.mjs — FLOCKVM_API_KEY=flk_… node load-env.mjs .env staging
import { readFileSync } from "node:fs";
import { parseEnv } from "node:util";

const [file, environment] = process.argv.slice(2);
for (const [key, value] of Object.entries(parseEnv(readFileSync(file, "utf8")))) {
  const url = `https://flockvm.com/api/v1/environments/${encodeURIComponent(environment)}/vars/${encodeURIComponent(key)}`;
  const res = await fetch(url, {
    method: "PUT",
    headers: { Authorization: `Bearer ${process.env.FLOCKVM_API_KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify({ value }),
  });
  if (!res.ok) throw new Error(`${key}: ${(await res.json()).error.message}`);
}

Both send one request per variable, and each request makes a new version: VMs created meanwhile may get only part of the file.

Secret files

PUT /environments/{ref}/files/{path}, DELETE /environments/{ref}/files/{path} · Action: environment.write

Put a file, with its content as text:

curl -X PUT https://flockvm.com/api/v1/environments/staging/files/app/.env \
  -H "Authorization: Bearer $FLOCKVM_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"content": "DATABASE_URL=postgres://app@db.internal/app\n"}'

Or as base64, for any file:

jq -n --arg c "$(base64 < cert.pem | tr -d '\n')" '{content_base64: $c}' \
  | curl -X PUT https://flockvm.com/api/v1/environments/staging/files/app/cert.pem \
      -H "Authorization: Bearer $FLOCKVM_API_KEY" \
      -H "Content-Type: application/json" -d @-

Delete one:

curl -X DELETE https://flockvm.com/api/v1/environments/staging/files/app/cert.pem \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"

They answer the environment, with its new version.

  • The path after /files/ is relative to the login user's home: files/app/.env is /home/user/app/.env on the Agent image, /root/app/.env on Minimal. Absolute paths, ~, and . or .. segments are refused. Percent-encode characters that are not safe in a URL.
  • The body takes content (UTF-8 text) or content_base64 (standard base64), exactly one of them.
  • Files are written with mode 0600. See Secret files.

Reveal the values

POST /environments/{ref}/reveal · Action: environment.reveal

curl -X POST https://flockvm.com/api/v1/environments/staging/reveal \
  -H "Authorization: Bearer $FLOCKVM_API_KEY"
{
  "environment": { "id": "env_g6dhdxjz", "name": "staging", "version": 4 },
  "vars": [{ "key": "STRIPE_KEY", "value": "sk_test_51Hx9demo4242" }],
  "files": [
    { "path": "app/.env", "content_base64": "REFUQUJBU0VfVVJMPXBvc3RncmVzOi8vYXBwQGRiLmludGVybmFsL2FwcAo=" },
    { "path": "app/cert.pem", "content_base64": "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCg==" }
  ]
}

The only answer with values: every variable and every file of the latest version, files in base64. Owners and admins only. Each reveal is recorded in the audit log as org.environment.reveal.

A reveal puts your secrets in your terminal

The answer lands wherever your script writes it: your shell history, a CI log, an agent's context. Reveal only what you need, and don't reveal from a VM that runs code you don't trust.

Errors

Status code Example message When
400 bad_request "Name: 1 to 40 characters, lowercase letters, digits and dashes." (field: name) A name that breaks the rule.
400 bad_request "none is reserved: it means no environment." (field: name) The name none, at create or rename.
400 bad_request "Names starting with FLOCK_ are reserved for flockvm." (field: key) A variable key that breaks the rules.
400 bad_request (field: value) A value missing, not a string, over 32 KiB, or over the limits of 100 variables and 64 KiB in all.
400 bad_request "Path: no empty, . or .. segment: it must stay inside the home folder." (field: path) A file path that leaves the home folder, or over 256 bytes.
400 bad_request "Give the file as content_base64 (base64) or content (UTF-8 text): one of them." (field: content) Neither or both. Also a file over 256 KiB, or over 20 files or 512 KiB in all.
400 bad_request "is_default: only true. To change the default, make another environment the default." (field: is_default) "is_default": false.
400 bad_request "secrets: true or false." (field: secrets) A switch that is not a boolean.
400 bad_request (field: repos) Not owner/name, more than 10, or not reachable by the organization's GitHub App.
403 insufficient_scope "This API key cannot reveal environment values: it needs environment.reveal." (field: environment.reveal) The key's actions do not cover the route, whatever the user's role.
403 forbidden "Only owners and admins can change environments." A member's key on any write.
403 forbidden "Only owners and admins can reveal values." A member's key on reveal.
404 not_found "No environment nope." No such environment, one of another organization, or one the key is not restricted to.
404 not_found "No variable NOPE." Deleting a variable or file that is not there.
409 conflict "An environment named staging exists." The name is taken.
409 conflict "The default environment cannot be deleted: make another one the default first." Deleting the default environment.
503 not_configured repos without a GitHub App connected, or environments not set up on this deployment.
503 unavailable flockvm could not reach the host. Try again.

Every change and every reveal is recorded in the audit log with the key that made it: keys and paths, never values.

Next steps