How to use nested environments in API Spector
Environments usually share most of their variables and differ in only a few. Rather than copying every variable into each one, you can have one environment extend another: keep the shared values in a base, and override only what changes per stage. API Spector supports this, and the environment editor now shows which variables come from a parent.
Extend a base environment
- Open the environment editor from the environment selector in the toolbar.
- Select the environment you want to be the child, for example Staging.
- In the Extends dropdown, pick the parent, for example Base.
Staging now inherits every variable from Base. You only add the variables that differ, such as a different baseUrl or a stage-specific token.
Chains are allowed. Base can be extended by Staging, and Staging by Staging EU, and each level inherits from the one above it.
How values resolve
- A variable defined on the current environment wins over the same variable in a parent.
- When a chain has several levels, the nearest parent wins over a more distant one.
- A request reads the resolved set, so a reference like {{baseUrl}} picks up the right value for whichever environment is active.
See what is inherited
The environment editor makes this visible. Under your own variables there is an Inherited from parents list. Each row shows the variable name, its value, and a badge naming the parent it comes from. Encrypted secrets show as dots and OS environment references show as $NAME, exactly as they do in your own rows, so nothing sensitive is exposed.
When one of your own variables has the same name as a parent's, it carries an overrides badge that names the parent. That tells you this environment is replacing the inherited value rather than adding a new one, so you are never left guessing where a value comes from.
A typical setup
- Base: baseUrl, common headers, shared IDs.
- Staging extends Base: a staging baseUrl that overrides Base, plus a staging token.
- Production extends Base: a production baseUrl and a production token.
You edit the shared values once in Base, and every child picks them up. Switch the active environment and the same requests run against the right target, with the inherited values shown in the editor so you always know where each one comes from.