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
403on 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.readto read,environment.writeto change,environment.revealto reveal. A key restricted to some environments lists and reads only those: any other answers404.
Environments are kept on the host in France, the server that runs the VMs.
The environment object
is_defaultbooleanThe environment a new VM gets when environment is left out. Exactly one environment is the default.
safe_for_third_partiesbooleanWhen true, nothing of the organization goes into its VMs, whatever the sections say. See Safe for third parties.
secretsbooleanThe Secrets section: variables and secret files. Off, they stay out of new VMs, and what you saved is kept.
agent_credentialsbooleanThe Agent credentials section: the organization's Anthropic key as ANTHROPIC_API_KEY.
github_reposbooleanThe GitHub repositories section: repos, cloned into new VMs.
members_can_usebooleanWhether members may create VMs with it. Off, only owners and admins can.
versionnumberThe latest version. A VM keeps the version it was created with. See Versions.
varsarrayEach 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.
filesarrayEach secret file's path, relative to the login user's home, and its size in bytes. Never the content.
reposarrayThe GitHub repositories cloned into new VMs: {"repo": "acme/web", "updated_at": "…"}.
versionsarrayThe recent versions, newest first, with how many existing VMs use each one.
List environments
GET /environments · Action: environment.read
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
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
Answers the environment object.
Change an environment
PATCH /environments/{ref} · Action: environment.write
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.
Delete an environment
DELETE /environments/{ref} · Action: environment.write
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:
Delete one:
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.
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:
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:
Or as base64, for any file:
Delete one:
They answer the environment, with its new version.
- The path after
/files/is relative to the login user's home:files/app/.envis/home/user/app/.envon the Agent image,/root/app/.envon 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) orcontent_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
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
How variables, files and repositories reach a VM.
Pick an environment with environment, or "none".