---
type: api
title: Clear a scrolling search
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-clear-scroll
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-clear-scroll
products:
  - Elasticsearch
---

# Clear a scrolling search


## Paths

- `DELETE` `/_search/scroll/{scroll_id}`
- `DELETE` `/_search/scroll`

#### Path parameters

- `scroll_id` (union string | string[]) — optional, leave it out to use `/_search/scroll` — deprecated
  A comma-separated list of scroll IDs to clear.
To clear all scroll IDs, use `_all`.
IMPORTANT: Scroll IDs can be long. It is recommended to specify scroll IDs in the request body parameter.

## Description

Clear the search context and results for a scrolling search.

[About paginating search results](https://www.elastic.co/docs/reference/elasticsearch/rest-apis/paginate-search-results#scroll-search-results)

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Request body

`application/json`

- `scroll_id` (union) — optional
  The scroll IDs to clear.
To clear all scroll IDs, use `_all`.

## Response

`application/json`

- `succeeded` (boolean)
  If `true`, the request succeeded.
This does not indicate whether any scrolling search requests were cleared.
- `num_freed` (number)
  The number of scrolling search requests cleared.
## Code examples

#### Console

```console
DELETE /_search/scroll
{
  "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
}
```

#### JavaScript

```javascript
const response = await client.clearScroll({
  scroll_id: "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==",
});
```

#### Python

```python
resp = client.clear_scroll(
    scroll_id="DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_search/scroll" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
  }'
```

#### Java

```java
client.clearScroll(c -> c
    .scrollId("DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==")
);
```

#### C#

```c#
var response = await client
    .ClearScrollAsync(d1 => d1
        .ScrollId(new[] { "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==" })
    );
```

#### PHP

```php
$resp = $client->clearScroll([
    "body" => [
        "scroll_id" => "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ==",
    ],
]);
```

#### Ruby

```ruby
response = client.clear_scroll(
  body: {
    "scroll_id": "DXF1ZXJ5QW5kRmV0Y2gBAAAAAAAAAD4WYm9laVYtZndUQlNsdDcwakFMNjU1QQ=="
  }
)
```

