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

# How to restore an API key

> Learn how to restore an API key.

You may accidentally delete one or more of your API keys. This can happen when you **delete a user**, because doing so causes their associated API keys to disappear.

You can restore either deleted or expired keys, but Algolia only keeps the last 1,000 deleted keys.

<Note>
  When you restore a deleted API key, Algolia automatically resets its validity limit to 0 (unlimited).
</Note>

## Using the API

To run the code examples on this page, [install the latest API client](/doc/libraries/sdk/install).

You can restore a key with the [`restoreApiKey`](/doc/libraries/sdk/v1/methods/restore-api-key) method.

<CodeGroup>
  ```cs C# theme={"system"}
  var response = await client.RestoreApiKeyAsync("ALGOLIA_API_KEY");
  ```

  ```dart Dart theme={"system"}
  final response = await client.restoreApiKey(
    key: "ALGOLIA_API_KEY",
  );
  ```

  ```go Go theme={"system"}
  response, err := client.RestoreApiKey(client.NewApiRestoreApiKeyRequest(
    "ALGOLIA_API_KEY"))
  if err != nil {
    // handle the eventual error
    panic(err)
  }
  ```

  ```java Java theme={"system"}
  AddApiKeyResponse response = client.restoreApiKey("ALGOLIA_API_KEY");
  ```

  ```js JavaScript theme={"system"}
  const response = await client.restoreApiKey({ key: 'ALGOLIA_API_KEY' });
  ```

  ```kotlin Kotlin theme={"system"}
  var response = client.restoreApiKey(key = "ALGOLIA_API_KEY")
  ```

  ```php PHP theme={"system"}
  $response = $client->restoreApiKey(
      'ALGOLIA_API_KEY',
  );
  ```

  ```python Python theme={"system"}
  response = client.restore_api_key(
      key="ALGOLIA_API_KEY",
  )
  ```

  ```ruby Ruby theme={"system"}
  response = client.restore_api_key("ALGOLIA_API_KEY")
  ```

  ```scala Scala theme={"system"}
  val response = Await.result(
    client.restoreApiKey(
      key = "ALGOLIA_API_KEY"
    ),
    Duration(100, "sec")
  )
  ```

  ```swift Swift theme={"system"}
  let response = try await client.restoreApiKey(key: "ALGOLIA_API_KEY")
  ```
</CodeGroup>

## Using the Algolia dashboard

You can also restore API keys in your Algolia dashboard with the following steps:

1. Go to your dashboard's [**API keys**](https://dashboard.algolia.com/account/api-keys/) section.
2. Click the **All API Keys** tab.
3. Click the **Restore API Key** button, insert your API key, then click **Restore**.
