> 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/scripts.md).

# Scripts

APIs for managing scripts

## Get a script

> &#x20;Get a script by filtering based on its name or ID. The script's YAML is returned in a ZIP file.\
> \
> &#x20;Requires the granular RBAC permission for this feature.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scripts","description":"APIs for managing scripts"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scripts/get":{"post":{"summary":"Get a script","tags":["Scripts"],"responses":{"200":{"description":"OK","content":{"application/zip":{"schema":{"type":"object"}}}}},"operationId":"post-public_api-v1-scripts-get","description":" Get a script by filtering based on its name or ID. The script's YAML is returned in a ZIP file.\n\n Requires the granular RBAC permission for this feature.","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}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"object","properties":{"filter":{"type":"object","description":"Filter fields.","properties":{"field":{"enum":["id","name"],"description":"Identifies the script field the filter is matching. Filters are based on the following keywords:\r\n- `name`: Script name\r\n- `id`: Script ID"},"value":{"type":"string","description":"Value that this filter must match."}}}}}}}}}}}}}}
```

## Insert or update a script

> Update or add a script by passing the YAML in a ZIP file.\
> \
> Requires the granular RBAC permission for this feature.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scripts","description":"APIs for managing scripts"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scripts/insert":{"post":{"summary":"Insert or update a script","tags":["Scripts"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"objects_count":{"type":"integer","description":"The number of scripts identified and attempted to be added."},"objects":{"type":"object","properties":{"failures_items":{"type":"array","description":"This field in the response indicates that the script IDs listed failed to be added.","items":{"type":"object","properties":{"error":{"type":"string","description":"Error message."},"id":{"type":"string","description":"Script ID of the script that failed to be added."}}}}}}}}}}}},"operationId":"post-public_api-v1-scripts-insert","description":"Update or add a script by passing the YAML in a ZIP file.\n\nRequires the granular RBAC permission for this feature.","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}],"requestBody":{"content":{"multipart/form-data":{"schema":{"type":"object","properties":{"file":{"type":"string","format":"binary","description":"The script in YAML in a zipped file."}}}}}}}}}}
```

## Delete a script

> Delete a script by filtering based on its name or ID.\
> \
> Requires the granular RBAC permission for this feature.

```json
{"openapi":"3.0.0","info":{"title":"Cortex XDR Platform APIs","version":"Cortex XDR 5.2"},"tags":[{"name":"Scripts","description":"APIs for managing scripts"}],"servers":[{"url":"https://api-yourfqdn"}],"paths":{"/public_api/v1/scripts/delete":{"post":{"summary":"Delete a script","tags":["Scripts"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"objects_count":{"type":"integer","description":"The number of scripts identified and attempted to be deleted."},"objects":{"type":"object","properties":{"failures_items":{"type":"array","description":"This field in the response indicates that the script IDs listed failed to be deleted.","items":{"type":"object","properties":{"error":{"type":"string","description":"Error message."},"id":{"type":"string","description":"Script ID of the script that failed to be deleted."}}}},"succeeded_items":{"type":"array","description":"This field in the response indicates that the script IDs listed were successfully deleted.","items":{"type":"object","properties":{"id":{"type":"string","description":"Script ID of the script that was successfully deleted."}}}}}}}}}}}},"operationId":"post-public_api-v1-scripts-delete","description":"Delete a script by filtering based on its name or ID.\n\nRequires the granular RBAC permission for this feature.","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}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"object","properties":{"filter":{"type":"object","description":"Filter fields.","properties":{"field":{"enum":["id","name"],"description":"Identifies the playbook field the filter is matching. Filters are based on the following keywords:\r\n- `name`: Playbook name\r\n- `id`: Playbook ID"},"value":{"type":"string","description":"Value that this filter must match."}}}}}}}}}}}}}}
```


---

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