Delete By Query

  • Use this endpoint with the DELETE method to delete all documents that satisfy a query:
    <server URL>/databases/<database name>/queries

  • In this page:


This cURL request sends a query to a database named "Example" on our playground server. The results of this query - in this case, one document named "employees/1-A" - are all deleted.

curl -X DELETE ""
-d "{ \"Query\": \"from Employees where FirstName = 'Nancy'\" }"
Linebreaks are added for clarity.


HTTP/1.1 200 OK
Server: nginx
Date: Sun, 24 Nov 2019 12:21:11 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Content-Encoding: gzip
Vary: Accept-Encoding
Request-Time: 5

    "OperationId": 42,
    "OperationNodeTag": "A"

Request Format

This the general format of a cURL request that uses all query string parameters:

curl -X GET "<server URL>/databases/<database name>/docs?
-d "{ }"

Query String Parameters

Option Description
allowStale If the query is on an index (rather than a collection), this determines whether to delete results from a stale index. If set to false and the specified index is stale, an exception is thrown. Default: false.
staleTimeout If allowStale is set to false, this parameter sets the amount of time to wait for the index not to be stale. If the time runs out, an exception is thrown. The value is of type TimeSpan. Default: null - if the index is stale the exception is thrown immediately.
maxOpsPerSec The maximum number of deletions per second the server can perform in the background. Default: no limit.


This is the general format of the request body:

-d "{
    \"Query\": \"<RQL query referencing $<name>>\",
    \"QueryParameters\": {
Depending on the shell you're using to run cURL, you will probably need to escape all double quotes within the request body using a backslash: " -> \".
Parameter Description
Query A query in RQL. You can insert parameters from the QueryParameters object with $<parameter name>
QueryParameters A list of values that can be used in the query, such as strings, ints, or documents IDs. Inputs from your users should always be passed as query parameters to avoid SQL injection attacks, and in general it's best practice to pass all your right-hand operands as parameters.

Response Format

Http Status Codes

Code Description
200 The request was valid. This includes the case where the query found 0 results, or the specified index does not exist, etc.
500 Bad request or server-side exception


    "OperationId": <int>,
    "OperationNodeTag": "<cluster node tag>"
Field Description
OperationId Increments each time the server recieves a new Operation to execute, including as DeleteByQuery and PatchByQuery
OperationNodeTag The tag of the Cluster Node that first received the Delete by Query Operation. Values are A to Z. See Cluster Topology.