Environments & variables
Variable scopes, {{var}} substitution, dynamic tokens, and ƒx scripted values.
Variables let you parameterise requests — base URLs, tokens, IDs — and swap them out per environment without editing every request.
Variable scopes
When a request is sent, {{name}} references resolve against a layered set of
scopes, from broadest to most specific:
- Global — workspace-wide values.
- Folder — values set on an ancestor folder’s
settings.yaml, inherited by everything beneath it. A nearer folder overrides a farther one. The editor shows inherited values in a read-only panel, with the folder each one comes from. - Environment — values from the active environment.
- Request — values defined on the request itself.
- Runtime — values set during execution by a script, e.g.
mt.environment.set(...).
More specific scopes win, so a request-local userId overrides an environment one.
Variable substitution
{{name}} placeholders are resolved at send time across the URL, query, headers,
body, auth fields, and TLS paths. For example:
GET {{baseUrl}}/users/{{userId}}
Authorization: Bearer {{token}} The other protocols resolve the same way: WebSocket and gRPC substitute their endpoint and headers/metadata at connect time, and
every outgoing frame or message at send time — so a payload can carry {{token}},
or a fresh {{$guid}} per message.
Seeing what will resolve
Every field that takes a variable highlights its {{name}} tokens as you type —
green when the name resolves in the current scope, red when nothing will replace
it. That includes the request body (raw, GraphQL query and variables), the gRPC
message, MCP tool arguments, and the WebSocket send box, as well as the URL,
headers, query and auth fields. Hover a token to see the value it will resolve
to; secrets show as bullets rather than their contents, and an ƒx value shows its
expression.
A red token is the quickest way to catch a typo or a variable that belongs to a different environment — it’s exactly what will be sent verbatim, since unresolved tokens are left untouched.
Environments
An environment is a named set of variables — typically one per target (local, staging, production). Switch the active environment from the sidebar, from its tag next to Workspace, from the environment name in the status bar, or by typing its name in the command palette. The active one is marked, and each environment carries a colour for quick visual orientation. Environments are stored as files in the workspace; right-click one to clone or rename it.
Secrets (passwords, tokens, keys) are stored in an encrypted vault on your device — unlocked by your OS keychain — rather than in the workspace files. See TLS & certificates and the storage format for how secret references work.
A credential field that holds a {{variable}} is treated as a reference rather than a
password, so it is never moved into the vault — see securing credentials.
Variables don’t nest
Substitution is single pass: a resolved value is not scanned again. So a variable whose value is {{other}} resolves to the literal text {{other}}, not to whatever other holds — the token is sent verbatim.
That is deliberate: it rules out accidental recursion, and it keeps a value that merely looks like a token (a password containing braces, say) from being rewritten behind your back. When you genuinely need one variable built from another, use an ƒx scripted value, which can read the rest of the scope.
Dynamic tokens
Postman-compatible dynamic values are available inline:
| Token | Resolves to |
|---|---|
{{$guid}} | A random UUID |
{{$timestamp}} | The current Unix timestamp |
{{$randomInt}} | A random integer |
ƒx scripted values
Beyond static values, a variable’s value can be a small JavaScript expression
(an ƒx value), evaluated at resolve time. Scripted values can call helpers like guid(), datetime(), timestamp(), randomInt(), and randomBetween(), and
read other variables with mt.variables.get(...). Use them when a value needs to be
computed fresh on every send. Errors in an ƒx expression are surfaced inline.
Renaming variables
To rename a variable, edit its name in the environment, Globals or workflow variables table and save. Mitey asks whether to rename it everywhere, and lists every file that would change and how many times. If you confirm, it renames:
- the variable in every scope that defines it: globals, every environment, folder settings, request-local and workflow variables, so no environment is left without it;
- every
{{name}}reference in requests, folder settings, other variables’ values and workflow steps ({{ name }}keeps its spacing;{{nameSuffix}}is a different variable and is left alone); - the names a workflow uses directly (a
varcondition, aforEachlist and its<as>Index, extracts and step variables) and agent capture targets; - the name in script calls such as
mt.environment.get("name")orpm.variables.set('name', …). Other strings in a script are left alone. A script you had enabled stays enabled after the rewrite.
Only here saves the table with the new name and leaves every reference alone. The rename is refused if the new name is already in use somewhere. It is also refused while another open environment, folder or workflow editor has unsaved changes, since saving that editor later would bring the old name back. Requests the rename changes need agent approval again.
Auditing variables
As your workspace grows, it is easy to accumulate stale variables. The Audit feature helps you keep your environments clean. It scans your workspace to find:
- Unused variables: Defined in the environment but never referenced.
- Unset variables: Referenced by requests but missing from the environment.
- Duplicate variables: Defined multiple times across environments with identical values.
You can access the audit tool to quickly review and clean up your variable usage.