Documentation Menu▼

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}}
  • 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}}

Creating an Environment

  1. Select your target Collection in the sidebar.
  2. Click the Environment selector dropdown in the collection header or top bar.
  3. Click New Environment (or edit existing ones).
  4. Name it (e.g., Development, Staging, Production).
  5. Click Save.

Adding Variables

  1. Select the environment to edit
  2. Click + Add Variable
  3. Enter the variable Key and Value
  4. Toggle Enabled to include/exclude variables
  5. 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 Staging while Collection B points to Production at 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.