> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/releases-and-environments/environment-variables-and-secrets.md).

# Environment Variables and Secrets

Environment variables and secrets supply configuration without copying it into each workflow step. Separate values for each environment when services or credentials differ.

{% embed url="<https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FCOj3D7qQe889fc4w3Jnw%2FG075.mp4?alt=media&token=e75e016b-0e5e-47a2-91fe-d809c464058a>" %}

## Before you begin

Permission to manage the project’s environment settings.

## Key concepts

| Term        | Definition                                                                                                                                                  |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Environment | A named configuration context for variables, secrets, and deployment use. Different environments can reach different services or use different credentials. |
| Connection  | A saved authorization to a particular provider account. An action uses the selected account’s access, subject to StackAI sharing controls.                  |

## Configuration options

| Option               | Purpose                                                         | Behavior                                                                                |
| -------------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------------- |
| Environment variable | A named configuration value selected for the run’s environment. | Keep the variable key stable and review values for each destination environment.        |
| Secret               | Sensitive configuration such as a credential.                   | Use supported secret fields and avoid exposing values in prompts, logs, or screenshots. |

## Configure environment variables

1. Define the required variables and secret values in the intended environment.

![Define the variable key and the values required for each environment stage.](https://content.gitbook.com/content/SQ1Sgy933krTyK0S4JpP/blobs/lRGGSxj2Cu1PBo9SGBpQ/assets/g075-g075-02-values.png)

Define the variable key and the values required for each environment stage.

2. Reference them through the supported configuration fields.
3. Run the selected version in that environment and confirm the destination and behavior.

The workflow uses the values assigned to the selected environment.

## Behavior and limitations

Changing a variable can affect multiple steps that reference it. A variable name is not its value. Keep secrets out of prompts and visible output. Check environment selection when a workflow reaches the wrong service or cannot find a required configuration value.

## Related resources

[Create environment variables](/guides-and-quickstarts/releases-and-environments/create-environment-variables.md)

[Saved Changes, Versions, and Published Releases](/technical-reference/releases-and-environments/saved-changes-versions-and-published-releases.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/releases-and-environments/environment-variables-and-secrets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
