# What is a Variable?

* A variable is a container or a placeholder for a data value with a specified type.
* Variables may contain values that can be used in Actions.
* A variable has a lifetime which is referred to as scope. The scope defines the accessibility of the variable to a specific Container Action, Action box, or all Action boxes.
* A variable can be defined in shared Variables, an Action box, or a Container Action (where possible). Shared Variables are defined in the “Variables” tab.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img1.png>" %}

* Shared Variables scope covers the execution of all Action boxes.
* The scope of variables defined in an Action box includes all the Actions in the Action box.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img2.png>" %}

* The scope of the variables defined in the Container Actions includes all contained Actions for duration of the execution of the Container actions.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img3.png>" %}

* A variable can be Read Only. If specified as "Read Only," it takes the value initialized the first time and cannot be assigned any other value later.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img4.png>" %}

* A variable can be List type and can contain multiple values of the list type. These values can be accessed by their index number starting from 0 (zero). To define a variable as a list, set the checkbox \[X] List as in the image below.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img5.png>" %}

* Variables with a complex type may require other settings e.g. setting the Sample schema for the Json type.

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img6.png>" %}

**Sample Schema for JsON**:

{% embed url="<https://media.langstack.com/documentation/media/images/code/training_manual/chapter_2/ch2whatisavariable_img7.png>" %}


---

# 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.langstack.com/welcome/get-started/learn-langstack/basics-and-essentials/what-is-a-variable.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.
