Skip to content

Environments and variables

Anywhere text is accepted — URL, headers, body, auth fields — {{name}} is substituted before the request is built.

Environments

An environment is a named set of values. Switch between them with the selector at the top right.

The usual shape is one per deployment:

Local        host = localhost:3000
Staging      host = api.staging.example.com
Production   host = api.example.com

with a URL of https://{{host}}/v1/orders that never changes.

Seeing what will be sent

Unresolved variables are painted red in the editors, with a wavy underline; resolved ones are green. Hover any of them to see the value that will actually go out.

That matters more than it sounds. A mistyped variable name is otherwise completely invisible until the server rejects the request with something unrelated.

Setting from a script

js
sw.environment.set("token", sw.response.json().data.token)

Available immediately to every later request as {{token}}.

Dynamic values

Generated fresh each time they are used:

{{$guid}}A v4 UUID.
{{$timestamp}}Unix seconds.
{{$isoTimestamp}}ISO 8601.
{{$randomInt}}A random integer.

Reach them from a script with sw.variables.replaceIn("{{$guid}}").

Secrets

Values marked secret are masked in the UI and left out of generated code snippets unless you tick Resolve variables — and the snippet panel warns you when a snippet contains resolved secrets, before you paste it somewhere.

No account. No cloud. No telemetry.