> For the complete documentation index, see [llms.txt](https://docs.qyrus.com/api-testing/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.qyrus.com/api-testing/project-setup/global-and-environment.md).

# Global-&-Environment

Global variables are reusable project-level values that help keep API tests consistent and easy to maintain. A variable can have a different value in each environment, allowing the same test to run against development, staging, and other targets without editing the test script.

> **Data use notice:** Do not enter production or sensitive data. Use only non-confidential, synthetic, or anonymized data.

## Table of Contents

* [Open Global Variables](#open-global-variables)
* [Create and manage environments](#create-and-manage-environments)
* [Create a global variable](#create-a-global-variable)
* [Supported variable types](#supported-variable-types)
* [Store String, XPath, and JSONPath values](#store-string-xpath-and-jsonpath-values)
* [Set values for multiple environments](#set-values-for-multiple-environments)
* [Use a global variable in a test](#use-a-global-variable-in-a-test)
  * [Open the variables panel from an API script](#open-the-variables-panel-from-an-api-script)
* [Edit or delete variables](#edit-or-delete-variables)
* [Input checks and troubleshooting](#input-checks-and-troubleshooting)

## Open Global Variables

1. Open an API Testing project.
2. Open **Setup** in the top navigation bar, or expand **Setup** in the Home sidebar.
3. Select **Global Variables**.

The page lists variable names and their values for **Global Default** and any environments you create. Use **Quick Search** to locate a variable or **New Variable** to add one.

![Global Variables page](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-d32043443e75f5c8749c2ca5150532223b7d862e%2FGlobal-Variables-Page.png?alt=media)

## Create and manage environments

**Global Default** is available automatically and cannot be renamed or deleted. Additional environments let you assign target-specific values to the same variable.

### Create an environment

1. Select **Environment** on the Global Variables page.
2. Enter an **Environment Name** of up to 60 characters.
3. To copy existing values, enable **Clone Data From Other Environment** and select the source environment.
4. Select **Create**.

![New Environment dialog](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-0b72427b18c1d8231f2e61cd1d692ab0d8db9024%2FCreate-Environment.png?alt=media)

After an environment is created, it appears as another value column or row when variables are created and managed. Environment actions in the environment menu can be used to rename, clone, or delete non-default environments.

Open the three-dot menu beside an environment's name to view its actions. **Global Default** provides **Environment Info**, **Clone**, and **Export Environment**; it does not offer rename or delete actions.

![Global Default environment actions](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-2aa595bd2542475fe07bff74193df42f6a019b55%2FEnvironment-Actions.png?alt=media)

### View environment information

Open the environment's actions menu and point to or select **Environment Info** to view the creator, last updater, and associated dates.

![Environment Info showing creator and update details](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-4359cb2f53ea877e1249f6489121f222d0ce08cf%2FEnvironment-Info.png?alt=media)

### Export an environment

Use **Export Environment** to copy environment configuration to a destination workspace and environment.

1. Open the source environment's three-dot menu and select **Export Environment**.
2. In **Export Environment to Workspace**, verify the source name under **Exporting Environment**.
3. Choose a destination in **Select Workspace**.
4. Choose the destination in **Select Environment**, which is disabled until a workspace is selected.
5. Review the destination and select **Export** when the button becomes available.

![Export Environment dialog with workspace and environment selectors](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-3486aa1fa5ffc8c85cc1405e0220ea1474569fb1%2FExport-Environment.png?alt=media)

Check the values in the destination before running tests, especially base URLs and environment-specific values. If **Export** is disabled, complete both destination selections.

## Create a global variable

1. Select **New Variable**.
2. Enter a unique **Variable Name** of up to 60 characters.
3. Select a **Variable Type**.
4. Enter or configure a value for **Global Default** and each environment.
5. Select **Create Variable**.

Variable names should start with a letter and use letters, numbers, or underscores. Keep names unique across the project.

Examples: `base_url`, `customer_id`, and `response_json_path`.

## Supported variable types

The selected type determines whether Qyrus stores a supplied value or generates one during execution.

| Variable type       | Purpose and input                                                                                                      |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| **Custom**          | Stores a user-provided custom value exactly as entered.                                                                |
| **String**          | Stores plain text such as names, identifiers, media types, or other reusable string values.                            |
| **XPath**           | Stores an XPath expression for locating data in XML or SOAP content, for example `/bookstore/book[1]/title`.           |
| **JSONPath**        | Stores a JSONPath expression for locating data in JSON content, for example `$.store.book[0].title`.                   |
| **Integer**         | Generates an integer between the configured minimum and maximum values.                                                |
| **Decimal**         | Generates a number using the configured minimum, maximum, and decimal-point precision.                                 |
| **Persistent UUID** | Automatically generates a unique UUID that remains persistent.                                                         |
| **Email**           | Stores an email or generates one from a pattern. `?` becomes a random letter and `#` becomes a digit from 0 through 9. |
| **Date**            | Stores a selected date in the displayed date format.                                                                   |
| **Future Date**     | Generates a future date using a maximum year and date format.                                                          |
| **Past Date**       | Generates a past date using a minimum year and date format.                                                            |
| **Protected**       | Stores a masked value separately for each environment. Use it for values that should not be displayed as plain text.   |
| **Password**        | Stores or generates a password value.                                                                                  |
| **First Name**      | Automatically generates a random first name. Use String when a specific name is required.                              |
| **Last Name**       | Automatically generates a random last name. Use String when a specific name is required.                               |
| **Base URL**        | Stores an API base URL separately for each environment.                                                                |
| **Header**          | Stores a reusable header value and supports applying one value to multiple environments.                               |

### Custom

Enter a custom value exactly as it should be substituted during execution.

![Custom variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-35df7ee2da7e704bc0b23b452e29bfbfd58071ec%2FVariable-Custom.png?alt=media)

### String

Use **String** to store a fixed text value. String variables are useful for names, identifiers, media types, request values, and other text that should not be generated dynamically.

Examples:

```
active
application/json
customer-001
```

### XPath

Use **XPath** to store a path expression that selects a value from an XML or SOAP document.

Examples:

```
/bookstore/book[1]/title
//customer/id
```

### JSONPath

Use **JSONPath** to store a path expression that selects a value from a JSON document.

Examples:

```
$.store.book[0].title
$.customer.id
```

String, XPath, and JSONPath values can be different for **Global Default** and each configured environment.

### Integer and Decimal

For **Integer**, provide the minimum and maximum. For **Decimal**, also specify the number of decimal places.

![Integer variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-620580e73e12f8144502394ac29b4437fd91018e%2FVariable-Integer.png?alt=media)

![Decimal variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-58c1879f04802107d06ccad9b89a759c7ba5ec07%2FVariable-Decimal.png?alt=media)

### Persistent UUID and Email

**Persistent UUID** generates a unique stable value. **Email** accepts a fixed address or a pattern such as `????####@email.com`.

![Persistent UUID variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-1543eff59e3a2c3230f736c3a67453d3e732e35f%2FVariable-Persistent-UUID.png?alt=media)

![Email variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-0c962bc41bdcb8ae2f63abd9cac2e91b6d273fb1%2FVariable-Email.png?alt=media)

### Date types

Use **Date** for a specific date. Use **Future Date** or **Past Date** to generate dates within the configured bounds and format.

![Date variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-f815f7f17a1e5cd1cc7f1f14e0e4853d53d1861b%2FVariable-Date.png?alt=media)

![Future Date variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-c565a16a5e5c5c821e9abad92c80516d716329ad%2FVariable-Future-Date.png?alt=media)

![Past Date variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-67901d3d905d5b2bc782857f39376a09dad715e1%2FVariable-Past-Date.png?alt=media)

### Protected values and Password

Use **Protected** for values that should be masked in the interface and **Password** for password values. Values can be supplied independently for Global Default and every environment. Masking describes how a value is displayed; the configured value is still used when a request references it.

![Protected values for multiple environments](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-1e39b326d43c349830a575dc3beb5c186a3687da%2FVariable-Protected-Values.png?alt=media)

![Password variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-489eb6c4fcb893dd231fdc43098a49d6741df099%2FVariable-Password.png?alt=media)

### Generated names

**First Name** and **Last Name** generate random names automatically. Select **String** when you need a fixed name.

![First Name variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-0a85bb947657ca49883922b43b99d61145953cf6%2FVariable-First-Name.png?alt=media)

![Last Name variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-fff03931c479ed5ac13ee3608098642b11f24cff%2FVariable-Last-Name.png?alt=media)

### Base URL and Header

Use **Base URL** to switch API hosts between environments. Use **Header** for reusable values such as `application/json`.

![Base URL variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-f30e3158aee0674a384042802f8f3969c7ae5dcd%2FVariable-Base-URL.png?alt=media)

![Header variable](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-8ac90a339b24e07b7c24dc73f58c0addbc19cac0%2FVariable-Header.png?alt=media)

## Set values for multiple environments

The **Variable Value For Each Environment** section displays one input for **Global Default** and each created environment.

* Enter different values beside each environment when targets require different configuration.
* Expand **Add Values For All Environments?** to enter a shared value, optionally filter environments, and select **Apply**.
* Use **Reset All** to clear values entered in the dialog before creating the variable.

## Use a global variable in a test

Global variables can be referenced in supported fields in Playground, API test suites, and workflows, including requests used for Functional or Performance executions.

### Open the variables panel from an API script

You do not need to leave the API script to find or create a variable:

1. Open the API script and locate a supported value field, such as a parameter or header value.
2. Select the **+ icon inside or beside the value field**. This opens the variables panel on the right side of the editor.
3. Select the **Global Variables** tab. You can switch to **Pre-request Variables** when you need an extracted pre-request value instead.
4. To create a variable, select **New Variable**, complete its configuration, and save it.
5. To use an existing variable, select it from the list. A checkmark identifies the selected variable.
6. Close the panel when finished.

![The plus icon highlighted in red opens the Global Variables panel](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-3351fb7acc3538bd757d3d73c639dbeb17b178ab%2FOpen-Variables-Panel-from-Script-Highlighted.png?alt=media)

In the example above, selecting the **+** icon opens **Global Variables**, where the `URL` variable can be selected or a new variable can be created.

After selection, Qyrus inserts the variable reference into the field. The following example uses `#URL#` as a query-parameter value and in the request URL.

![A global variable inserted into an API script](https://2173886669-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrWgLy70uByJZz2Zz3InN%2Fuploads%2Fgit-blob-d844a6fb856ffadb171e6f407ab89a375c25b262%2FGlobal-Variable-in-Script.png?alt=media)

Wrap the variable name with `#` characters:

```
#base_url#
#customer_id#
#response_json_path#
```

At execution time, Qyrus replaces the reference with the value configured for the selected environment. Use references in request URLs, header values, path and query parameter values, request bodies, and variable-enabled assertion and extractor fields. In editors that provide a variable picker, use it to select a variable for the field.

For example, use `#base_url#/customers` in a request URL or `#customer_id#` in a query-parameter value. Select the intended environment before sending or executing the request.

## Edit or delete variables

1. Find the variable on the **Global Variables** page.
2. Open its actions menu.
3. Select **Edit** to update its configuration and environment values, or select **Delete** to remove it.
4. Confirm the action when prompted.

Deleting a variable can break tests that still reference it. Search the project for its `#variable_name#` reference before deletion.

## Input checks and troubleshooting

* Keep variable names unique and within 60 characters. Keep environment names within 60 characters.
* For Integer and Decimal values, check the minimum and maximum bounds; for Decimal, also check the precision.
* If a request uses an unexpected value, check the selected environment, its configured value, and the spelling of the `#variable_name#` reference.
* If a reference stops resolving after a deletion, restore the required variable or update the dependent request before rerunning it.

## Related topics

* [Certificates](/api-testing/project-setup/certificate.md)
* [Pre-request APIs and Variables](/api-testing/project-setup/pre-requisite-api.md)
* [Project Settings](/api-testing/project-setup/project-set-up.md)

Continue to [Pre-request APIs and Variables](/api-testing/project-setup/pre-requisite-api.md) to extract values from setup requests.
