> For the complete documentation index, see [llms.txt](https://docs.avoautomation.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avoautomation.com/avo-assure/actions/generic/xml-and-json-operations/get-key-value.md).

# Get Key Value

This is pre-built Action located under the **@Generic** Element. The functionality of this Action in Avo Assure is to fetch the key value based on the input provided and store the result in a dynamic variable.

## Syntax

**Input Value**: `<JSON_input>;<path>`

{% hint style="info" %}
**Note**:&#x20;

* You can manually provide the key path or generate it automatically using the [**Data Path Builder**](/avo-assure/actions/generic/xml-and-json-operations/get-tag-value/data-path-builder.md) for the JSON input. Use the generated path as the input for the **Get Key Value** action.
* The index starts from 1 to retrieve items from the list.
  {% endhint %}

| Argument                            | Description                                                            |
| ----------------------------------- | ---------------------------------------------------------------------- |
| <p>\<JSON\_input><br>(Required)</p> | Provide the JSON input from which the value needs to be retrieved.     |
| <p>\<path><br>(Required)</p>        | Provide the path of the key to retrieve its value from the JSON input. |

**Output Value**: `<Dynamic Variable>;<Dynamic Variable>(Optional)`

| Argument                                    | Description                                                        |
| ------------------------------------------- | ------------------------------------------------------------------ |
| <p>\<Dynamic Variable></p><p>(Required)</p> | This dynamic variable stores the fetched key value from JSON body. |
| <p>\<Dynamic Variable></p><p>(Optional)</p> | This dynamic variable stores the status as True, False, or None.   |

### Example: Retrieving a Key Value from a JSON Input Using Key Path

In this example, we explain how to retrieve a specific key value from a JSON input using a nested key path with array indexing.

* **Action**: Get Key Value
* **Input Value**: \<JSON\_input>;CompanyData.Departments.Department\[2].\_deptId
  * The first argument (**\<JSON\_input>**) specifies the JSON input from which the key value is retrieved.
  * The second argument (**CompanyData.Departments.Department\[2].\_deptId**) specifies the key path used to locate the required value. The array index (**\[2]**) specifies the third object inside the Department array.

{% code overflow="wrap" expandable="true" %}

```json
// JSON Body 
{ 
  "CompanyData": { 
    "Departments": { 
      "Department": [ 
        { 
          "_deptId": "D001", 
          "name": "HR" 
        }, 
        { 
          "_deptId": "D002", 
          "name": "Finance" 
        }, 
        { 
          "_deptId": "D003", 
          "name": "QA" 
        } 
      ] 
    } 
  } 
} 
```

{% endcode %}

* **Output Value**: {DeptId};{Status}
  * The first output variable (**{DeptId}**) stores the retrieved key value as **D002**.
  * The second output variable (**{Status}**) stores the execution result with the following possible values:
    * **True**: If the key value is retrieved successfully.
    * **False**: If the key path does not exist or the JSON input is invalid.
* **Logical Explanation**: The **Get Key Value** action fetches the value from the **Input Value** column (**\<JSON\_input>;CompanyData.Departments.Department\[2].\_deptId**) and searches for the specified key path in the JSON input. The action navigates through the nested structure, accesses the third Department object using array index **\[2]**, retrieves the \_deptId value (**D002**), and stores it in the **{DeptId}** variable. The execution result is stored in the **{Status}** variable as **True**.

<figure><img src="https://2174257472-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fk8QZzXZMIJSStKAzDSTu%2Fuploads%2FR5GIgvz1FV18R93Qjsbv%2Fimage.png?alt=media&amp;token=830743c6-db11-4c34-9cbc-8efef6fd8407" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.avoautomation.com/avo-assure/actions/generic/xml-and-json-operations/get-key-value.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
