# Variables and Secrets

{% hint style="warning" %}
Keep sensitive data secure! Use Secrets and Variables to protect credentials and private information in a collaborative workspace.
{% endhint %}

## Using Variables and Secrets

Variables and Secrets in dex are reusable placeholders that help you manage configuration values across environments while supporting collaboration and security.

Both are used as text replacements throughout the platform and can be referenced dynamically in configurations, especially when working with external data sources in **Connections**. However, they serve different purposes:

* **Variables** store visible, editable values that can be reused across multiple components. When you update a variable, it is automatically updated wherever it’s referenced.
* **Secrets** store sensitive values like passwords or tokens. Once entered, they are encrypted and cannot be viewed or edited again—ensuring privacy and security in shared environments.

{% embed url="<https://youtu.be/1YyTKfnW_aw>" %}
Adding Variables and Secrets
{% endembed %}

### Creating and Managing Variables and Secrets

To create a new variable or secret, go to the **Variables** menu on the left-hand sidebar. Click “New Variable” to open the form.

You’ll need to provide the following:

* **Name**: A unique identifier for the variable or secret. Names must contain only **uppercase letters and underscores** (e.g. `API_TOKEN` or `COMMON_VARIABLE`).
* **Value**: The text or secret you want to store.
* **Mark as Secret**: If enabled, the value will be encrypted and hidden after saving.
* **Scope**: Choose whether this variable is available at the **Project** level or the **Environment** level.
* **Choose the Project or Environment**: Select the scope where this variable or secret will be accessible.

Once saved, variables will remain editable and visible. Secrets, on the other hand, are hidden and cannot be retrieved or updated—only deleted and re-created.

### Using a Variable

To reference a variable or secret in dex, use the double-curly brace syntax:

```plaintext
{{ VARIABLE_NAME }}
```

This works across all configuration fields, especially when setting up credentials, file paths, schema names, or API keys in **Connections**.

For example:

* Use `{{ DB_PASSWORD }}` in a database connection form.
* Reference `{{ BUCKET_NAME }}` in your storage configuration.

When dex runs your workflows, these placeholders will be automatically replaced with the latest value stored in the Variables menu—ensuring consistency and maintainability across teams and projects.

{% hint style="success" %}
Best practice: Use Variables to store shared identifiers (like schema names or folder prefixes), and use Secrets for anything sensitive like tokens, passwords, or keys.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.dexlabs.io/lakehouse-platform/variables-and-secrets.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
