# Set Key Value

This is pre-built Action located under the @Generic Element Name. It instructs the Avo Assure Client to set the value of the specified key from the input and save the result in the given output variable.

Syntax:&#x20;

Input: \<input\_json>;\<block\_key\_name>;\<block\_count>;\<key\_name>;\<key\_value>

Output: \<Dynamic Variable>;\<Dynamic Variable>(Optional)&#x20;

&#x20;

<figure><img src="/files/vC0WuYq7MDo3eMNecbcM" alt=""><figcaption></figcaption></figure>

&#x20;

Usecase/Example:&#x20;

<figure><img src="/files/AKWWSI58rgkdOoyY6BK9" alt=""><figcaption></figcaption></figure>

&#x20;

Scenario: Updating User Preferences in a Web Application

In a web application, users can customize their settings, such as notification preferences and theme choices. When users make changes to their preferences, the application must send a request to the backend API to save these updates. This scenario tests the functionality of setting key values in the

payload to ensure that the application accurately reflects the user's desired settings when making the API call.

&#x20;

Testing Example:

&#x20;

Input:

API Endpoint: \`POST /api/users/preferences\`&#x20;

Initial Payload:&#x20;

&#x20; json

&#x20; {

&#x20;   "userId": "56789",

&#x20;   "notifications": {

&#x20;     "email": true,

&#x20;     "sms": false

&#x20;   },

&#x20;   "theme": "light"

&#x20; }

&#x20; \`\`\`

&#x20;

Using the Action:

Use the action \`set key value\` to update the following:

&#x20; Set \`notifications.sms\` to \`true\` (enabling SMS notifications).

&#x20; Set \`theme\` to \`"dark"\` (changing the user interface theme).

&#x20;

Expected Result:

\- Updated Payload after actions:&#x20;

&#x20; \`\`\`json

&#x20; {

&#x20;   "userId": "56789",

&#x20;   "notifications": {

&#x20;     "email": true,

&#x20;     "sms": true

&#x20;   },

&#x20;   "theme": "dark"

&#x20; }

&#x20;

Validation: The API response confirms that the user preferences were updated successfully, demonstrating that the "Set Key Value" functionality works as intended.

Output: The resulting beautified content is stored in the {result} output variable, which can be utilized for display or other purposes.


---

# 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.avoautomation.com/avo-assure/actions/generic/xml-and-json-operations/set-key-value.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.
