Workspace variables
Settings every workflow in a workspace shares, read as {{env.NAME}} in step settings and env.NAME in JavaScript, with write-only secrets.
On this page
A workspace variable is a named setting that every workflow in a workspace can read: a partner's base URL, a facility code, an API token. You change it once, in Settings → Secrets & variables, and every step that reads it gets the new value on its next run. It is the MedHook equivalent of Mirth's configuration map and Rhapsody's environment variables. It is not the engine's process environment, which is described in Environment variables.
How it works
A step reads a variable when it runs, never when it is saved. The workflow and every saved version keep the reference ({{env.API_BASE}}), so changing a variable never needs a new version of the workflow.
| Where | How you write it | Example |
|---|---|---|
| An adapter step's settings | {{env.NAME}} | https://{{env.PARTNER_HOST}}/fhir/Patient |
| A filter or condition rule's value | {{env.NAME}} | MSH.4 equals {{env.FACILITY}} |
| A template step | {{env.NAME}} | {"facility": "{{env.FACILITY}}"} |
| A JavaScript step or filter expression | env.NAME | return { base: env.API_BASE }; |
In a template step, env is a reserved name: a field called env in the message never replaces a variable, so a message cannot inject one. An adapter step resolves its own settings before it adds the message's data, for the same reason.
Trigger settings are not resolved. A trigger setting that contains {{env. gets a validation warning; enter the value itself.
Names and values
| Rule | Detail |
|---|---|
| Name | Capital letters, digits and underscores, starting with a letter, at most 64 characters. |
| Unique | One variable per name in each workspace. |
| Value | Text, at most 8192 characters. A variable may exist without a value. |
| Read-only in code | env is frozen: a JavaScript step cannot change it. |
Unknown and empty variables
A step that reads a variable that does not exist, or one that has no value, fails. The error names the variable and never shows a value, and the failure is not retried: it fails the same way until you create the variable or enter its value.
The deploy checklist reports the same problems before you deploy:
| Code | Severity | Meaning |
|---|---|---|
VARIABLE_UNSET | Error | A step reads a variable that has no value. Deploy is blocked. |
VARIABLE_UNKNOWN | Warning | A step reads a name that is not a variable in this workspace. |
ENV_IN_TRIGGER | Warning | A trigger setting contains {{env., which triggers don't resolve. |
Secrets
Turn on Secret for a credential. A secret:
- is encrypted at rest with the engine's master key, like adapter profile credentials, and is re-encrypted by a master key rotation;
- is write-only: the API and the UI never return its value, only whether it has one. Leave the value field empty when you edit it to keep the stored value;
- has at least 8 characters, so masking never hides short, common text;
- cannot be turned back into a plain variable. Delete it and create a new one instead.
A step still gets the real value, for example to build an Authorization header. What the engine stores about the run is masked: wherever a secret's value appears in a step's stored output, console lines, channel map or error text, run history shows •••• instead. A dry run's results are masked the same way.
Changes and audit
Operators and admins create, edit and delete variables; viewers can read the list. Every change writes an audit event (workspace_variable.created, workspace_variable.updated, workspace_variable.deleted) that names the variable and never records a value. A change reaches running workflows on every replica within about a second.
Imported from Mirth
The Mirth importer creates a variable for each configuration map entry. The name is the key in capitals with other characters as underscores (api.base becomes API_BASE). An entry that looks like a credential becomes a secret with no value: credentials are never imported, and deploy stays blocked until someone enters the value. The test is deliberately broad. It catches keys such as sftp.pass, dbPwd, privateKey, passphrase, authHeader and client_key, and values that hold a password in a URL (jdbc:postgresql://user:pw@host), a PEM block or a Bearer header. A plain entry it catches by mistake only needs its value entered again. Imported $cfg('key') and configurationMap.get('key') read the variable.