← Back to Overview

ENVIRONMENTS

Managing Environments

Create and manage environments with key-value variables for different stages of your development workflow — Development, Staging, Production, and more.

Creating a new environment with variables

Creating Environments

Environments hold key-value variables that can be referenced anywhere in your requests using {{variable}} syntax.

Navigate to the Sidebar → Environments tab
Click + New Environment
Name it (e.g., Development, Staging, Production)
Choose scope: Local (workspace-only) or Global (shared across workspaces)
Starts with an empty variable table — ready for your key-value pairs
Each environment gets a unique UUID id for internal tracking
Tip: Create separate environments for each stage of your workflow. Use the same variable keys across environments (e.g., base_url) with different values to switch contexts instantly.

Editing Variables

Each environment contains a variable table where you define key-value pairs used in your requests.

Click an environment to expand its variable table
Each row has a key, value, and an enabled/disabled checkbox
Add new variables: type in the last empty row — a new row appears automatically
Delete: click the × button that appears on hover
Values support any text — URLs, tokens, numbers, JSON strings
Changes save automatically — no manual save step required

Example variable table:

KeyValue
base_urlhttps://api.example.com
tokensk-abc123...
debugtrue

Disabled variables (unchecked) are stored but not resolved during interpolation

Local vs Global

Environments exist in two scopes, allowing both workspace-specific and shared configurations.

Local Environments

Stored in .openpost/environments.json

Workspace-specific — only available in the current project

Perfect for project-specific endpoints and tokens

Git-committable — share with your team

Global Environments

Stored in ~/.openpost/global/environments.json

Available across all workspaces

Ideal for personal tokens, shared base URLs

Syncs across VS Code windows automatically

Both shown in the sidebar with scope labels (Local / Global)
Can have one local AND one global environment active simultaneously
Local variables override global variables with the same key
Override example: If Global has base_url = https://shared.api.com and Local has base_url = http://localhost:3000, the local value wins when both environments are active.

Active Selection

Only the active environment's variables are available for {{interpolation}} in your requests.

Environment dropdown showing Local and Global environments
Top bar dropdown shows all environments grouped by scope (Local / Global)
Select one to make it active — its variables become available for {{interpolation}}
Can have both a local and global environment active at the same time
Active environment persisted per-workspace in config.json
Switching environment immediately affects all open request tabs
Note: The active selection is remembered when you close and reopen VS Code. You don't need to reselect your environment each time.

Deleting Environments

Remove environments you no longer need.

Right-click → Delete in the sidebar
Confirmation dialog appears — this is irreversible
If the deleted environment was active, the selection clears
Requests using its variables will show as unresolved (highlighted in orange)
Warning: Deleting an environment does not update saved requests that reference its variables. Those placeholders will remain as {{unresolved}} until you switch to an environment that provides those keys.

CLI Management

Manage environments from the terminal using the API Studio CLI:

openpost env set <name>

Set the active environment by name

openpost env add <name> <key> <value>

Add a variable to an existing environment

openpost list environments

List all environments (local and global)

openpost run <collection> --env <name>

Override the active environment for a single run

Tip: The --env flag is useful in CI/CD pipelines where you want to run a collection against a specific environment without changing the workspace default.

Next

Ko-fi