# User-Defined Variables

The Variables section is a key-value storage for storing and reusing some data. It is often used for removing code duplicates and improving readability: the greetingUrl variable says more than just the line <https://next.json-generator.com/api/json/get/EJvQVEVGL> for sure.

The variables mechanism is very well integrated to all application parts and has several features:

* You can use strings, objects, arrays, and links to other variables as values.
* Variables are defined for each node and are inherited from parent nodes.
* Variables values can refer to other variables.
* [Default variables](https://docs.testmace.com/variables/variables) names start with $.

### Using Variables

You can use variables in any string parameters of the node - URLs, headers names, authorization tokens, etc. To do that, use the `${variableName}` syntax, where `variableName` is a link to the variable. Here are some examples:

* `${id}`
* `${$dynamicVar.id}`
* `${$response.body.name}`

It's possible to combine strings and links to other variables in the node parameters fields. For instance, you can use  `http://${host}/posts/${$dynamicVar.id}` as an URL.&#x20;

To access an array element, that is stored in a variable, you can use the `${variableName[index]}` syntax. For example, to access the third response entity id, you'll write `${$response.body[2].id}`. Note that it the index is zero-based.

Autocompletion works for variables:

![](https://gblobscdn.gitbook.com/assets%2F-Lh_FaVh9XfQJ0p1KqZ1%2F-MEY9ibfnYvDKaURxlxy%2F-MEY9mDK7gTKvDfOGiWm%2Fvariables1.gif?alt=media\&token=3a1d85be-cefd-4daf-ae05-57107f4c3b4b)

Variable value highlighting works as well:

![](https://gblobscdn.gitbook.com/assets%2F-Lh_FaVh9XfQJ0p1KqZ1%2F-MEY9ibfnYvDKaURxlxy%2F-MEYAHlXOuh-KHuhndW9%2FScreenshot%202020-08-12%20at%2018.57.17.png?alt=media\&token=1a488086-2e8c-4597-999f-513c474ccfb0)

There is the Variables tab in every node interface, that contains the variables list. This is how the tab looks like:

![](https://gblobscdn.gitbook.com/assets%2F-Lh_FaVh9XfQJ0p1KqZ1%2F-MEY9ibfnYvDKaURxlxy%2F-MEYAgxCEmpEv54HZrYP%2FScreenshot%202020-08-12%20at%2018.58.23.png?alt=media\&token=0bacf5d4-f58c-4055-8033-bdcef09631f7)

The tab looks the same for all node types. You'll learn more about how to work with variables in the next sections.


---

# 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.testmace.com/variables/user-variables.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.
