Environments
Environments let you define sets of variables and instantly switch between them. Use environments to manage different API base URLs, tokens, and settings for dev, staging, and production without editing your requests.
What Are Environments?
An environment is a named collection of key-value variables. For example:
Development
BASE_URL = http://localhost:3000
API_KEY = dev-key-abc123
USER_ID = 42
Production
BASE_URL = https://api.example.com
API_KEY = prod-key-xyz789
USER_ID = 42
When you send a request, Veyak replaces any {{VARIABLE}} placeholder with the value from the currently active environment.
Using Variables in Requests
Use double curly braces {{VARIABLE_NAME}} anywhere in your request:
- URL:
{{BASE_URL}}/users/{{USER_ID}} - Headers:
Authorization: Bearer {{ACCESS_TOKEN}} - Query params:
?token={{TOKEN}} - Body:
- JSON & Raw:
{ "key": "{{API_KEY}}" } - Form-Data: Dynamic keys
{{FIELD_NAME}}and values{{FORM_VAL}} - URL-Encoded: Dynamic keys
{{PARAM_KEY}}and values{{PARAM_VAL}}
- JSON & Raw:
- Cookies: Dynamic names
{{COOKIE_NAME}}, values{{COOKIE_VAL}}, and domains{{DOMAIN}} - Authentication:
- Basic Auth: Username
{{BASIC_USER}}and password{{BASIC_PASSWORD}} - Bearer Token:
{{BEARER_TOKEN}} - API Key: Key
{{API_HEADER}}and secret{{API_KEY}}
- Basic Auth: Username
Creating an Environment
- Select your target Collection in the sidebar.
- Click the Environment selector dropdown in the collection header or top bar.
- Click New Environment (or edit existing ones).
- Name it (e.g.,
Development,Staging,Production). - Click Save.
Adding Variables
- Select the environment to edit
- Click + Add Variable
- Enter the variable Key and Value
- Toggle Enabled to include/exclude variables
- Mark as Secret to hide the value in the UI
| Field | Description |
|---|---|
| Key | Variable name (e.g., BASE_URL) |
| Value | Variable value |
| Enabled | Include this variable when active |
| Secret | Mask the value in the UI |
Switching Environments
Click the Environment selector dropdown to switch the active environment for your current collection. Changes take effect immediately — no restart required. Different collections can maintain different active environments simultaneously.
Collection-Scoped Architecture (v0.8.0)
Starting with Veyak v0.8.0, environments are collection-scoped rather than globally workspace-scoped:
- Complete Isolation: Each collection maintains its own dedicated environments, eliminating variable collisions between different microservices or API providers.
- Independent Active State: You can point Collection A to
Stagingwhile Collection B points toProductionat the same time. - Script Persistence: Pre- and post-request scripts targeting
veyak.environment.set()persist variables directly into the collection’s active environment.
Tips
- Use Secret for tokens, passwords, and API keys so they’re not visible at a glance.
- Name environments clearly:
Dev,Staging,Prod. - Disabled variables are skipped during substitution but kept for future use.
- Variables with the same key as a disabled variable in the active env will not be substituted.