Skip to content
pols.so docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Secrets and environment

Give sandboxes API keys, passwords and configuration through the encrypted vault or plain environment variables.

A sandbox’s commands see the environment variables you give it when you create it. There are two ways to set them:

  • Vault entries (--secret NAME) for API keys, passwords and tokens. Their values are stored encrypted, never shown again and never pass through your command line.
  • Environment variables (--env, --env-file) for ordinary configuration.

Both reach the sandbox as environment variables of every command that runs in it. A vault entry with hosts is the exception: the variable holds a placeholder, and the value itself never enters the sandbox.

The vault

Every org has a vault of passwords and environment variables. Its owners and admins manage it on the account page, logged in with your email; members see the entries’ names:

  • Add an entry with a name, a kind (password or env), the hosts it may be sent to (optionally with a path prefix and HTTP methods) and a value. The name is the environment variable a sandbox gets.
  • Replace a value by saving the same name again. Leaving the hosts, path and methods fields blank keeps them; filling any of them replaces all three.
  • Delete an entry.

The Secrets (Vault) page in the account settings: the list of vault entries with name, kind, hosts and last use, and the form to add an entry. The Secrets (Vault) page in the account settings: the list of vault entries with name, kind, hosts and last use, and the form to add an entry. Dark theme.

The vault under Settings › Secrets (Vault); a saved value shows only as dots.

A saved value is never displayed again, on the page or anywhere else, and never written to a log. The vault holds up to 100 entries of up to 32 KiB each, with up to 10 hosts each.

API keys cannot add, change or read values. With an API key you can only list the entries’ names, kinds, hosts (with any path prefix and methods) and timestamps, and name entries when you create or fork a sandbox:

pols vault ls
pols new --name agent --secret ANTHROPIC_API_KEY --secret GITHUB_TOKEN
pols fork agent --name agent-2 --secret EXTRA_TOKEN

The same is available as GET /v1/vault and the secrets field of POST /v1/sandboxes and .../fork, the MCP tool vault_list and the secrets argument of sandbox_create, and pols.vault.list() in the TypeScript client. Every name must exist in the vault; otherwise the call fails with bad_request. A sandbox lists the names it got in secrets.

When values are read

A sandbox gets each entry’s value when its VM is created, and keeps that value:

  • Changing an entry without hosts later reaches only sandboxes created after the change. Sandboxes that exist keep the value they got, also when you delete the entry. Entries with hosts behave differently; see below.
  • A fork keeps its source’s entries, with the values the source got, and reads the entries you add.
  • If an entry is deleted before the sandbox’s VM was created, the sandbox goes to error.
  • Templates keep no environment, so they keep no vault values either.

How values are protected

Values are encrypted with AES-256-GCM. The key is kept outside the database, and each value is bound to its org and name, so a ciphertext copied to another entry or org does not decrypt.

Inside a sandbox, an entry without hosts is an ordinary environment variable: every program that runs there can read it. Give a sandbox only the secrets it needs, and do not give such entries to sandboxes that run code you do not trust.

Entries with hosts

An entry with hosts (exact names such as api.example.com; no wildcards, addresses or ports) never enters the sandbox. Its variable holds a placeholder, pols-vault- and 48 hex digits, that differs per sandbox and entry and tells nothing about the value. When a program in the sandbox sends an HTTPS request to one of the entry’s hosts, the pols edge swaps the placeholder for the value in the Authorization, X-Api-Key and Api-Key headers and forwards the request to the real host. Requests to every other host leave the placeholder as it is, and a placeholder is worthless outside its own sandbox.

  • Path and methods. An entry with hosts may also have a path prefix (such as /v1, matched by whole segments) and HTTP methods. The edge then swaps the placeholder only on requests with one of those methods to a path under the prefix, so an agent can use a key only for the calls it was meant for.
  • Defaults. Unless an entry names hosts of its own, ANTHROPIC_API_KEY and CLAUDE_CODE_OAUTH_TOKEN go to api.anthropic.com, and OPENAI_API_KEY and CODEX_API_KEY to api.openai.com, so the preinstalled Claude Code and Codex work with placeholders as they are. To give sandboxes the value itself, for a key used through a proxy or another base URL, make the entry plain on the vault page.
  • Changes. A sandbox uses the entry’s current value and hosts, so a replaced value or a removed host takes effect within seconds, and a new host at the sandbox’s next start. An entry made plain or left without hosts reaches only sandboxes created afterwards; existing ones keep a placeholder that nothing swaps any more.
  • Egress. The edge sends the request no further than the sandbox’s egress policy reaches: a sandbox with egress none reaches nothing.
  • Not covered. Builds and server apps of sites get their vault entries’ values as such. The edge forwards whatever the hosts answer, so list only hosts that do not send a request’s credentials back.

To make this work, pols installs its vault CA in the sandbox at every start and points the entries’ hosts at the edge in /etc/hosts; NODE_EXTRA_CA_CERTS, SSL_CERT_FILE and REQUESTS_CA_BUNDLE point Node, OpenSSL and Python requests at the CA unless you set them. GET /v1/vault returns each entry’s hosts, path_prefix, methods and plain.

Plain environment variables

pols new --name app --env NODE_ENV=production
pols new --name app --env DATABASE_URL            # copies DATABASE_URL from your environment
pols new --name app --env-file .env               # KEY=VALUE lines

--env KEY copies the variable from your own environment, so its value does not appear on the command line. --env KEY=VALUE puts the value into your shell history and the process list; prefer the vault for anything secret. --env-file reads KEY=VALUE lines; --env wins over a file.

Environment variables are stored as given and returned only by name (env_keys). Deleting a sandbox erases them. Forks keep them; templates do not.

For a single command, pols exec --env KEY=VALUE adds a variable to that command only.