# Set gateway variables

A gateway variable is a named value stored in one environment. [Recipes](https://docs.faustine.ai/apis/recipes/) read it as `sdk.env.NAME` when they run in that environment, so the same recipe can use a different value in Staging and in Production.

Variables are encrypted and are never shown again after you save them. Clients do not see them, and a script a client runs in Code mode cannot read them.

## Add a variable

To add a variable:

1. In the portal, go to [**Agent Gateway**](https://auth.faustine.ai/go?to=%2Fintegrations%2Fagent-gateway) and select your gateway.
2. Check the environment button in the header. The variable is stored in the environment it names.
3. Select the **Variables** tab, then **Add a variable**.
4. Enter the name and the value.
5. Select **Add**.

The table lists the variable by name with the date it was last updated. The value column shows only its length.

A recipe reads the variable by name:

```js
const res = await sdk.crm.contactsList({ region: sdk.env.REGION })
return res.items
```

## Replace a value

To store a new value under an existing name, select **Rotate** on the variable's row, enter the new value and select **Rotate**. The previous value cannot be recovered.

## Delete a variable

Select **Delete** on the variable's row and confirm. Every recipe that reads that name in this environment fails on the line that reads it.

## Limits

| Limit | Value |
| --- | --- |
| Name | Letters, digits and underscores, not starting with a digit. Up to 64 characters. |
| Value | Up to 4096 characters. |
| Variables per environment | 100 |

## Variables and environments

Variables are not copied when you add an environment or promote one onto another. The **Variables** tab also lists the names that another environment of the gateway has and this one lacks. Select one of those rows to set its value here. Values never travel between environments.

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| A recipe fails and the error names a variable | The variable is not set in the environment the call was made on. | Add it in that environment's **Variables** tab. |

## Next steps

- [Recipes](https://docs.faustine.ai/apis/recipes/): operations made of several calls.
- [Environments](https://docs.faustine.ai/agent-gateway/environments/): what each environment owns.
- [Promote from one environment to another](https://docs.faustine.ai/agent-gateway/promote/): what a promotion copies and what it leaves.
