> ## Documentation Index
> Fetch the complete documentation index at: https://docs.virtualityhub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Secrets and environment variables

> Inject encrypted secrets and environment variables into V-Run Python workflows at runtime — declared in config.yaml and scoped per workflow.

Workflows often need external credentials (API keys, database passwords) and configuration values (endpoints, feature flags). V-Run provides two mechanisms to inject these at runtime, both scoped to a single workflow.

## Secrets

Secrets are encrypted values that are never exposed in the UI after creation. Use them for:

* API keys and tokens
* Database passwords
* Private keys
* Any value you would never commit to source control

### Setting secrets

Secrets live inside the workflow that uses them. Open the workflow in the editor and set them from the **Config** tab alongside your environment variables.

### Using secrets in code

Secrets are injected as environment variables at runtime. Access them with `os.environ`:

```python theme={null}
import os

api_key = os.environ["API_KEY"]
db_password = os.environ["DATABASE_PASSWORD"]
```

### Declaring required secrets

List secrets your workflow needs in the `config.yaml` so that missing secrets are flagged before execution:

```yaml theme={null}
secrets:
  - API_KEY
  - DATABASE_PASSWORD
```

## Environment variables

Environment variables store non-sensitive configuration values. Unlike secrets, their values are visible in the UI.

Use them for:

* API endpoint URLs
* Feature flags
* Configuration modes (e.g. `LOG_LEVEL=debug`)

### Setting environment variables

Environment variables are also defined per-workflow, from the **Config** tab of the editor.

### Using environment variables in code

Access them the same way as secrets:

```python theme={null}
import os

api_url = os.environ.get("API_URL", "https://api.example.com")
log_level = os.environ.get("LOG_LEVEL", "info")
```

### Declaring required environment variables

```yaml theme={null}
required_env:
  - DATABASE_URL
  - API_URL
```

## Scope

Both secrets and environment variables are scoped to a single workflow — there is no shared, account-level, or project-level scope. If two workflows need the same value, set it on each one independently.
