Environments and variables
Run the same requests against staging and production by changing one selector.
An environment is a named set of variables. Requests reference them as {{name}}, so switching environment repoints the whole workspace at once.
Setting one up#
- Open Workspace → Environments and create one.Name it after the deployment — Staging, Production, Local.
- Add the variables the requests need.
base_urlalmost always; then tokens, account ids, anything that differs between deployments. - Create the others with the same keys.Same names, different values. Requests then work against any of them untouched.
- Select one from the environment picker.It applies to everything you send from then on.
Using a variable#
Write {{name}} anywhere in a URL, header or body. In the URL bar it renders as a pill; clicking the pill lets you set its value on the spot.
{{base_url}}/v1/charges
Authorization: Bearer {{token}}
{ "account": "{{account_id}}" }
No spaces inside the braces. {{ base_url }} is not a variable and is sent literally — the same rule the CLI and server both follow.
Values that are generated#
Some variables are produced rather than looked up, which is how you get a unique value per send:
| Variable | Produces |
|---|---|
{{$uuid}} | A random UUID |
{{$timestamp}} | Unix seconds |
{{$isoTimestamp}} | ISO 8601 |
{{$randomInt}} | A random integer |
When a variable is missing#
An unresolved {{token}} is left visible in the request rather than replaced with nothing, and flagged. Blanking it would send a subtly wrong request, and the 401 that follows is very hard to explain.
Secrets#
- Mark a variable sensitive to mask it in the interface
- Values are encrypted at rest
- For credentials used by many requests, an auth profile is usually tidier than a variable
Frequently asked questions#
How do I use different URLs for staging and production?
Define a base_url variable in each environment with the appropriate host, write your request URLs as {{base_url}}/path, and switch environments with the selector.
Why is my variable not being substituted?
Check for spaces inside the braces — {{ name }} is not recognised, only {{name}} — and confirm the active environment actually defines that key.