website/src/docs/nitro/environments.md
Environment variable provide a mechanism for reusing specific values across multiple documents. These variables are defined as key-value pairs.
Frequently used data, like URLs, tokens, and credentials, are commonly centrally managed as environment variable. By doing so, these values can be referenced in your documents and changed in a single location for all you documents. You can also quickly switch between different values for different environments.
For instance, you might store your API key as an environment variable, allowing it to be used universally in all your documents. If the API key changes, you can just update the environment variable without having to manually alter each document.
You can define multiple environments for a single workspace corresponding to various contexts or project stages (e.g., development, testing, production). The environments can be switched in the status bar.
When you have different project stages such as such as development (https://serivce1.dev.company.com), testing (https://serivce1.test.company.com), and production (https://serivce1.prod.company.com), you can for example set up the dynamic part of the url as a variable URL and incorporate it in all your urls (https://serivce1.{{subdomain}}.company.com).
By switching the active environment in Nitro, the base URL will update automatically, streamlining your workflow.
Similarly, identifiers such as client ID and client secret can be defined as environment variable, which make it convenient to work with.
To create a new environment, follow these steps:
You can rename by right-clicking on the environment and selecting the 'Rename' option.
To open the environment variable editor, click on the environment you would like to edit.
{{ClientId}}, {{ClientSecret}} {{Subdomain}}To switch environments, click on the environment name in the status bar. A dropdown menu will appear, listing all available environments. After selecting an environment, the environment variables of the selected environment will be active and applied to all documents.
Once you have defined an environment variable, you can reference it in your documents by using the following syntax: {{variable_name}}.
Environment variable can be employed in a variety of places within Nitro, such as URLs, GraphQL Variables, and Connection Settings. When a request is executed, any referenced environment variable will be substituted with their respective values.