> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# verifyApiKey

> Verify an API key against the configured key.

[ref-validate]: /docs/server-sdks/reference/typescript/agents/configuration/auth-handler/validate

Verify an API key against the configured key. Uses a constant-time comparison
to prevent timing attacks. Returns `false` immediately when API key auth is
not configured.

<Note>
  Pass only the key value -- this method does not parse headers. For full
  header-based validation (which reads the configured `apiKeyHeader`, case-
  insensitive), use [`validate()`][ref-validate].
</Note>

## **Parameters**

<ParamField path="key" type="string" required={true} toc={true}>
  The API key string to verify.
</ParamField>

## **Returns**

`boolean` -- `true` if the key matches; `false` if it doesn't, or if API key
auth was not configured.

## **Example**

```typescript {8}
import { AuthHandler } from '@signalwire/sdk';

const auth = new AuthHandler({
  apiKey: 'sk_live_abc123',
  apiKeyHeader: 'X-Api-Key',
});

function authorize(headerValue: string | undefined) {
  if (!headerValue) return false;
  return auth.verifyApiKey(headerValue);
}
```