Manage environment variables and secrets (and import contexts)¶
Goal: keep the settings and keys your scripts need (log levels, API keys, tokens) as
personal environment variables and secrets, load them from a .env file, and use them in a
script. Admins also keep the context's platform variables and secrets, which workers
reference, and import contexts from a contexts.toml.
Prerequisites
- Signed in, on the context you want them on (entries are kept per context: set them up on each).
- No admin role is needed for your own variables and secrets: they change nothing on the platform and pass no write gate. The platform scope and importing contexts need an admin.
Add a variable or a secret¶
- Open Config > Environment variables (route
/config/env) or Config > Secrets (/config/secrets). The line under the title names the context. -
Press Add…, type a Name (a letter or
_, then letters, digits and_, e.g.LOG_LEVEL) and a Value, press Save. The notice says Personal variable LOG_LEVEL saved (Personal secret … saved).

-
A secret's row shows
…and its last four characters (…abcd), never the value. To change it, select the row, press Edit… and type the new value (the field says set (…abcd); type to replace).
A name is either a variable or a secret: adding a variable BINANCE_KEY while you have a
secret BINANCE_KEY says BINANCE_KEY is already a secret.
Import a .env file¶
-
On Environment variables, press Import .env… and pick the file, e.g.
-
The preview lists what this page takes:
- New:
LOG_LEVEL,REGION(not there yet); - Changed: names whose value differs, ticked to replace; untick one to keep its current value;
- Unchanged: same value already;
- Left out:
BINANCE_KEY — a secret pattern,GITHUB_TOKEN — a secret pattern.

- New:
-
Press Import N (N: the new and ticked names). Nothing is written before.
- Open Config > Secrets and import the same file: now
BINANCE_KEYandGITHUB_TOKENare offered andLOG_LEVEL,REGIONare left out as not a secret pattern. A changed secret is found by the server: neither value is shown.
Which names are secrets is decided by the secret patterns at the bottom of
Config > Secrets: regular expressions matched anywhere in the name, ignoring case,
TOKEN and KEY by default. Add one (e.g. ^AWS_, SECRET$) with Add pattern,
remove one with ✕, Defaults restores TOKEN, KEY.
Use them in a script¶
In Infra > Scripts:
const level = await vf.env('LOG_LEVEL')
const key = await vf.secret('BINANCE_KEY')
print('log level', level, '— key ends with', key.slice(-4))
The secret is fetched from the app server for this run only; Operations called lists
vf.secret with the name, not the value. See
Scripts.
Delete¶
Mark rows (or select one) and press Delete…; with several marked, the dialog lists them and asks once more (Yes, delete all N: this cannot be undone).
Platform scope¶
Admins only: the variables and secrets workers use, shared by everyone on the context.
-
On Config > Environment variables or Config > Secrets, switch the scope to Platform. The line under the title says where they are kept.

-
Add… a platform variable, e.g.
REGION=eu(kept incfg.env), or a platform secret, e.g.alpaca-paper-key(a secret key may also hold.and-). Each save is one write: on a protected context you confirm it, and Infra > Changes lists it. -
A platform secret's row shows set and Set at, never the value or its last characters.
-
Import .env… works as above, with your secret patterns. An imported secret whose name already exists is Changed with the note value not readable (its value cannot be compared): it is replaced unless you untick it. The whole import is one write.
-
Give them to a worker when you create it (Infra > Workers > New…): secrets under Secret references, variables under Platform variables as
attribute=VARIABLElines, e.g.region=REGION(the attribute is 1-20 lower-case letters or digits). See Start a worker. A worker sees a changed variable at its next start. -
Delete a platform secret: type its key (for several marked ones, their number) to confirm. Its value cannot be read back, and every worker of the context that uses it fails at its next load or start. Platform variables and your own entries ask the usual way.
Without the admin role the platform scope is read-only (the buttons say Only admins may change platform entries).
Import contexts¶
Admins only; the app server needs an overlay file (VIRTUFIN_APP_CONTEXTS_OVERLAY,
Settings).
-
Open Config > Contexts (route
/config/contexts): each context with its host, health and whether a key is set (set, from the environment, none; never the key).
-
Press Import TOML… and pick a file in the contexts.toml format.
- The preview lists New, Changed (ticked to replace) and Unchanged contexts, and the bad entries as Left out with their problem (no api_host).
- Press Import N. The entries go into the app server's overlay, which replaces the
deployment's entries of the same name; an entry without
api_keykeeps the existing key. The table shows them with Source overlay, and the context menu offers them.
When it does not work¶
| You see | Why, and what to do |
|---|---|
NAME on lines X and Y |
The file gives a name twice: remove one line. |
NAME is already a secret / already a variable |
The name is the other kind: delete it there first, or rename it. |
(unclosed: Invalid regular expression … |
The pattern is not a valid regular expression: fix it. |
| A secret shows only set | It is shorter than eight characters: no trailing characters are shown. |
| Import TOML… is off | You are not an admin, or the server has no overlay file (its tooltip says which). |
| Platform buttons are off | You are not an admin: the platform scope is read-only for you. |
| the gateway does not know the Secrets service yet; try again in a few minutes | The api gateway caches the WorkManager's methods for up to an hour after a release: wait and press Retry. |
NAME is already a platform secret / variable |
In the platform scope the name is the other kind: delete it there first. |
| An imported platform secret is Changed though its value is the same | A platform secret's value cannot be read to compare: untick it to leave it alone. |