# Set variables for each environment

A variable is a configuration value the agent's actions read, such as the base URL of your API. The analysis finds the variables in your app's configuration. Set a value for each environment when Staging and Production call different backends.

> **Warning:** Variables are sent to the browser with the widget, so anyone who opens your site can read them. Do not put a secret in a variable.

## How values are resolved

Each variable has a default and can have one value for each environment. When the widget loads, the agent uses the environment's value, or the default when that environment has none. The actions read the result as `config.<NAME>`.

A variable with no default and no value in an environment blocks that environment. Faustine refuses to publish to it or to serve a version on it until the variable has a value.

## Set a default

To set the value every environment falls back to:

1. In the portal, go to [**Web Agents**](https://auth.faustine.ai/go?to=%2Fweb-assistants) and select your agent.
2. Select the **Variables** tab.
3. Under **Definitions**, find the variable. Next to its name is the place in your code it came from.
4. Enter the **Default value**. You can also edit the **Description**.

The field saves when you leave it and shows **Saved**. A default belongs to the draft, so it reaches your site with the next version you publish.

![The Variables tab, with the definition of each variable and its value on Production.](https://docs.faustine.ai/images/web-agents/variables-light.png)

## Set a value for one environment

To override the default in an environment:

1. Under **Environment values**, find the variable's row and the environment's column.
2. Enter the value. A cell that is empty shows the default with a **default** tag.
3. Select **Save** followed by the environment's name, such as **Save Staging**.

Saving an environment stores its whole column: every value of that environment is replaced with what the column shows. Environment values belong to the environment and are not part of a version.

A cell with a warning icon has no value and no default.

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| The tab shows **No variables discovered** | The analysis did not find configuration values in your code. | Nothing to do. |
| Publishing or deploying fails and names variables that are missing values | A variable has no default and no value in the target environment. | Enter a value for that environment, or a default, and try again. |
| Actions on Staging call the Production API | Staging has no value for the base URL and falls back to the default. | Enter the Staging URL in the Staging column and save. |

## Next steps

- [Versions, environments and deployments](https://docs.faustine.ai/web-agents/versions-and-environments/): what belongs to a version and what belongs to an environment.
- [Deploy a version to an environment](https://docs.faustine.ai/web-agents/deploy-a-version/): serve a version once its variables are set.
- [Actions](https://docs.faustine.ai/web-agents/actions/): the code that reads the variables.
