examples Variables and auth
grouped/grouped-environments.http
Grouped environments declared in their own resterm.env.json, with a mock backend that echoes what each request carried.
start the local mock first
resterm _examples/grouped/grouped-environments.httpRun this from the root of a clone of the Resterm repository.
Editor
Grouped environments docs# Grouped environments: three independent choices instead of one flat list.
#
# api dev | stage | prod which backend
# credentials personal | ci | operator who you are
# region eu-west | eu-east | ap-tokyo where it runs
#
# 9 declarations in resterm.env.json cover all 27 combinations.
#
# Press Ctrl+E to switch. Space stages a profile, Enter applies, so you can
# change several groups in one go. The header shows the first group and a count,
# for example "ENV: api=prod +2".
#
# These requests talk to the local mock in mock.http, which echoes back whatever
# the request carried. Start it with `g Shift+M`, then switch a group and rerun:
# the response body changes with the selection. From the CLI, pass one flag per
# group:
#
# resterm mock _examples/grouped/mock.http &
# resterm run --all --env-group api=prod --env-group credentials=operator \
# _examples/grouped/grouped-environments.http
### Show the whole selection
# @name showSelection
# @description Every group at once. Switch a profile and rerun to see exactly what moved.
# @assert response.statusCode == 200
# @assert env.meta.groups.has("api") and env.meta.groups.has("credentials") and env.meta.groups.has("region")
# @assert response.json().api == env.meta.groups.get("api")
# @assert response.json().credentials == env.meta.groups.get("credentials")
# @assert response.json().region == env.get("deployment.code")
GET {{base.url}}/api/{{api.tier}}/context
Accept: application/json
X-Api-Version: {{api.version}}
X-Credential-Profile: {{identity.profile}}
X-Client-Id: {{identity.clientId}}
X-Region: {{deployment.code}}
X-Region-Name: {{deployment.name}}
### Backend only
# @name apiHealth
# @description Reads the api group alone. Switching credentials or region leaves this response unchanged.
GET {{base.url}}/api/{{api.tier}}/health
Accept: application/json
### Credentials only
# @name whoAmI
# @description Reads the credentials group alone. This is why the header keeps the profile name visible.
# @auth bearer {{identity.token}}
GET {{base.url}}/whoami
Accept: application/json
X-Credential-Profile: {{identity.profile}}
X-Client-Id: {{identity.clientId}}
### Region only
# @name regionRouting
# @description Reads the region group alone.
GET {{base.url}}/regions/{{deployment.code}}/status
Accept: application/json
X-Region-Name: {{deployment.name}}
### Every group at once
# @name workloads
# @description One request drawing on all three groups, the case grouped environments exist for.
# @auth bearer {{identity.token}}
GET {{base.url}}/api/{{api.tier}}/{{deployment.code}}/workloads
Accept: application/json
X-Api-Version: {{api.version}}
X-Client-Id: {{identity.clientId}}# Mock backend for grouped-environments.http. It has no idea which environment
# is selected, so every route simply reflects what the request carried. That is
# what makes a group switch visible in the response body.
#
# Start it from this directory with `g Shift+M` in the TUI, or from the
# repository root:
#
# resterm mock _examples/grouped/mock.http
### Context for the active selection
# @mock method=GET path=/api/{tier}/context
HTTP/1.1 200 OK
Content-Type: application/json
X-Mock-Route: context
{
"api": {{json.path.tier}},
"apiVersion": {{json.headers.X-Api-Version}},
"credentials": {{json.headers.X-Credential-Profile}},
"clientId": {{json.headers.X-Client-Id}},
"region": {{json.headers.X-Region}},
"regionName": {{json.headers.X-Region-Name}}
}
### Backend health, api group only
# @mock method=GET path=/api/{tier}/health
HTTP/1.1 200 OK
Content-Type: application/json
X-Mock-Route: health
{
"status": "ok",
"api": {{json.path.tier}}
}
### Caller identity, credentials group only
# @mock method=GET path=/whoami
HTTP/1.1 200 OK
Content-Type: application/json
X-Mock-Route: whoami
{
"credentials": {{json.headers.X-Credential-Profile}},
"clientId": {{json.headers.X-Client-Id}},
"authorization": {{json.headers.Authorization}}
}
### Regional routing, region group only
# @mock method=GET path=/regions/{code}/status
HTTP/1.1 200 OK
Content-Type: application/json
X-Mock-Route: region
{
"region": {{json.path.code}},
"regionName": {{json.headers.X-Region-Name}}
}
### Workloads, every group at once
# @mock method=GET path=/api/{tier}/{code}/workloads
HTTP/1.1 200 OK
Content-Type: application/json
X-Mock-Route: workloads
{
"api": {{json.path.tier}},
"region": {{json.path.code}},
"apiVersion": {{json.headers.X-Api-Version}},
"clientId": {{json.headers.X-Client-Id}},
"workloads": []
}
### Anything else
# @mock method=GET path=/{rest...} default=true
HTTP/1.1 404 Not Found
Content-Type: application/json
{"error":"no mock for this path","path":{{json.path.rest}}}{
"$shared": {
"base": {
"url": "http://127.0.0.1:8080"
}
},
"$groups": {
"api": {
"$default": "dev",
"dev": {
"api": {
"tier": "dev",
"version": "2026-07-dev"
}
},
"stage": {
"api": {
"tier": "stage",
"version": "2026-07-rc"
}
},
"prod": {
"api": {
"tier": "prod",
"version": "2026-07"
}
}
},
"credentials": {
"$default": "personal",
"personal": {
"identity": {
"profile": "personal",
"clientId": "resterm-local",
"token": "personal-demo-token"
}
},
"ci": {
"identity": {
"profile": "ci",
"clientId": "resterm-ci",
"token": "ci-demo-token"
}
},
"operator": {
"identity": {
"profile": "operator",
"clientId": "resterm-operator",
"token": "operator-demo-token"
}
}
},
"region": {
"$default": "eu-west",
"eu-west": {
"deployment": {
"code": "eu-west-1",
"name": "Europe West"
}
},
"eu-east": {
"deployment": {
"code": "eu-east-1",
"name": "EU East"
}
},
"ap-tokyo": {
"deployment": {
"code": "ap-northeast-1",
"name": "Asia Pacific"
}
}
}
}
}