[role="xpack"]
[[delete-query-rule]]
=== Delete query rule

++++
<titleabbrev>Delete query rule</titleabbrev>
++++

Removes an individual query rule within an existing query ruleset.
This is a destructive action that is only recoverable by re-adding the same rule via the <<put-query-rule, create or update query rule>> API.

[[delete-query-rule-request]]
==== {api-request-title}

`DELETE _query_rules/<ruleset_id>/_rule/<rule_id>`

[[delete-query-rule-prereq]]
==== {api-prereq-title}

Requires the `manage_search_query_rules` privilege.

[[delete-query_rule-path-params]]
==== {api-path-parms-title}

`<ruleset_id>`::
(Required, string)

`<rule_id>`::
(Required, string)

[[delete-query-rule-response-codes]]
==== {api-response-codes-title}

`400`::
Missing `ruleset_id`, `rule_id`, or both.

`404` (Missing resources)::
No query ruleset matching `ruleset_id` could be found, or else no rule matching `rule_id` was found in that ruleset.

[[delete-query-rule-example]]
==== {api-examples-title}

The following example deletes the query rule with ID `my-rule1` from the query ruleset named `my-ruleset`:

////
[source,console]
----
PUT _query_rules/my-ruleset
{
    "rules": [
        {
            "rule_id": "my-rule1",
            "type": "pinned",
            "criteria": [
                {
                    "type": "exact",
                    "metadata": "query_string",
                    "values": [ "marvel" ]
                }
            ],
            "actions": {
                "ids": ["id1"]
            }
        }
    ]
}
----
// TESTSETUP
////

[source,console]
----
DELETE _query_rules/my-ruleset/_rule/my-rule1
----
