> 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-3-api/cortex-xdr-3.x-apis/dataset-management.md).

# Dataset Management

APIs for managing datasets

## Add Dataset

> Add a dataset of type \`lookup\` with the specified name and schema.> \\
>
> \
> Required license: \*\*Cortex XDR Pro per Endpoint\*\* or \*\*Cortex XDR Pro per GB\*\*

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR REST API","version":"3.18"},"tags":[{"name":"Dataset Management","description":"APIs for managing datasets"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/xql/add_dataset":{"post":{"summary":"Add Dataset","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"dataset_name":{"type":"string","description":"Name of the dataset added."}}}}}},"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"}}}}},"operationId":"post-public_api-v1-xql-add_dataset","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},{"schema":{"type":"string","default":"gzip"},"in":"header","name":"Accept-Encoding","description":"For retrieving a compressed gzipped response"}],"description":"Add a dataset of type `lookup` with the specified name and schema.\r\n\r\nRequired license: **Cortex XDR Pro per Endpoint** or **Cortex XDR Pro per GB**","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"request":{"type":"object","required":["dataset_name","dataset_type","dataset_schema"],"properties":{"dataset_name":{"type":"string","description":"The designated name of the dataset."},"dataset_type":{"enum":["lookup"],"description":"Dataset type. Currently only `lookup` is supported."},"dataset_schema":{"type":"object","description":"The schema of the dataset in a comma-separated list of JSON pairs where the key is the field name and the value is the field type.","additionalProperties":{"enum":["datetime","text","number","bool"]}}}}}}}}},"tags":["Dataset Management"]}}},"components":{"schemas":{"reply":{"title":"reply","type":"object","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 dataset

> Delete a dataset with the specified name. The following dataset types can be deleted: Lookup, Raw, User, Snapshot, and Correlation. You can only delete a dataset with dependencies by setting \`force\` to \`true\`.> \\
>
> \
> \*\*Note:\*\* The System dataset and other protected datasets cannot be deleted.&#x20;> \\
>
> \
> Required license: \*\*Cortex XDR Pro per Endpoint\*\* or \*\*Cortex XDR Pro per GB\*\*

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR REST API","version":"3.18"},"tags":[{"name":"Dataset Management","description":"APIs for managing datasets"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v2/xql/delete_dataset":{"post":{"summary":"Delete a dataset","responses":{"200":{"description":"OK"},"400":{"description":"ad 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"}}}}},"operationId":"post-public_api-v1-xql-delete_dataset","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},{"schema":{"type":"string","default":"gzip"},"in":"header","name":"Accept-Encoding","description":"For retrieving a compressed gzipped response"}],"description":"Delete a dataset with the specified name. The following dataset types can be deleted: Lookup, Raw, User, Snapshot, and Correlation. You can only delete a dataset with dependencies by setting `force` to `true`.\r\n\r\n**Note:** The System dataset and other protected datasets cannot be deleted. \r\n\r\nRequired license: **Cortex XDR Pro per Endpoint** or **Cortex XDR Pro per GB**","requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request"],"properties":{"request":{"type":"object","required":["dataset_name"],"properties":{"dataset_name":{"type":"string","description":"The name of the dataset to be deleted."},"force":{"type":"boolean","description":"**Warning:** Setting this to `true` forces deletion even when there are dependencies."}}}}}}}},"tags":["Dataset Management"]}}},"components":{"schemas":{"reply":{"title":"reply","type":"object","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."}}}}}}
```

## Get all datasets

> Retrieve a list of all the datasets and their properties.> \\
>
> \\
>
> \
> Required license: \*\*Cortex XDR Pro per Endpoint\*\* or \*\*Cortex XDR Pro per GB\*\*

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR REST API","version":"3.18"},"tags":[{"name":"Dataset Management","description":"APIs for managing datasets"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/xql/get_datasets":{"post":{"summary":"Get all datasets","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"array","items":{"type":"object","properties":{"dataset_name":{"type":"string","description":"Dataset name."},"type":{"type":"string","description":"Dataset type. Can be one of the following: `System`, `Lookup`, `Raw`, `User`, `Snapshot`, `Correlation`, `System Audit`."},"log_update_type":{"type":"string","description":"Log update type. Can be one of the following: `Logs` (event logs are updated continuously), `State` (the current state is updated periodically)."},"last_updated":{"type":"integer","description":"Integer in timestamp epoch milliseconds. When the data in the dataset was last updated."},"total_days_stored":{"type":"integer","description":"Number of dats the data is stored in the tenant, which is comprised of `hot_range` + `cold_range`."},"hot_range":{"type":"object","description":"The time period of the hot storage from the start date to the end date.","properties":{"from":{"type":"integer","description":"    Integer in timestamp epoch milliseconds."},"to":{"type":"integer","description":"Integer in timestamp epoch milliseconds."}}},"cold_range":{"type":"object","description":"The time period of the cold storage from the start date to the end date.","properties":{"from":{"type":"integer","description":"Integer in timestamp epoch milliseconds."},"to":{"type":"integer","description":"Integer in timestamp epoch milliseconds."}}},"total_size_stored":{"type":"integer","description":"Actual size of the data (in bytes) that is stored in the tenant. This number is dependent on the events stored in the hot storage. For the xdr_data dataset, where the first 31 days of storage are included with your license, the first 31 days are not included in the `total_size_stored` number."},"average_daily_size":{"type":"integer","description":"Average daily amount stored (in bytes) in the tenant. This number is dependent on the events stored in the hot storage."},"total_events":{"type":"integer","description":"Number of total events/logs that are stored in the tenant. This number is dependent on the events stored in the hot storage."},"average_event_size":{"type":"integer","description":"Average size (in bytes) of a single event in the dataset (`total_size_stored` divided by the `total_events`). This number is dependent on the events stored in the hot storage."},"ttl":{"type":"integer","description":"Time to live. Defines when lookup entries expire and are removed automatically from the lookup dataset."},"default_query_target":{"type":"boolean","description":"whether the dataset is configured to use as your default query target in XQL Search, so when you write your queries you do not need to define a dataset. Can be one of the following: `True`, `False`."}}}}}}}}},"400":{"description":"ad 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"}}}}},"operationId":"post-public_api-v1-xql-get_datasets","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},{"schema":{"type":"string","default":"gzip"},"in":"header","name":"Accept-Encoding","description":"For retrieving a compressed gzipped response"}],"description":"Retrieve a list of all the datasets and their properties.\r\n\r\n\r\nRequired license: **Cortex XDR Pro per Endpoint** or **Cortex XDR Pro per GB**","tags":["Dataset Management"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"request":{"type":"object"}}}}}}}}},"components":{"schemas":{"reply":{"title":"reply","type":"object","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-3-api/cortex-xdr-3.x-apis/dataset-management.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.
