{
  "doc": {
    "id": "api/commands/env",
    "title": "env | Cypress Documentation",
    "description": "Securely read environment variables in Cypress tests using cy.env(). Learn syntax, examples, security benefits, and how to migrate from Cypress.env().",
    "section": "api",
    "source_path": "/llm/markdown/api/commands/env.md",
    "version": "29b099a83033817a9072f7deec58409720b52bc4",
    "updated_at": "2026-05-03T15:21:58.370Z",
    "headings": [
      {
        "id": "api/commands/env#env",
        "text": "env",
        "level": 1
      },
      {
        "id": "api/commands/env#syntax",
        "text": "Syntax",
        "level": 2
      },
      {
        "id": "api/commands/env#usage",
        "text": "Usage",
        "level": 3
      },
      {
        "id": "api/commands/env#arguments",
        "text": "Arguments",
        "level": 3
      },
      {
        "id": "api/commands/env#yields-learn-about-subject-management",
        "text": "Yields Learn about subject management",
        "level": 3
      },
      {
        "id": "api/commands/env#examples",
        "text": "Examples",
        "level": 2
      },
      {
        "id": "api/commands/env#single-variable",
        "text": "Single Variable",
        "level": 3
      },
      {
        "id": "api/commands/env#multiple-variables",
        "text": "Multiple Variables",
        "level": 3
      },
      {
        "id": "api/commands/env#use-environment-variables-across-tests",
        "text": "Use environment variables across tests",
        "level": 3
      },
      {
        "id": "api/commands/env#handle-required-vs-optional-variables",
        "text": "Handle required vs optional variables",
        "level": 3
      },
      {
        "id": "api/commands/env#chaining-with-other-commands",
        "text": "Chaining with other commands",
        "level": 3
      },
      {
        "id": "api/commands/env#use-cy-env-in-custom-commands",
        "text": "Use cy.env in custom commands",
        "level": 3
      },
      {
        "id": "api/commands/env#suppress-command-logging",
        "text": "Suppress command logging",
        "level": 3
      },
      {
        "id": "api/commands/env#why-use-cy-env",
        "text": "Why use cy.env()?",
        "level": 2
      },
      {
        "id": "api/commands/env#secure-access-to-sensitive-values",
        "text": "Secure access to sensitive values",
        "level": 3
      },
      {
        "id": "api/commands/env#when-to-use-cy-env-vs-cypress-expose",
        "text": "When to use cy.env() vs Cypress.expose()",
        "level": 3
      },
      {
        "id": "api/commands/env#use-cypress-expose-for-public-configuration",
        "text": "Use Cypress.expose() for public configuration",
        "level": 4
      },
      {
        "id": "api/commands/env#use-cy-env-for-sensitive-or-secret-values",
        "text": "Use cy.env() for sensitive or secret values",
        "level": 4
      },
      {
        "id": "api/commands/env#migrate-from-cypress-env",
        "text": "Migrate from Cypress.env()",
        "level": 2
      },
      {
        "id": "api/commands/env#notes",
        "text": "Notes",
        "level": 2
      },
      {
        "id": "api/commands/env#read-only-behavior",
        "text": "Read-only behavior",
        "level": 3
      },
      {
        "id": "api/commands/env#test-configuration-overrides",
        "text": "Test configuration overrides",
        "level": 3
      },
      {
        "id": "api/commands/env#case-sensitivity",
        "text": "Case sensitivity",
        "level": 3
      },
      {
        "id": "api/commands/env#history",
        "text": "History",
        "level": 2
      },
      {
        "id": "api/commands/env#see-also",
        "text": "See also",
        "level": 2
      }
    ]
  },
  "content": {
    "type": "root",
    "children": [
      {
        "type": "heading",
        "depth": 1,
        "children": [
          {
            "type": "text",
            "value": "env"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Securely read environment variables set in your Cypress configuration, `cypress.env.json`, or `CYPRESS_*` environment variables from within Cypress tests."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Read-Only Command"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.env()` is read-only and can only retrieve environment variables. It cannot set or modify environment variables. To set environment variables, use one of the supported methods described in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/environment-variables.md",
            "children": [
              {
                "type": "text",
                "value": "Environment Variables & Secrets"
              }
            ]
          },
          {
            "type": "text",
            "value": " guide."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Syntax"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(keys)cy.env(keys, options)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Usage"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Correct Usage"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')module.exports = defineConfig({  env: {    apiUrl: 'https://api.example.com',    apiKey: 'secret-key-12345',  },  expose: {    environment: 'staging', // Public configuration value  },})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'export default defineConfig({  env: {    apiUrl: 'https://api.example.com',    apiKey: 'secret-key-12345',  },  expose: {    environment: 'staging', // Public configuration value  },})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Get a single environment variablecy.env(['apiUrl']).then(({ apiUrl }) => {  cy.request(`${apiUrl}/users`).its('status').should('eq', 200)})// Get multiple environment variablescy.env(['apiUrl', 'apiKey']).then(({ apiUrl, apiKey }) => {  cy.request({    url: `${apiUrl}/users`,    headers: { Authorization: `Bearer ${apiKey}` },  })    .its('status')    .should('eq', 200)})// With optionscy.env(['apiUrl'], { log: false }).then(({ apiUrl }) => {  // Use apiUrl})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Arguments"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "keys (String[])"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "An array of environment variable keys to retrieve from Cypress. These environment variables can be set via any of the methods described in the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/environment-variables.md",
            "children": [
              {
                "type": "text",
                "value": "Environment Variables & Secrets"
              }
            ]
          },
          {
            "type": "text",
            "value": " guide."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Environment variables cannot be set using "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
            "children": [
              {
                "type": "text",
                "value": "test configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": " when `allowCypressEnv` is set to `false`."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "If a variable is not defined, its value will return `undefined` in the returned object."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "options (Object)"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Pass an options object to change the default behavior of `cy.env()`."
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Option"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Default"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Description"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`log`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`true`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Displays the command in the "
                  },
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/core-concepts/open-mode.md#Command-Log",
                    "children": [
                      {
                        "type": "text",
                        "value": "Command log"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": ". Only variable names are logged, never values."
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`timeout`"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "4000"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Time to wait for `cy.env()` to resolve before timing out."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Yields "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management",
            "children": [
              {
                "type": "text",
                "value": "Learn about subject management"
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.env()` yields an object with the values found for the environment variable keys requested."
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['apiUrl', 'apiKey']).then((env) => {  // env = { apiUrl: 'https://api.example.com', apiKey: 'secret-key-12345' }})"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Examples"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Single Variable"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Get a single environment variable:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['apiUrl']).then(({ apiUrl }) => {  cy.visit(apiUrl)})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Multiple Variables"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Get multiple environment variables at once:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['apiUrl', 'apiKey', 'timeout']).then(({ apiUrl, apiKey, timeout }) => {  cy.request({    url: `${apiUrl}/users`,    headers: { Authorization: `Bearer ${apiKey}` },    timeout: timeout || 5000,  })})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Use environment variables across tests"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Store environment variables for use across multiple tests by using a `before()` hook:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "describe('API tests', () => {  let apiBaseUrl  before(() => {    cy.env(['apiBaseUrl']).then(({ apiBaseUrl: url }) => {      apiBaseUrl = url    })  })  it('can make requests', () => {    cy.request(`${apiBaseUrl}/users`).its('status').should('eq', 200)  })})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Handle required vs optional variables"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Variables that are not set will be `undefined`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['requiredVar', 'optionalVar']).then(({ requiredVar, optionalVar }) => {  if (requiredVar === undefined) {    throw new Error('requiredVar must be set in Cypress configuration')  }  // Use optionalVar only if it's defined  if (optionalVar) {    // Use optionalVar  }})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Chaining with other commands"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['baseUrl']).then(({ baseUrl }) => {  cy.visit(baseUrl)  cy.get('h1').should('be.visible')})"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Use cy.env in custom commands"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Create custom commands that use `cy.env()`:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// cypress/support/commands.jsCypress.Commands.add('apiRequest', (endpoint, options = {}) => {  cy.env(['apiUrl', 'apiKey']).then(({ apiUrl, apiKey }) => {    cy.request({      url: `${apiUrl}${endpoint}`,      headers: {        Authorization: `Bearer ${apiKey}`,        ...options.headers,      },      ...options,    })  })})// In your testcy.apiRequest('/users').its('status').should('eq', 200)"
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Suppress command logging"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Hide the command from the command log:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "cy.env(['apiKey'], { log: false }).then(({ apiKey }) => {  // The command and variable name won't appear in command log})"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Why use cy.env()?"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.env()` was introduced to replace the deprecated `Cypress.env()` API."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Secure access to sensitive values"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Unlike "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/cypress-api/env.md",
            "children": [
              {
                "type": "text",
                "value": "`Cypress.env()`"
              }
            ]
          },
          {
            "type": "text",
            "value": ", which hydrates all environment variables into the browser:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.env()` only exposes the variables you explicitly request"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Variables are not automatically serialized into browser state"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Only requested variables are passed into `cy.origin()` contexts"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Sensitive data is easier to audit and control"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "This reduces accidental exposure and limits the blast radius of secrets."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "When to use cy.env() vs Cypress.expose()"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Both "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/commands/env.md",
            "children": [
              {
                "type": "text",
                "value": "`cy.env()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " and "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/cypress-api/expose.md",
            "children": [
              {
                "type": "text",
                "value": "`Cypress.expose()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " provide access to configuration values in Cypress, but they serve different security and execution needs. Choosing the right API helps avoid accidental exposure of sensitive data and keeps configuration intent clear."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Use Cypress.expose() for public configuration"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Recommended when:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Values are public or non-sensitive - Examples include feature flags, API versions, environment labels, or plugin configuration that is safe to appear in browser state."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Synchronous access is needed - `Cypress.expose()` returns values immediately, without requiring Cypress command chaining."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 4,
        "children": [
          {
            "type": "text",
            "value": "Use `cy.env()` for sensitive or secret values"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Choose `cy.env()` when security, scoping, and controlled access matter. Recommended when:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Values are sensitive - API keys, passwords, tokens, or any data that should not be broadly exposed to the browser."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "Security is a priority - `cy.env()` only exposes the variables you explicitly request and does not automatically serialize them into browser state."
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "You're already working within Cypress command chains: `cy.env()` is asynchronous and designed to be used inside Cypress tests and hooks."
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Example: choosing the right API"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// ✅ Use cy.env() for sensitive valuescy.env(['apiKey']).then(({ apiKey }) => {  cy.request({    url: 'https://api.example.com/users',    headers: { Authorization: `Bearer ${apiKey}` },  })})// ✅ Use Cypress.expose() for public configurationconst apiVersion = Cypress.expose('apiVersion') // Synchronous, public valueconst featureFlag = Cypress.expose('featureFlag') // Safe to expose in browser"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/cypress-api/expose.md",
            "children": [
              {
                "type": "text",
                "value": "`Cypress.expose()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " for more details."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Migrate from Cypress.env()"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.env()` replaces the deprecated "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/api/cypress-api/env.md",
            "children": [
              {
                "type": "text",
                "value": "`Cypress.env()`"
              }
            ]
          },
          {
            "type": "text",
            "value": " API."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "After migrating all usages, you can prevent future use of `Cypress.env()` by disabling it in Cypress configuration using the `allowCypressEnv` option:"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.js"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "text",
                    "value": "cypress.config.ts"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "const { defineConfig } = require('cypress')module.exports = defineConfig({  allowCypressEnv: false,})"
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "import { defineConfig } from 'cypress'export default defineConfig({  allowCypressEnv: false,})"
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/migration-guide.md#Migrating-away-from-Cypressenv",
            "children": [
              {
                "type": "text",
                "value": "Migration Guide"
              }
            ]
          },
          {
            "type": "text",
            "value": " for detailed migration instructions."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "Notes"
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Read-only behavior"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "`cy.env()` is read-only and cannot set environment variables at runtime."
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "See the "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/guides/environment-variables.md",
            "children": [
              {
                "type": "text",
                "value": "Environment Variables & Secrets"
              }
            ]
          },
          {
            "type": "text",
            "value": " guide for more details on setting environment variables."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Test configuration overrides"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Environment variables cannot be set using "
          },
          {
            "type": "link",
            "title": null,
            "url": "/llm/markdown/app/references/configuration.md#Test-Configuration",
            "children": [
              {
                "type": "text",
                "value": "test configuration"
              }
            ]
          },
          {
            "type": "text",
            "value": " when `allowCypressEnv` is set to `false`. This is a security feature to prevent exposing sensitive data through test configuration."
          }
        ]
      },
      {
        "type": "heading",
        "depth": 3,
        "children": [
          {
            "type": "text",
            "value": "Case sensitivity"
          }
        ]
      },
      {
        "type": "paragraph",
        "children": [
          {
            "type": "text",
            "value": "Variable names are case-sensitive and must match exactly how they are defined in your configuration:"
          }
        ]
      },
      {
        "type": "code",
        "lang": null,
        "meta": null,
        "value": "// Configuration{  env: {    apiUrl: 'https://api.example.com',  }}// In testcy.env(['apiUrl'])  // ✅ Gets 'https://api.example.com'cy.env(['APIURL']) // ❌ Returns undefined"
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "History"
          }
        ]
      },
      {
        "type": "table",
        "align": [
          null,
          null
        ],
        "children": [
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Version"
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "Changes"
                  }
                ]
              }
            ]
          },
          {
            "type": "tableRow",
            "children": [
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/changelog.md#15-10-0",
                    "children": [
                      {
                        "type": "text",
                        "value": "15.10.0"
                      }
                    ]
                  }
                ]
              },
              {
                "type": "tableCell",
                "children": [
                  {
                    "type": "text",
                    "value": "`cy.env()` command added"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "type": "heading",
        "depth": 2,
        "children": [
          {
            "type": "text",
            "value": "See also"
          }
        ]
      },
      {
        "type": "list",
        "ordered": false,
        "start": null,
        "spread": false,
        "children": [
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/cypress-api/env.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`Cypress.env()`"
                      }
                    ]
                  },
                  {
                    "type": "text",
                    "value": " (deprecated)"
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/api/cypress-api/expose.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "`Cypress.expose()`"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/configuration.md",
                    "children": [
                      {
                        "type": "text",
                        "value": "Configuration"
                      }
                    ]
                  }
                ]
              }
            ]
          },
          {
            "type": "listItem",
            "spread": false,
            "checked": null,
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "link",
                    "title": null,
                    "url": "/llm/markdown/app/references/migration-guide.md#Migrating-away-from-Cypressenv",
                    "children": [
                      {
                        "type": "text",
                        "value": "Migration Guide: migrating away from `Cypress.env()`"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  },
  "token_estimate": 1448
}