> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Clear objects

> Clear the records of an index without affecting its settings.

export const Legacy = ({title, href}) => {
  return <Note>

    This page documents an earlier version of the API client.
    For the latest version, see <a href={href}>{title}</a>.

    </Note>;
};

<Legacy title="Delete all records from an index" href="/doc/libraries/sdk/methods/search/clear-objects" />

**Required ACL:** `deleteIndex`

This method enables you to **delete an index's contents** (records)
without removing any settings, rules and synonyms.

If you want to **remove the entire index** and not just its records,
**use the [delete method](/doc/libraries/sdk/v1/methods/delete-index) instead**.

Clearing an index has **no impact on its Analytics data** because
[you can't clear an index's analytics data](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/concepts/indices-analytics).

Clearing an index counts as one operation but **it's rate-limited:**

* If you have more than 100 pending requests, your requests will be throttled.
* If you have more than 5,000 pending requests, further requests will be ignored.

## Examples

<CodeGroup>
  ```cs C# theme={"system"}
  index.ClearObjects();

  // Asynchronous
  await index.ClearObjectsAsync();
  ```

  ```go Go theme={"system"}
  res, err := index.ClearObjects()
  ```

  ```java Java theme={"system"}
  index.clearObjects();

  // Asynchronous
  index.clearObjectsAsync();
  ```

  ```js JavaScript theme={"system"}
  index.clearObjects().then(() => {
    // done
  });
  ```

  ```kotlin Kotlin theme={"system"}
  index.clearObjects()
  ```

  ```php PHP theme={"system"}
  $index->clearObjects();
  ```

  ```python Python theme={"system"}
  index.clear_objects()
  ```

  ```ruby Ruby theme={"system"}
  index.clear_objects
  ```

  ```scala Scala theme={"system"}
  client.execute { clear index "INDEX_NAME" }
  ```

  ```swift Swift theme={"system"}
  index.clearObjects { result in
    if case .success(let response) = result {
      print("Response: \(response)")
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="requestOptions" type="object">
  A mapping of request options to send along with the request.
</ParamField>

## Response

<ResponseField name="taskID" type="integer">
  This is the taskID which is used with the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</ResponseField>

<ResponseField name="updatedAt" type="string">
  Date at which the job to clear the index has been created.
</ResponseField>

### Response as JSON

This section shows the JSON response returned by the API.
Each API client wraps this response in language-specific objects, so the structure may vary.
To view the response, use the `getLogs` method.
Don't rely on the order of properties—JSON objects don't preserve key order.

```jsonc JSON icon=braces theme={"system"}
{
  "updatedAt": "2017-12-18T21:22:40.761Z",
  "taskID": 19541511530
}
```
