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

# Delete index

> Delete an index and all its settings, including links to its replicas.

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 an index" href="/doc/libraries/sdk/methods/search/delete-index" />

**Required ACL:** `deleteIndex`

* Deleting an index **doesn't remove its analytics data**.

* Deleting a nonexistent index is ignored—no error is returned.

* **Indices with replicas:**

  * Deleting a primary index makes replicas independent indices.
  * You can't delete a replica directly.
    First [unlink it](/doc/guides/managing-results/refine-results/sorting/how-to/deleting-replicas) to make it a regular index,
    then delete it.

* **Delete only records.**
  Use [`clearObjects`](/doc/libraries/sdk/v1/methods/clear-objects) to remove records but keep settings, rules, and synonyms.

For more information, including how to delete multiple indices,
see [Delete indices](/doc/guides/sending-and-managing-data/manage-indices-and-apps/manage-indices/how-to/delete-indices).

## Examples

### Delete an index by name

<CodeGroup>
  ```cs C# theme={"system"}
  // Use an API key with `deleteIndex` ACL
  var client = new SearchClient("YourApplicationID", "YourAPIKey");
  var index = client.InitIndex("YourIndexName");

  index.Delete();

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

  ```go Go theme={"system"}
  // Use an API key with `deleteIndex` ACL
  client := search.NewClient("YourApplicationID", "YourAPIKey")
  index := client.InitIndex("YourIndexName")
  res, err := index.Delete()
  ```

  ```java Java theme={"system"}
  // Use an API key with `deleteIndex` ACL
  SearchClient client = DefaultSearchClient.create("YourApplicationID", "YourAPIKey");
  SearchIndex<Record> index = client.initIndex("YourIndexName", Record.class);

  index.delete();

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

  ```js JavaScript theme={"system"}
  const algoliasearch = require('algoliasearch');

  // Use an API key with `deleteIndex` ACL
  const client = algoliasearch('YourApplicationID', 'YourAPIKey');
  const index = client.initIndex('YourIndexName');

  index.delete();
  ```

  ```kotlin Kotlin theme={"system"}
  // Use an API key with `deleteIndex` ACL
  val client = ClientSearch(
    ApplicationID("YourApplicationID"),
    APIKey("YourAPIKey")
  )
  val index = client.initIndex(IndexName("YourIndexName"))

  index.deleteIndex()
  ```

  ```php PHP theme={"system"}
  <?php
  require_once __DIR__."/vendor/autoload.php";
  use Algolia\AlgoliaSearch\SearchClient;

  // Use an API key with `deleteIndex` ACL
  $client = SearchClient::create(
    'YourApplicationID', 'YourAPIKey'
  );
  $index = $client->initIndex('YourIndexName');
  $index->delete();
  ```

  ```python Python theme={"system"}
  from algoliasearch.search_client import SearchClient

  # Use an API key with `deleteIndex` ACL
  client = SearchClient.create("YourApplicationID", "YourAPIKey")
  index = client.init_index("YourIndexName")
  index.delete()
  ```

  ```ruby Ruby theme={"system"}
  require 'algolia'

  # Use an API key with `deleteIndex` ACL
  client = Algolia::Search::Client.create(
    'YourApplicationID', 'YourAPIKey'
  )
  index = client.init_index('YourIndexName')
  index.delete
  ```

  ```scala Scala theme={"system"}
  // Use an API key with `deleteIndex` ACL
  val client = new AlgoliaClient("YourApplicationID", "YourAPIKey")
  client.execute { delete index "index" }
  ```

  ```swift Swift theme={"system"}
  import AlgoliaSearchClient

  // Use an API key with `deleteIndex` ACL
  let client = SearchClient(
    appID: "YourApplicationID",
    apiKey: "YourAPIKey"
  )
  let index = client.index(withName: "YourIndexName")

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

## Parameters

<ParamField body="indexName" type="string" required>
  Name of the index to be deleted.
</ParamField>

## Response

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

<ResponseField name="taskID" type="integer">
  The `taskID` for the [`waitTask`](/doc/libraries/sdk/v1/methods/wait-task) method.
</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"}
{
  "deletedAt": "2017-12-18T21:22:40.761Z",
  "taskID": 19541511530
}
```
