Insomnia logo
  • Documentation
  • Get Started for Free
    • Introduction to Insomnia
    • Install Insomnia
    • Send Your First Request
    • Import and Export Data
    • Environment Variables
    • Global Environments
    • Insomnia Accounts
    • Forgotten Passphrase
    • Managing E2EE (End-to-End Encryption)
    • Organizations
    • Enable Enterprise membership
    • Configuring EE SSO
    • Integrating Insomnia Enterprise with Okta SAML 2.0
    • Integrating Insomnia Enterprise with Okta OpenID Connect
    • Integrating Insomnia Enterprise with Microsoft Azure/Entra ID SAML 2.0
    • Insomnia Whitelisting Guide for Enterprise Users
    • Transfer enterprise organizations and license
    • Configuring SCIM
    • Multiple Owners
    • Manage Domains
    • Invite Controls
    • Storage Controls
    • Session Report
    • Insomnia Subscriptions
    • Insomnia Subscription Management
    • Scratch Pad Tutorial
    • Requests
    • Responses
    • Request Collections
    • Request Timeouts
    • Chaining Requests
    • Post CSV Data
    • SOAP Requests
    • gRPC
    • WebSocket Support
    • Get Started with Documents
    • Design Documents
    • Linting
    • GraphQL for OpenAPI
    • Migrate from Designer
    • Unit Testing
    • Stress Testing
    • Insomnia Storage Options Guide
    • Sync with Insomnia Cloud
    • Sync with Git
    • Key Security Features
    • Security Standards
    • Signup and Authentication
    • Analytics Collected
    • End to End Data Encryption
    • Software Bill of Materials
    • Verifying Build Provenance for Signed Insomnia Binaries
    • Authentication
    • Client Certificates
    • Collection Runner
    • Generate Code Snippet
    • Cookie Management
    • Encoding
    • GraphQL Queries
    • Run in Insomnia Button
    • Key Maps
    • Proxy
    • Folder-level settings
    • Introduction to Plugins
    • Context Object Reference
    • Template Tags
    • Hooks and Actions
    • Custom Themes
    • AI Runner
    • FAQ
    • Application Data
    • SSL Validation
    • Password Recovery
    • Introduction to Inso CLI
    • Install Inso CLI
    • CLI Command Reference
      • inso run test
      • inso run collection
      • inso lint spec
      • inso export spec
      • inso script
      • Using Custom Linting with Inso CLI
    • Configuration
    • Inso CLI on Docker
    • Software Bill of Materials
    • Verifying Signatures for Signed Inso CLI Images
    • Verifying Inso CLI Build Provenance
      • Verifying Build Provenance for Signed Inso CLI Images
      • Verifying Build Provenance for Signed Inso CLI Binaries
    • Continuous Integration
    • Insomnia Pre-request Script Overview
    • Insomnia After-Response Script Overview
    • Secret Environment Variables
    • External Vault Integration (Enterprise feature)
    • Insomnia API Mocking Overview
    • Enterprise Login Report

Environment Variables

Set up environment variables to reuse values across multiple requests. Common variables are base URLs, authentication tokens, and resource IDs.

Request using base URL and ID variables that can be reused. Request using base URL and ID variables that can be reused.

Environment Basics

An environment is a JSON object containing key-value pairs of the data you want to reference. Access the environment manager through the environment dropdown menu at the top of the sidebar. From here, you can edit the base environment, create sub environments, assign colors, and more.

The Manage Environments modal allows you to access and edit your base and sub environments. The Manage Environments modal allows you to access and edit your base and sub environments.

Note: Variable names must only contain letters, numbers, and underscores.

Referencing Environment Variables

Environment variables can be referenced in (almost) any text input within the Insomnia application. There are two ways to do this:

  1. Summon the autocomplete dropdown by pressing Control+Space
  2. Allow the autocomplete to show automatically as you type

After you have set environment variables, you can access the variables via autocomplete dropdown menu. After you have set environment variables, you can access the variables via autocomplete dropdown menu.

Once a variable is selected, it will be displayed with a colored placeholder. Clicking on the button will show a modal dialog for further editing.

Note: Hovering over the placeholder with your mouse will show the current value.

Base Environment

A base environment is assigned to every workspace within Insomnia and can be accessed via the environment manager. Variables in the base environment are available throughout the entire workspace, even if other environments are defined. A common use for the base environment is to store default variables that will not change across production, staging, or development services such as resource names, languages, sample data, etc.

Sub Environments

Sub environments are most commonly used for store variables related to production, staging, or development services. They are also sometimes used to defining variables for different users of a single app. Once sub environments exist, they can be activated via the environment dropdown.

Note: Sub environments can be created as Private, meaning they will never be synced or exported.

Folder Environments

You can access a folder’s environment from the folder settings. Click on the folder and then go to the Environment tab.

Folder Environment example

Any variables defined at the folder-level will be available to all requests within that folder. These will also override any variables defined within a sub environment or base environment.

Environment Priority

If two variables with the same name are defined in multiple environments, the environment with higher priority will win. Here is the priority of environment, ranging from highest to lowest:

  1. Folder Environment (highest priority)
  2. Sub Environment
  3. Base Environment (lowest priority)

For example, if a variable is defined in a base environment and in a sub environment, the value in the sub environment will overwrite the one in the base environment.

Recursive Variables

Environments can reference other variables, including variables defined within itself. This is especially useful for composing more complex variables such as the domain name in the following example.

Use variables within environment variable json configuration to reference other variables and minimize duplication. Use variables within environment variable json configuration to reference other variables and minimize hard-coded values.

Note: Environment variables can also contain Template Tags. Recursive, or nested, variables only work while the environment is active.

Exporting Shared and Private Environments

Environments are by default exported when exporting a collection/design document. To export them, go to Collection/Design Document’s main dropdown and click Export:

export dropdown

Shared environments will be always included in the export file.

If there are any environments marked as private need to be manually included. A dialog should open during export asking if wish to include these in the export as well.

export private envs

Edit this page
Report an issue
    COMPANY
  • Insomnia
  • Blog
  • Changelog
  • Pricing
  • Careers
    PRODUCTS
  • Insomnia
  • Inso (CLI)
    RESOURCES
  • Sign In
  • Documentation
  • Support
    LEGAL
  • Privacy Policy
  • Terms & Conditions
© Kong Inc. 2021