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

# Retrieve remaining validity for secured API key

> Returns the time in seconds until the secured API key expires.

This helper method returns the number of seconds remaining until the secured API key expires,
as defined by its `validUntil` property.
If the key has already expired, the method returns a negative value representing the number of seconds since expiration.

## Usage

<CodeGroup>
  ```cs C# theme={"system"}
  var expires = client.GetSecuredApiKeyRemainingValidity(
    securedApiKey,
  )
  ```

  ```go Go theme={"system"}
  let expires, err := client.GetSecuredApiKeyRemainingValidity(
      securedApiKey,
  )
  ```

  ```java Java theme={"system"}
  Duration expires = client.getSecuredApiKeyRemainingValidity(
      securedApiKey
  );
  ```

  ```js JavaScript theme={"system"}
  const expires = client.getSecuredApiKeyRemainingValidity({
    securedApiKey
  });
  ```

  ```kt Kotlin theme={"system"}
  val expires = client.securedApiKeyRemainingValidity(
    apiKey: securedApiKey,
  )
  ```

  ```php PHP theme={"system"}
  expires = $client->getSecuredApiKeyRemainingValidity(
    $securedApiKey
  )
  ```

  ```python Python theme={"system"}
  expires = client.get_secured_api_key_remaining_validity(
    secured_api_key,
  )
  ```

  ```ruby Ruby theme={"system"}
  expires = client.get_secured_api_key_remaining_validity(
    secured_api_key
  )
  ```

  ```scala Scala theme={"system"}
  client.getSecuredApiKeyRemainingValidity(securedKey) match {
      case Some(validity) if validity > Duration.Zero =>
        println(s"Key is still valid for ${validity.toMinutes} minutes")
      case Some(_) =>
        println("Key has expired")
      case None =>
        println("Key has no expiry date or couldn’t be decoded")
    }
  ```

  ```swift Swift theme={"system"}
  let expires = client.getSecuredApiKeyRemainingValidity(
      securedApiKey,
  )
  ```
</CodeGroup>

## Parameters

<Tabs>
  <Tab title="C#">
    <ParamField body="securedApiKey" type="string" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Go">
    <ParamField body="securedApiKey" type="string" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Java">
    <ParamField body="securedApiKey" type="String" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="JavaScript">
    <ParamField body="securedApiKey" type="string" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Kotlin">
    <ParamField body="securedApiKey" type="String" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="PHP">
    <ParamField body="securedApiKey" type="string" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Python">
    <ParamField body="secured_api_key" type="str" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Ruby">
    <ParamField body="secured_api_key" type="String" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Scala">
    <ParamField body="securedApiKey" type="String" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>

  <Tab title="Swift">
    <ParamField body="securedApiKey" type="String" required>
      The secured API key you want to test.
      For more information, see [Generate secured API key](/doc/libraries/sdk/methods/search/generate-secured-api-key).
    </ParamField>
  </Tab>
</Tabs>
