> 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/xdr-5-api/cortex-platform/scheduled-queries.md).

# Scheduled Queries

APIs for managing scheduled queries

## Get scheduled queries

> Return a list of scheduled queries. You can return all scheduled queries or filter results. You can also return extended results with all details included.\
> \
> You must have \*\*Instance Administrator\*\* permissions to run this endpoint.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scheduled Queries","description":"APIs for managing scheduled queries"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scheduled_queries/list":{"post":{"tags":["Scheduled Queries"],"summary":"Get scheduled queries","description":"Return a list of scheduled queries. You can return all scheduled queries or filter results. You can also return extended results with all details included.\n\nYou must have **Instance Administrator** permissions to run this endpoint.","parameters":[{"schema":{"type":"string"},"in":"header","name":"Authorization","description":"{api_key}","required":true},{"schema":{"type":"string"},"in":"header","name":"x-xdr-auth-id","description":"{api_key_id}","required":true}],"operationId":"post-public_api-v1-scheduled_queries-list","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"object","properties":{"filters":{"type":"array","description":"An array of filter fields.","items":{"type":"object","properties":{"field":{"type":"string","description":"Identifies the query field the filter is matching. Filters are based on the following keywords:\n- `query_def_id`\n- `timestamp`","enum":["query_def_id","timestamp"]},"operator":{"type":"string","enum":["EQ","NEQ"]},"value":{"type":"string"}}}},"extended_view":{"type":"boolean","description":"Display the extended view of the queries, which includes additional fields. If this is `false`, the response does not include `total_count ` or `result_count`. Extended fields may change in future versions.","default":false},"list_ids":{"type":"array","description":"List of scheduled query IDs to retrieve.","items":{"type":"string"}}}}}}}},"required":false},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"query_def_id":{"type":"string"},"query_definition_name":{"type":"string"},"xql":{"type":"string"},"timeframe":{"type":"object","properties":{"relativeTime":{"type":"string"}}},"schedule":{"type":"object","properties":{"run_date":{"type":"integer"},"trigger_type":{"type":"string"}}},"tenants":{"type":"object","nullable":true},"enable":{"type":"boolean"}}}},"filter_count":{"type":"integer"},"total_count":{"type":"integer"}}}}}},"Retrieve all scheduled queries":{},"Retrieve all scheduled queries with extended view":{}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"401":{"description":"Unauthorized access. An issue occurred during authentication. This can indicate an incorrect key, id, or other invalid authentication parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"403":{"description":"Forbidden access. The provided API Key does not have the required RBAC permissions to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}}}}}},"components":{"schemas":{"reply":{"type":"object","title":"reply","description":"The query result upon error.","properties":{"err_code":{"type":"string","description":"HTTP response code."},"err_msg":{"type":"string","description":"Error message."},"err_extra":{"type":"string","description":"Additional information describing the error."}}}}}}
```

## Insert or update scheduled queries

> Insert new scheduled queries or update existing scheduled queries. \
> \
> You must have \*\*Instance Administrator\*\* permissions to run this endpoint.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scheduled Queries","description":"APIs for managing scheduled queries"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scheduled_queries/insert":{"post":{"tags":["Scheduled Queries"],"summary":"Insert or update scheduled queries","description":"Insert new scheduled queries or update existing scheduled queries. \n\nYou must have **Instance Administrator** permissions to run this endpoint.","parameters":[{"schema":{"type":"string"},"in":"header","name":"Authorization","description":"{api_key}","required":true},{"schema":{"type":"string"},"in":"header","name":"x-xdr-auth-id","description":"{api_key_id}","required":true}],"operationId":"post-public_api-v1-scheduled_queries-insert","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"array","items":{"type":"object","required":["query_definition_name","xql","timeframe","schedule"],"properties":{"query_definition_name":{"type":"string","description":"**Note:** You should use a unique `query_definition_name` for each scheduled query on each tenant."},"xql":{"type":"string"},"timeframe":{"type":"object","properties":{"relativeTime":{"type":"integer"}}},"schedule":{"type":"object","required":["trigger_type"],"properties":{"trigger_type":{"type":"string"},"run_date":{"type":"integer"}}}}}}}}}},"required":false},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"object","properties":{"<query_id>":{"type":"object","properties":{"query_definition_name":{"type":"string"},"xql":{"type":"string"},"timeframe":{"type":"object","properties":{"relativeTime":{"type":"integer"}}},"schedule":{"type":"object","properties":{"trigger_type":{"type":"string"},"run_date":{"type":"integer"}}}},"description":"The query_id of the scheduled query that was inserted or updated."}},"description":"Upon successful insert or update, the reply returns each individual query_id with the query definitions.\r\nIf the insert or update failed, the reply will include the scheduled query name and the error message."}}}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"401":{"description":"Unauthorized access. An issue occurred during authentication. This can indicate an incorrect key, id, or other invalid authentication parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"403":{"description":"Forbidden access. The provided API Key does not have the required RBAC permissions to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}}}}}},"components":{"schemas":{"reply":{"type":"object","title":"reply","description":"The query result upon error.","properties":{"err_code":{"type":"string","description":"HTTP response code."},"err_msg":{"type":"string","description":"Error message."},"err_extra":{"type":"string","description":"Additional information describing the error."}}}}}}
```

## Delete a scheduled query

> Delete scheduled queries.\
> \
> You must have \*\*Instance Administrator\*\* permissions to run this endpoint.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scheduled Queries","description":"APIs for managing scheduled queries"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scheduled_queries/delete":{"post":{"tags":["Scheduled Queries"],"summary":"Delete a scheduled query","description":"Delete scheduled queries.\n\nYou must have **Instance Administrator** permissions to run this endpoint.","parameters":[{"schema":{"type":"string"},"in":"header","name":"Authorization","description":"{api_key}","required":true},{"schema":{"type":"string"},"in":"header","name":"x-xdr-auth-id","description":"{api_key_id}","required":true}],"operationId":"post-public_api-v1-scheduled_queries-delete","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"array","items":{"type":"string"}}}}}},"required":false},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"array","items":{"type":"object","properties":{"scheduled_query_id":{"type":"string","description":"Each JSON pair in the response is the scheduled query ID and the results of the deletion request."}}}}}}},"Example 1":{}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"401":{"description":"Unauthorized access. An issue occurred during authentication. This can indicate an incorrect key, id, or other invalid authentication parameters.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"403":{"description":"Forbidden access. The provided API Key does not have the required RBAC permissions to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/reply"}}}}}}}},"components":{"schemas":{"reply":{"type":"object","title":"reply","description":"The query result upon error.","properties":{"err_code":{"type":"string","description":"HTTP response code."},"err_msg":{"type":"string","description":"Error message."},"err_extra":{"type":"string","description":"Additional information describing the error."}}}}}}
```


---

# 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/xdr-5-api/cortex-platform/scheduled-queries.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.
