# `npx @sanity/cli functions env add`

Set or replace one environment variable on a deployed Function. The command writes to the Functions API and does not redeploy the Stack.

Run from the Blueprint directory or a subdirectory; the manifest is required even though the command only touches remote state.

## Confirm the target

Resolve the deployed Function name and Stack before changing remote state. Use `functions env list` to inspect existing keys when replacing a value was not explicitly requested.

Set a non-secret value:

```sh
npx @sanity/cli functions env add process-order API_URL https://api.example.com/
```

Override the locally configured Stack with `--stack NAME_OR_ID`.

## Protect secret values

The value is a positional command argument and may be visible in shell history, process inspection, or agent tool transcripts. Do not run the command with a secret until the user has approved both the target and the handling method.

Do not use `--json` or `--trace` for secrets: the JSON result contains the value, and trace output prints the request body. Never paste a secret value into source files, logs, issue comments, or an assistant response.

After setting the variable, verify only its key:

```sh
npx @sanity/cli functions env list process-order --json
```
