{"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"environment-variables","__idx":0},"children":["Environment variables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Redocly sets environment variables when running API registry jobs. The API registry runs both the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["lint"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bundle"]}," commands which can use environment variables."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["To learn how to set up environment variables for Developer portals, refer to the ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs-legacy/developer-portal/guides/environment-variables"},"children":["portal guide"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"built-in-environment-variables","__idx":1},"children":["Built-in environment variables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Two built-in environment variables can control arguments passed to these respective commands for additional runtime control:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Command"},"children":["Command"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Environment variable"},"children":["Environment variable"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Example value"},"children":["Example value"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Exceptions"},"children":["Exceptions"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["lint"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["REDOCLY_CLI_LINT_ARGS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["--skip-rule=no-sibling-refs"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Does not support ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--format"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--config"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--lint-config"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["bundle"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["REDOCLY_CLI_BUNDLE_ARGS"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["--skip-decorator=decorators/remove-internal-schema-properties"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Does not support ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["--metafile"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"custom-environment-variables","__idx":2},"children":["Custom environment variables"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Custom plugins can create, read, and modify environment variables."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pay attention to the following limitations (and differences from environment variables in the developer portals):"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API registry doesn't support ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":[".env.*"]}," files for defining environment variables. For API versions in the registry, environment variables can only be defined in Workflows settings."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can't use environment variables in the Redocly configuration file or add them directly to your API definitions. For API versions, they are supported only in ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/custom-plugins"},"children":["custom plugins"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When creating your own environment variables, their names must not start with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["REDOCLY_"]},". That prefix is reserved for special internal variables."]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-1-define-the-variable-in-workflows-settings","__idx":3},"children":["Step 1: Define the variable in Workflows settings"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In the Workflows app, select your API version from the API registry page."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On the API version page, select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Settings"]},", then ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Environment variables"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Environment variables"]}," page, select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Add variable"]},"."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In the dialog that opens, define the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["name"]}," and the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["value"]}," for your environment variable. If you're adding one of the internal variables, make sure its name is correct."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Optionally, select the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Secret"]}," checkbox. This encrypts the value of the variable and hides it from the logs. Use this to protect your credentials, private URLs, and similar sensitive data."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Select ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Create variable"]}," to finish adding a new variable. For the built-in environment variables, this step completes the configuration."]}]}]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"info","name":"Tip"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If necessary, you can modify an existing environment variable in Workflows at any point after creating it. Select the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["Edit"]}," icon next to the variable on the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Environment variables"]}," page. In the dialog that opens, change the environment variable name and/or value, then save your changes."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"step-2-use-the-variable-in-your-custom-plugin","__idx":4},"children":["Step 2: Use the variable in your custom plugin"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create a custom rule or decorator as a JS file. Place it in the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["rules"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["decorators"]}," directory which you have created in the root of your project."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In your rule or decorator, use the environment variables (name must match the name defined in Step 1)."]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Common uses for environment variables would be to influence code flow or to set a value used in the rules or decorators."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["It is a good practice to check for the environment variables existing before usage."]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Ncode flow example","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"if ('EXAMPLE_VARIABLE' in process.env && process.env.EXAMPLE_VARIABLE == 'blog') {\n  // This demonstrates code flow based the value of the EXAMPLE_VARIABLE\n}\n","lang":"js"},"children":[]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"value used example","disable":false},"children":[{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"js","header":{"controls":{"copy":{}}},"source":"if ('EXAMPLE_VARIABLE' in process.env) {\n  // This demonstrates using the value of the variable\n  myValue = process.env.EXAMPLE_VARIABLE;\n}\n","lang":"js"},"children":[]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Refer to the custom plugins documentation to ",{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/custom-plugins"},"children":["learn more about writing custom plugins"]},", and review some examples:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/guides/change-token-url"},"children":["Change token URL decorator"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/guides/hide-apis"},"children":["Hide APIs decorator"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/guides/replace-servers-url"},"children":["Replace server URL decorator"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"Link","attributes":{"href":"/docs/cli/guides/response-contains-property"},"children":["Response contains property rule"]}]}]}]},"frontmatter":{"excludeFromSearch":true},"tagList":["admonition","tab","tabs"],"title":"Environment variables","lastModified":"2025-08-10T02:58:02.000Z"}