> 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/cortex-xsiam-developer-guide/cortex-xsiam-development-guide/integrations-and-scripts/advanced-topics/transform-language-dt.md). Agents can also search and read this documentation through its [MCP server](https://cortex-docs.paloaltonetworks.com/~gitbook/mcp).

# Transform Language (DT)

Use DT for various context related functions in Cortex XSIAM. DT is a query language for JSON objects, similar to JSONQuery.

Cortex XSIAM Transform Language (DT) supports context-related functions. DT queries JSON objects, similarly to JSONQuery.

### Transform Language context example

This sample context data demonstrates how DT accesses, aggregates, and mutates data.

```json
{
    "URL": {
        "Data": "google.com"
    },
    "IP": {
        "Hostname": "google-public-dns-a.google.com",
        "RecordedFuture": {
            "FirstSeen": "2010-04-27T12:46:51.000Z",
            "Criticality": "None",
            "LastSeen": "2019-02-06T11:13:38.139Z"
        },
        "Address": "8.8.8.8",
        "Geo": {
            "Country": "United States",
            "Location": "37.751, -97.822"
        },
        "ASN": 15169
    },
    "DBotScore": [{
        "Vendor": "urlscan.io",
        "Indicator": "google.com",
        "Score": 0,
        "Type": "url"
    }, {
        "Vendor": "ipinfo",
        "Indicator": "8.8.8.8",
        "Score": 0,
        "Type": "ip"
    }, {
        "Vendor": "Recorded Future",
        "Indicator": "8.8.8.8",
        "Score": 0,
        "Type": "ip"
    }, {
        "Vendor": "VirusTotal",
        "Indicator": "8.8.8.8",
        "Score": 1,
        "Type": "ip"
    }],
    "URLScan": {
        "URL": "google.com",
        "Country": ["IE"],
        "Certificates": [{
            "SubjectName": "<span>www.google</span>.com",
            "ValidFrom": "2018-12-19 08:16:00",
            "ValidTo": "2019-03-13 08:16:00",
            "Issuer": "Google Internet Authority G3"
        }, {
            "SubjectName": "*.google.com",
            "ValidFrom": "2018-12-19 08:17:39",
            "ValidTo": "2019-03-13 08:17:00",
            "Issuer": "Google Internet Authority G3"
        }, {
            "SubjectName": "<span>www.google</span>.de",
            "ValidFrom": "2018-12-19 08:16:00",
            "ValidTo": "2019-03-13 08:16:00",
            "Issuer": "Google Internet Authority G3"
        }, {
            "SubjectName": "*.g.doubleclick.net",
            "ValidFrom": "2018-12-19 08:17:00",
            "ValidTo": "2019-03-13 08:17:00",
            "Issuer": "Google Internet Authority G3"
        }, {
            "SubjectName": "*.apis.google.com",
            "ValidFrom": "2018-12-19 08:16:00",
            "ValidTo": "2019-03-13 08:16:00",
            "Issuer": "Google Internet Authority G3"
        }],
        "ASN": "AS15169"
    },
    "MaxMind": {
        "Address": "8.8.8.8",
        "ISP": "Google",
        "UserType": "business",
        "Organization": "Google LLC",
        "ISO_Code": "US",
        "Geo": {
            "Location": "37.751, -97.822",
            "Country": "United States",
            "Continent": "North America",
            "Accuracy": 1000
        },
        "ASN": 15169,
        "RegisteredCountry": "United States"
    }
}
```

### Access nested context values with DT

DT accesses keys in dictionaries, including nested dictionaries.

Using the sample context data, you can access:

* The `Continent` value in the `Geo` dictionary under `MaxMind`.
* The `Hostname` value in the `IP` dictionary.
* The `FirstSeen` value in the `RecordedFuture` dictionary under `IP`.

Use these DT statements to access the values:

| Example                          | Result                         |
| -------------------------------- | ------------------------------ |
| `${MaxMind.Geo.Continent}`       | North America                  |
| `${IP.Hostname}`                 | google-public-dns-a.google.com |
| `${IP.RecordedFuture.FirstSeen}` | 2010-04-27T12:46:51.000Z       |

### Access context arrays with DT

Access array values with dot notation and an index, as you would other JSON keys.

{% hint style="info" %}
Indices start with 0, not 1.
{% endhint %}

Using the sample context data:

`URLScan` contains a `Certificates` array. To access the first entry's `SubjectName`, use this DT statement:

| Example                                     | Result                                                                                             |
| ------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| `${URLScan.Certificates.SubjectName}`       | \[`"www.google.com", "*.google.com", "www.google.de", "*.g.doubleclick.net", "*.apis.google.com"]` |
| `${URLScan.Certificates.[0].SubjectName}`   | `www.google.com`                                                                                   |
| `${URLScan.Certificates.[0:2].SubjectName}` | \[`"www.google.com", "*.google.com", "www.google.de"]`                                             |

To retrieve a result range, use `[0:9]`, where `0` is the first array position and `9` is the ninth.

### Filter context data with DT selectors

DT supports conditions within statements. Use JavaScript selectors to filter context items and bind results in a DT string.

The `val` JavaScript method exposes the value at the current context path.

These examples use selector methods:

| Example                                                                                           | Result                                                                               | Description                                                                                                                                                                                                            |
| ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `${DBotScore.Vendor(val == 'urlscan.io')}`                                                        | `urlscan.io`                                                                         | Returns only vendors that exactly match the urlscan.io description.                                                                                                                                                    |
| `${URLScan.Certificates.SubjectName( val.indexOf('www') == 0)}`                                   | `[<span>www.google</span>.com, <span>www.google</span>.de]`                          | Returns any SubjectName that starts with "www".                                                                                                                                                                        |
| `${URLScan.Certificates.SubjectName( val.indexOf('doubleclick') >= 0)}`                           | `*.g.doubleclick.net`                                                                | Returns any SubjectName that contains doubleclick.                                                                                                                                                                     |
| `${URLScan.Country( val.toUpperCase().indexOf('IE') >= 0)}`                                       | `IE`                                                                                 | Returns any country that contains IE or ie or any mixed case.                                                                                                                                                          |
| `${URLScan.Certificates(val.SubjectName.indexOf('de') == val.length-2).ValidTo}`                  | `2019-03-13 08:16:00`                                                                | Returns all ValidTo for certificates that have SubjectName ending with de. Notice that we tested a relative path to “SubjectName” (“de”) and returned a different path (“ValidTo”).                                    |
| `${URLScan.Certificates(val.ValidFrom == val1---URLScan.Certificates.[0].ValidFrom).SubjectName}` | `["<span>www.google</span>.com", "<span>www.google</span>.de", "*.apis.google.com"]` | Returns all SubjectNames for certificates that have the same ValidTo time as the first certificate in the array. Note that the bind value (val1) does not start with ‘.’ and will DT the context from the top context. |

Selectors help avoid duplicate entries and add data to existing entries.

For example:

```python
ec = {
    "Data": "www.demisto.com",
    "Malicious": {
        "Vendor": "Palo Alto Networks",
        "Description": "This indicator found to be malicious by Palo Alto Networks"
    }
}


demisto.results({
 Type: entryTypes.note,
 Contents: 'related',
 ContentsFormat: formats.json,
 HumanReadable: 'md',
 EntryContext: {'URL(val.Data && val.Data == obj.Data)': ec 
})
```

The `'URL(val.Data &amp;&amp; val.Data == obj.Data)'` expression finds context entries with matching `Data` values. When it finds a match, it updates the existing context. Otherwise, it creates a new context entry.

### Transform context data with DT mutators

Because DT is JavaScript-based, it can transform results into another format. For example, combine a server address from one integration with an endpoint from another to create a URL for later use.

These examples use DT mutators:

| Example                                                                                                                         | Result                                                    | Description                                                                                                    |
| ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| `${URLScan.Certificates(val.SubjectName.indexOf("doubleclick") > -1).ValidFrom=foo(val);function foo(aa) { return aa + "Z"; }}` | `2018-12-19 08:17:00Z`                                    | Returns the timestamp where the SubjectName contains the word "doubleclick". Then it appends "Z" to the value. |
| `${MaxMind.Organization=val.toLowerCase()}`                                                                                     | `google llc`                                              | Returns all the organizations but in lower case.                                                               |
| `${DBotScore.Vendor(val.indexOf('Recorded')>=0)=val.toLowerCase()}`                                                             | `"Recorded Future"`                                       | Returns all the vendors containing “Recorded” but in lower case.                                               |
| `${DBotScore.type=val.ip +': ' + val.Vendor}`                                                                                   | `["ip: ipinfo", "ip: Recorded Future", "ip: VirusTotal"]` | Returns the concatenated ip and vendor for all DBotScores.                                                     |


---

# 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://cortex-docs.paloaltonetworks.com/cortex-xsiam-developer-guide/cortex-xsiam-development-guide/integrations-and-scripts/advanced-topics/transform-language-dt.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.
