> For the complete documentation index, see [llms.txt](https://cleyrop.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cleyrop.gitbook.io/docs/documentation-fr-en/data-and-ai-project/dataflow/creer-un-dataflow/ajouter-des-variables-denvironnement.md).

# Add environment variables

The **environment variables** allow storing reusable information in your Dataflows, such as **URL**, **tokens**, or **external access identifiers**. They make configuring your transformations easier without directly exposing these values in the code.

***

## Add an environment variable <a href="#ajouter-une-variable-denvironnement" id="ajouter-une-variable-denvironnement"></a>

To add an environment variable, click *(x)* in the right action bar of the Dataflow.

A window opens allowing you to:

* Create a **global variable** (shared across all branches)
* Or a **local variable** (specific to the current branch)

<figure><img src="/files/33f2c53d3a871a0f272b03ece7350893123ebc3d" alt="" width="375"><figcaption></figcaption></figure>

Fill in the following fields:

* **Name** : unique identifier of the variable
* **Description** : additional information
* **Value** : content of the variable

## Choose the type of variables

#### Secret variables <a href="#variables-secretes" id="variables-secretes"></a>

* Some variables can be marked as secret.
* Their value is **encrypted** and **non-editable** after creation

{% hint style="info" %}
To change the value of a secret variable, you must **delete it and recreate it**.
{% endhint %}

#### Global vs. Local <a href="#variables-secretes" id="variables-secretes"></a>

**Global variables**

* Created in the main branch (main).
* Dynamically accessible in all branches.
* The variable value is **copied** when a new branch is created.
* Can only be modified from **branch** **main** (by the Dataflow owner).
* If a local variable has the **same name,** it is **the local value** that will be used at runtime.

**Local variables**

* Created in a **specific branch** (including main).
* Visible and editable only in their branch.
* Can have the **same name** if a common variable has the same name, the local value will be used
* Are not propagated to other branches.
* Can be **modified or deleted** freely without impacting other branches.

When running a Dataflow:

1. If a **local variable** with the same name exists, it is used.
2. Otherwise, the **global variable** (defined in main) is used.\
   No variable from another branch is visible or used.

#### Behavior example

Let's take two **global variables** defined:

* **in the main branch:**\
  Name: API\_URL / Value: <https://api.production.example.com\\>
  Name: REGION / Value: Occitanie<br>
* **in a working branch (feature/test-api),** a user creates a local variable with the same name\
  Name: API\_URL / Value: <https://api.sandbox.example.com>

When the working branch is run,

* the API\_URL variable used will be <https://api.sandbox.example.com>
* the REGION variable will remain Occitanie

If a user wants to ensure that **production environment variables will not be used** they can set them as local variables in the main branch.

## Edit and delete

**Local variables**

* Editable and deletable at any time.
* Their deletion **does not affect** other branches.

**Global variables**

* **Editable only from the main branch**, by the **Dataflow owner**.
* Any change is **propagated immediately** to all branches, except those that have redefined the variable locally.
* In case of deletion:
  * The variable disappears in all branches where it has not been redefined locally.
  * A **alert** is displayed to indicate the deletion.
