> 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/agentix-api/run-xql-query-apis.md).

# Run XQL query APIs

Cortex AgentiX enables you to run XQL queries on your data sources using a series of APIs. To execute XQL APIs you must have:

* Valid API Key and API Key ID that include the Instance Administrator role permissions.
* Available query quota.

Query quota is made up of query units that enable you to run XQL APIs. Each XQL API query entails a cost of query units calculated according to the complexity and number of search results. The query cost for each API query is displayed in the [Get Query Results](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_query_results) API. You can also track the query cost per XQL API search, overall usage, and remaining quota in Cortex AgentiX or by running a [Get XQL Query Quota](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_quota) API. Cortex AgentiX provides a free daily quota relative to your license size for you to run XQL API queries.

> **Note**: You will be able to purchase additional query units in future Cortex AgentiX versions.

To execute a XQL API, you need to run a series of APIs. Each API requires a response value from the previous API to continue. This allows you to track the number of XQL queries you want to run, which in turn helps you manage your daily quota. Queries called without enough quota will fail. To ensure you don't surpass your quota, Cortex AgentiX allows you to run up to four API queries in parallel.

Run the following APIs to call an XQL query:

1. [**Start an XQL Query**](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-start_xql_query)—Run an XQL query. Response returns a unique execution ID used to retrieve the results by the [Get XQL Query Results](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_query_results) API.
2. [**Get XQL Query Results**](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_query_results)—Retrieve XQL query results. API displays up to 1,000 results. If query generated more than 1,000 results, the response returns a unique stream ID used to retrieve additional results by the [Get XQL Query Results Stream](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_query_results_stream) API.
3. [**Get XQL Query Results Stream**](broken://pages/f6a6f1a2dd8bf17910d56d82a1283e5540a78417#post-public_api-v1-xql-get_query_results_stream)—Retrieve XQL query with more than 1,000 results.


---

# 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/agentix-api/run-xql-query-apis.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.
