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

# Restore API key

> Restore a deleted API key.

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="Restore an API key" href="/doc/libraries/sdk/methods/search/restore-api-key" />

**Required ACL:** `Admin`

The system keeps up to **1,000 deleted API keys**.
When this limit is exceeded, the oldest deleted keys are permanently removed and can't be restored.

Restored API keys don't expire (the `validity` is reset to 0).
Requests must be authenticated with the **admin API key**.

## Examples

### Restore an API key

<CodeGroup>
  ```cs C# theme={"system"}
  client.RestoreApiKey("myAPIKey");
  ```

  ```go Go theme={"system"}
  res, err := client.RestoreAPIKey("myAPIKey")
  ```

  ```java Java theme={"system"}
  client.restoreApiKey("myAPIKey");

  // Async
  client.restoreApiKeyAsync("myAPIKey");
  ```

  ```js JavaScript theme={"system"}
  client.restoreApiKey('myAPIKey').then(() => {
    // done
  });
  ```

  ```kotlin Kotlin theme={"system"}
  client.restoreAPIKey(APIKey("myAPIKey"))
  ```

  ```php PHP theme={"system"}
  $client->restoreApiKey("myAPIKey");
  ```

  ```python Python theme={"system"}
  client.restore_api_key('myAPIKey')
  ```

  ```python Python theme={"system"}
  client.restore_api_key('myAPIKey')
  ```

  ```scala Scala theme={"system"}
  client.execute {
    restore key "myAPIKey"
  }
  ```

  ```swift Swift theme={"system"}
  client.restoreAPIKey("myAPIKey") { result in
    if case .success(let response) = result {
    }
  }
  ```
</CodeGroup>

## Parameters

<ParamField body="apiKey" type="string" required>
  API key to restore
</ParamField>

## Response

<ResponseField name="createdAt" type="string">
  The date at which the key has been restored.
</ResponseField>

<ResponseField name="key" type="string">
  The restored key.
</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"}
{
  "key": "1eb37de6308abdccf9b760ddacb418b4",
  "createdAt": "2017-12-16T22:21:31.871Z"
}
```
