> 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/xpanse-api/xpanse-public-api/tag-management.md).

# Tag Management

APIs for managing tags

## Add Tags to Assets

> Add tags in bulk to a set of assets.

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/tags/assets_internet_exposure/assign/":{"post":{"parameters":[{"in":"header","name":"authorization","description":"api-key","schema":{"type":"string"},"required":true},{"in":"header","name":"x-xdr-auth-id","description":"api-key-id","schema":{"type":"string"},"required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignTagsToAsmEntitiesResponse"}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"$ref":"#/components/responses/UNPROCESSABLE_ENTITY"},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequest"}}},"description":""},"summary":"Add Tags to Assets","tags":["Tag Management"],"description":"Add tags in bulk to a set of assets."}}},"components":{"schemas":{"AssignTagsToAsmEntitiesResponse":{"type":"object","properties":{"reply":{"$ref":"#/components/schemas/AssignTagsToAsmEntitiesReply"}},"required":["reply"],"additionalProperties":true},"AssignTagsToAsmEntitiesReply":{"type":"object","properties":{"assign_tags":{"type":"string","description":"succeeded if request was successful"}},"required":["assign_tags"],"additionalProperties":true},"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}},"AssignOrRemoveTagsFromAsmAssetsRequest":{"type":"object","properties":{"request_data":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequestData"}},"required":["request_data"],"additionalProperties":true},"AssignOrRemoveTagsFromAsmAssetsRequestData":{"type":"object","description":"A dictionary containing the API request fields. An empty dictionary returns all results.","properties":{"filters":{"type":"array","items":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequestFilter"}},"tags":{"type":"array","description":"List of tag names to add or remove. These do not need to include the tag family.","items":{"type":"string"}}}},"AssignOrRemoveTagsFromAsmAssetsRequestFilter":{"type":"object","required":["field","operator","value"],"properties":{"field":{"type":"string","enum":["name","has_xdr_agent","ip_address","externally_detected_providers","type","has_active_external_services","mac_addresses","externally_inferred_cves","aws_cloud_tags","gcp_cloud_tags","azure_cloud_tags","tags","business_units_list","ipv6_address","has_bu_overrides","asm_id_list"],"description":"Identifies the asset field the filter matches. Case-sensitive."},"operator":{"type":"string","enum":["in","contains","neq","eq","not_contains"],"description":"Comparison operator for the filter. Valid operators depend on the field:\n  - **contains** / **not_contains**: use with externally_detected_providers, externally_inferred_cves, name\n  - **eq** / **neq**: use with name, ip_address, has_bu_overrides\n  - **in**: use with asm_id_list, has_active_external_services, type, business_units_list, ip_address\n"},"value":{"oneOf":[{"type":"string"},{"type":"boolean"},{"type":"array","items":{"type":"string"}}],"description":"Value depends on the filter field used.\n  - **asm_id_list**: list of asset ID strings\n  - **business_units_list**: string or list of strings in the format \"BU name\" or \"BU:BU name\"\n  - **externally_detected_providers**: string\n  - **externally_inferred_cves**: string\n  - **has_active_external_services**: list of strings (enum values: \"yes\", \"no\", \"unknown\")\n  - **has_bu_overrides**: boolean (\"true\" or \"false\")\n  - **has_xdr_agent**: string (enum values: \"yes\", \"no\")\n  - **ip_address**: list of strings\n  - **ipv6_address**: string\n  - **mac_addresses**: string\n  - **name**: string\n  - **tags**: list of strings in the format \"tag-family:tag-name\"\n  - **type**: list of strings (enum values: \"certificate\", \"cloud_compute_instance\", \"domain\", \"unassociated_responsive_ip\")\n"}}}},"responses":{"UNPROCESSABLE_ENTITY":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## Add Tags to IP Address Ranges

> Add tags in bulk to owned IP ranges.

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/tags/external_ip_address_ranges/assign/":{"post":{"parameters":[{"in":"header","name":"authorization","description":"api-key","schema":{"type":"string"},"required":true},{"in":"header","name":"x-xdr-auth-id","description":"api-key-id","schema":{"type":"string"},"required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignTagsToAsmEntitiesResponse"}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"$ref":"#/components/responses/UNPROCESSABLE_ENTITY"},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequest"}}},"description":""},"summary":"Add Tags to IP Address Ranges","tags":["Tag Management"],"description":"Add tags in bulk to owned IP ranges."}}},"components":{"schemas":{"AssignTagsToAsmEntitiesResponse":{"type":"object","properties":{"reply":{"$ref":"#/components/schemas/AssignTagsToAsmEntitiesReply"}},"required":["reply"],"additionalProperties":true},"AssignTagsToAsmEntitiesReply":{"type":"object","properties":{"assign_tags":{"type":"string","description":"succeeded if request was successful"}},"required":["assign_tags"],"additionalProperties":true},"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}},"AssignOrRemoveTagsFromIpRangesRequest":{"type":"object","properties":{"request_data":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequestData"}},"required":["request_data"],"additionalProperties":true},"AssignOrRemoveTagsFromIpRangesRequestData":{"type":"object","properties":{"filters":{"type":"array","items":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequestFilter"},"description":"An array of filter fields."},"tags":{"type":"array","items":{"type":"string"},"description":"Name of the tag to add to the ranges. The tag name does not need to include the tag family."}},"additionalProperties":true,"description":"A dictionary containing the API request fields. An empty dictionary returns all results."},"AssignOrRemoveTagsFromIpRangesRequestFilter":{"type":"object","properties":{"field":{"type":"string","enum":["organization_handles","tags","business_units_list","ipaddress_version","has_bu_overrides","range_id_list"],"description":"range_id_list: indicates that the set of IP ranges will be a list of IDs."},"operator":{"type":"string","enum":["in","contains","neq","eq","not_contains"],"description":"in"},"value":{"oneOf":[{"type":"string"},{"type":"integer"},{"type":"array","items":{"type":"string"}},{"type":"array","items":{"type":"integer"}}],"description":"List of strings, the ip range IDs that should be removed from the tag."}},"required":["field","operator","value"],"additionalProperties":true}},"responses":{"UNPROCESSABLE_ENTITY":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## Create Asset Tag Rules

> Create tag rules that apply tags automatically to assets that match your rule criteria, including any new assets that are attributed to your organization. Tag rules can be defined for IPv4 addresses and IPv4 ranges. These fields can be the same to denote a single IP address. If the list of IP addresses exceeds 100, Expander will create multiple tag rules, each with at most 100 IP addresses per rule. \<br />Required License: Cortex Xpanse Expander<br>

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/create_asset_tag_rules/":{"post":{"parameters":[{"in":"header","name":"authorization","description":"api-key","schema":{"type":"string"},"required":true},{"in":"header","name":"x-xdr-auth-id","description":"api-key-id","schema":{"type":"string"},"required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTagRulesForIpRangesResponse"}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"$ref":"#/components/responses/UNPROCESSABLE_ENTITY"},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTagRulesForIpRangesRequest"}}}},"summary":"Create Asset Tag Rules","description":"Create tag rules that apply tags automatically to assets that match your rule criteria, including any new assets that are attributed to your organization. Tag rules can be defined for IPv4 addresses and IPv4 ranges. These fields can be the same to denote a single IP address. If the list of IP addresses exceeds 100, Expander will create multiple tag rules, each with at most 100 IP addresses per rule. <br />Required License: Cortex Xpanse Expander\n","tags":["Tag Management"]}}},"components":{"schemas":{"CreateTagRulesForIpRangesResponse":{"type":"object","properties":{"reply":{"type":"string"}},"required":["reply"],"additionalProperties":true},"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}},"CreateTagRulesForIpRangesRequest":{"type":"object","properties":{"request_data":{"$ref":"#/components/schemas/CreateTagRulesForIpRangesRequestData"}},"required":["request_data"],"additionalProperties":true},"CreateTagRulesForIpRangesRequestData":{"type":"object","properties":{"ip_ranges":{"type":"array","items":{"$ref":"#/components/schemas/IpRange"},"description":"List of dictionaries containing \"from_ip\" and \"to_ip\" to define an IP range. These fields can be the same to denote a single IP address.<br /> For example,<br />`\"from_ip\": \"1.1.1.1\", \"to_ip\": \"1.1.1.3\"`.'\n"},"rule_name":{"type":"string","description":"Name of the tag rule. Will use `tag_name` if left empty."},"description":{"type":"string","description":"(Optional) Description of the tag rule."},"tag_name":{"type":"string","description":"Name of the tag to be used to tag assets. If a rules-based tag with the same name already exists, it will use that tag. If not, a new rules-based tag will be created."}},"required":["ip_ranges"],"additionalProperties":true,"description":"A dictionary containing the API request fields."},"IpRange":{"type":"object","properties":{"from_ip":{"type":"string"},"to_ip":{"type":"string"}},"additionalProperties":true}},"responses":{"UNPROCESSABLE_ENTITY":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## Remove Tags from Assets

> Remove tags in bulk from a set of assets.

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/tags/assets_internet_exposure/remove/":{"post":{"parameters":[{"in":"header","name":"authorization","description":"api-key","schema":{"type":"string"},"required":true},{"in":"header","name":"x-xdr-auth-id","description":"api-key-id","schema":{"type":"string"},"required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveTagsFromAsmEntitiesResponse"}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"$ref":"#/components/responses/UNPROCESSABLE_ENTITY"},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequest"}}},"description":""},"summary":"Remove Tags from Assets","tags":["Tag Management"],"description":"Remove tags in bulk from a set of assets."}}},"components":{"schemas":{"RemoveTagsFromAsmEntitiesResponse":{"type":"object","properties":{"reply":{"$ref":"#/components/schemas/RemoveTagsFromAsmEntitiesReply"}},"required":["reply"],"additionalProperties":true},"RemoveTagsFromAsmEntitiesReply":{"type":"object","properties":{"remove_tags":{"type":"string","description":"succeeded if request was successful"}},"required":["remove_tags"],"additionalProperties":true},"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}},"AssignOrRemoveTagsFromAsmAssetsRequest":{"type":"object","properties":{"request_data":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequestData"}},"required":["request_data"],"additionalProperties":true},"AssignOrRemoveTagsFromAsmAssetsRequestData":{"type":"object","description":"A dictionary containing the API request fields. An empty dictionary returns all results.","properties":{"filters":{"type":"array","items":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromAsmAssetsRequestFilter"}},"tags":{"type":"array","description":"List of tag names to add or remove. These do not need to include the tag family.","items":{"type":"string"}}}},"AssignOrRemoveTagsFromAsmAssetsRequestFilter":{"type":"object","required":["field","operator","value"],"properties":{"field":{"type":"string","enum":["name","has_xdr_agent","ip_address","externally_detected_providers","type","has_active_external_services","mac_addresses","externally_inferred_cves","aws_cloud_tags","gcp_cloud_tags","azure_cloud_tags","tags","business_units_list","ipv6_address","has_bu_overrides","asm_id_list"],"description":"Identifies the asset field the filter matches. Case-sensitive."},"operator":{"type":"string","enum":["in","contains","neq","eq","not_contains"],"description":"Comparison operator for the filter. Valid operators depend on the field:\n  - **contains** / **not_contains**: use with externally_detected_providers, externally_inferred_cves, name\n  - **eq** / **neq**: use with name, ip_address, has_bu_overrides\n  - **in**: use with asm_id_list, has_active_external_services, type, business_units_list, ip_address\n"},"value":{"oneOf":[{"type":"string"},{"type":"boolean"},{"type":"array","items":{"type":"string"}}],"description":"Value depends on the filter field used.\n  - **asm_id_list**: list of asset ID strings\n  - **business_units_list**: string or list of strings in the format \"BU name\" or \"BU:BU name\"\n  - **externally_detected_providers**: string\n  - **externally_inferred_cves**: string\n  - **has_active_external_services**: list of strings (enum values: \"yes\", \"no\", \"unknown\")\n  - **has_bu_overrides**: boolean (\"true\" or \"false\")\n  - **has_xdr_agent**: string (enum values: \"yes\", \"no\")\n  - **ip_address**: list of strings\n  - **ipv6_address**: string\n  - **mac_addresses**: string\n  - **name**: string\n  - **tags**: list of strings in the format \"tag-family:tag-name\"\n  - **type**: list of strings (enum values: \"certificate\", \"cloud_compute_instance\", \"domain\", \"unassociated_responsive_ip\")\n"}}}},"responses":{"UNPROCESSABLE_ENTITY":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## Remove Tags from IP Address Ranges

> Remove tags in bulk from a set of IP address ranges.

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/tags/external_ip_address_ranges/remove/":{"post":{"parameters":[{"in":"header","name":"authorization","description":"api-key","schema":{"type":"string"},"required":true},{"in":"header","name":"x-xdr-auth-id","description":"api-key-id","schema":{"type":"string"},"required":true}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoveTagsFromAsmEntitiesResponse"}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"$ref":"#/components/responses/UNPROCESSABLE_ENTITY"},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequest"}}}},"summary":"Remove Tags from IP Address Ranges","tags":["Tag Management"],"description":"Remove tags in bulk from a set of IP address ranges."}}},"components":{"schemas":{"RemoveTagsFromAsmEntitiesResponse":{"type":"object","properties":{"reply":{"$ref":"#/components/schemas/RemoveTagsFromAsmEntitiesReply"}},"required":["reply"],"additionalProperties":true},"RemoveTagsFromAsmEntitiesReply":{"type":"object","properties":{"remove_tags":{"type":"string","description":"succeeded if request was successful"}},"required":["remove_tags"],"additionalProperties":true},"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}},"AssignOrRemoveTagsFromIpRangesRequest":{"type":"object","properties":{"request_data":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequestData"}},"required":["request_data"],"additionalProperties":true},"AssignOrRemoveTagsFromIpRangesRequestData":{"type":"object","properties":{"filters":{"type":"array","items":{"$ref":"#/components/schemas/AssignOrRemoveTagsFromIpRangesRequestFilter"},"description":"An array of filter fields."},"tags":{"type":"array","items":{"type":"string"},"description":"Name of the tag to add to the ranges. The tag name does not need to include the tag family."}},"additionalProperties":true,"description":"A dictionary containing the API request fields. An empty dictionary returns all results."},"AssignOrRemoveTagsFromIpRangesRequestFilter":{"type":"object","properties":{"field":{"type":"string","enum":["organization_handles","tags","business_units_list","ipaddress_version","has_bu_overrides","range_id_list"],"description":"range_id_list: indicates that the set of IP ranges will be a list of IDs."},"operator":{"type":"string","enum":["in","contains","neq","eq","not_contains"],"description":"in"},"value":{"oneOf":[{"type":"string"},{"type":"integer"},{"type":"array","items":{"type":"string"}},{"type":"array","items":{"type":"integer"}}],"description":"List of strings, the ip range IDs that should be removed from the tag."}},"required":["field","operator","value"],"additionalProperties":true}},"responses":{"UNPROCESSABLE_ENTITY":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}
```

## Delete Unused Tags

> Delete unused tags by specifying tag IDs or tag names. You don't have to provide both tag\_ids and tag\_names, but you can use both to specify different tags.&#x20;

```json
{"openapi":"3.0.2","info":{"title":"Cortex Xpanse REST API","version":"2.12.0"},"tags":[{"name":"Tag Management","description":"APIs for managing tags"}],"servers":[{"url":"https://api-{{fqdn}}"}],"paths":{"/public_api/v1/assets/delete_unused_tag/":{"post":{"summary":"Delete Unused Tags","tags":["Tag Management"],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"reply":{"type":"string"}}}}}},"400":{"description":"Bad Request. Got an invalid JSON.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"402":{"description":"Unauthorized access. User does not have the required license type to run this API.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}},"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/DefaultApiErrorResponse"}}}},"422":{"description":"Unprocessable Entity","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"500":{"description":"Internal server error. A unified status for API communication type errors.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DefaultApiErrorResponse"}}}}},"operationId":"post-public_api-v1-assets-delete_unused_tag","description":"Delete unused tags by specifying tag IDs or tag names. You don't have to provide both tag_ids and tag_names, but you can use both to specify different tags. ","parameters":[{"schema":{"type":"string"},"in":"header","name":"authorization","description":"api-key","required":true},{"schema":{"type":"string"},"in":"header","name":"x-xdr-auth-id","required":true,"description":"api-key-id"}],"requestBody":{"content":{"application/json":{"schema":{"type":"object","required":["request_data"],"properties":{"request_data":{"type":"object","description":"A dictionary containing the API request fields.\r\n\r\nAn empty dictionary returns all results.\r\n","properties":{"tag_family":{"enum":["assets","ip_ranges"]},"tag_ids":{"type":"array","description":"IDs of tags to be deleted. ","items":{"type":"string"}},"tag_names":{"type":"array","description":"Names of tags to be deleted.","items":{"type":"string"}}}}}}}}}}}},"components":{"schemas":{"DefaultApiErrorResponse":{"type":"object","properties":{"reply":{"description":"The query results upon error.","allOf":[{"$ref":"#/components/schemas/GenericReply"}]}},"required":["reply"],"additionalProperties":true},"GenericReply":{"type":"object","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."}},"additionalProperties":true},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"status":{"type":"string","description":"Error name"},"message":{"type":"string","description":"Error message"},"errors":{"type":"object","description":"Errors"}}}}}}
```


---

# 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/xpanse-api/xpanse-public-api/tag-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.
