> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/xsoar-6-administrator-guide/6.14/customize-cortex-xsoar/customize-and-configure-cortex-xsoar/playbooks/extend-context/extend-context-using-the-command-line.md).

# Extend Context using the Command Line

You can extend context either in a playbook task, or directly from the command line. Whichever method you use, Cortex XSOAR recommends that you first run your command with the **`raw-response=true`** flag. This will help you identify the information that you want to add to your extended data.

1. Run your command with the extend-context flag **`!`*****`<commandName>`*** ***`<argumentName> <value>`*****`extend-context=contextKey=JsonOutputPath`**.

   For example, to add the user and manager fields to context use the ad-get-user command, as follows:

   **`!ad-get-user username=${user.manager.username} extend-context=manager=attributes.manager::attributes=displayName`**
2. To output only the values that you set as Extend context, run the command with the ignore-output flag=true. **`!ad-get-user username=${user.manager.username} extend-context=manager=attributes.manager::attributes=displayName ignore-output=true`**

**Example**

By default, after adding the IBM Qradar v3 integration instance, offenses pulled from QRadar to Cortex XSOAR return a number of fields, including event count, offense type, description, etc. You can use extended context to show which additional information is available and also use that information to map it to a field.

* Run the command **`!qradar-offenses raw-response="true"`**. From the context data, you see that there are a number of additional fields that are retrieved.
* Identify the fields that you want to add and run your command. For example, to retrieve the number of devices affected by a given offense, as well as the domain in which those devices reside, run the following command: **`!qradar-offenses extend-context=device-count=device_count::domain-id=domain_id`**

The following image shows how to create an extended context key from the CLI in the playground.

![playbook-extend-context-cli.png](/files/eAzzYieqwGDuHihdEKUZ)


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/xsoar-6-administrator-guide/6.14/customize-cortex-xsoar/customize-and-configure-cortex-xsoar/playbooks/extend-context/extend-context-using-the-command-line.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
