# Replacement variables

## Introduction

Variables can be defined for an environment and then referenced throughout your process flow, using an [environment variable syntax](#environment-variable-syntax).

## Environment variable syntax

Environment variables are referenced using the following syntax:

```
{{environment.variables.your_variable_name}}
```

For example:

```
{{environment.variables.region}}
```

## Where can I reference environment variables?

Environment variables can be referenced throughout process flows - anywhere that you can reference [flow variables](https://doc.wearepatchworks.com/product-documentation/process-flows/building-process-flows/dynamic-variables/flow-variables), you can reference environment variables too.

## Defining environment variables

To define an environment variable, follow the steps below.

{% stepper %}
{% step %}
**Edit the configuration for the required virtual environment**

If you're not already editing the configuration for your virtual environment, [access it now](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/..#accessing-the-draft-version-for-a-new-virtual-environment).
{% endstep %}

{% step %}
**Access environment variables**

Select `environment variables` from the list of [replacements](https://doc.wearepatchworks.com/product-documentation/virtual-environments/implementing-virtual-environments/configuring-a-virtual-environment-version/configuring-virtual-environment-replacements):

<div align="left"><figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FHKLc5S0rTIeL8OH6T2nB%2Fenv%20variable%201.png?alt=media&#x26;token=a980f78f-2d66-44b0-baba-e6b308d0d0b2" alt="" width="375"><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}
**Create a new variable**

Click the `create` button:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FBlYIAE0xwL0LB0RwPFID%2Fenv%20variable%202.png?alt=media&#x26;token=f9f4dc2f-55e0-4735-b297-1a30005bda2d" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Configure the variable**

Configure variable settings and click the `create` button to confirm:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpsmzhEpjKZ7efOwv8KNt%2Fenv%20variable%203.png?alt=media&#x26;token=4e0ac9e6-8b68-4a9f-b4a0-dd6f1ec8c20b" alt=""><figcaption></figcaption></figure>

Options on this page are summarised below:

| Field                      | Summary                                                                                                                                                                                                                                 |
| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Name                       | The name (i.e. the *key*) to be used when referencing this variable.                                                                                                                                                                    |
| Type                       | Select the expected data type for resolved variable values.                                                                                                                                                                             |
| Value                      | If required, set a default value for this variable.                                                                                                                                                                                     |
| Fallback                   | Enter a value to be used if the variable cannot be resolved.                                                                                                                                                                            |
| Is this variable a secret? | Toggle this option `on` if values entered for this field are sensitive. Secret variables are encrypted. Note that environment variables are never displayed in the dashboard, irrespective of whether or not they are marked as secret. |
| {% endstep %}              |                                                                                                                                                                                                                                         |
| {% endstepper %}           |                                                                                                                                                                                                                                         |

## Managing environment variables

If required, you can [update](#updating-an-existing-environment-variable) or [remove](#removing-an-existing-environment-variable) existing environment variables.

### Updating an existing environment variable

To change the settings for an existing environment variable, follow the steps below.

{% stepper %}
{% step %}
**Edit the required variable**

Click the `edit` icon associated with the environment variable you want to update - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FwPVLFOyf0I9UEgfcT8yj%2Fenv%20variable%20edit.png?alt=media&#x26;token=81c5bac5-9ee6-4a57-921f-2790a8798ee4" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Update settings**

Update variable settings as needed:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FpWLVLSYDH7HTZkb3sHl3%2Fenv%20variable%20edit%20b.png?alt=media&#x26;token=97370fa1-13e1-426d-8f48-de0d1d785a31" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Confirm changes**

Click the `update` button to confirm your changes:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2FYqxLfbVF2C6NdWHTs4mj%2Fenv%20variable%20edit%20c.png?alt=media&#x26;token=a19da0e7-b742-4d96-8fdb-2fe9063463a6" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

### Removing an existing environment variable

To remove an existing environment variable, click the `trash` icon associated with the environment variable you want to remove - for example:

<figure><img src="https://2440044887-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLYNcUBVQwSkOMG6KjZfz%2Fuploads%2Fyx3xyTi9wWPBk6CxMH5D%2Fenv%20variable%20delete%20a.png?alt=media&#x26;token=f458676c-2b6e-49ea-9cae-9e5f690ad794" alt=""><figcaption></figcaption></figure>

The variable is removed immediately.
