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

# Security key

> Use the Web SDK to enroll and verify hardware security keys.

> [!NOTE]
>
> All Web SDK methods for security keys require you to [initiate an action
> first](https://docs.authsignal.com/sdks/client/web/actions.md).

Security keys are roaming hardware authenticators (such as YubiKeys) that authenticate using the WebAuthn standard. Unlike passkeys, they are not synced across devices.

## Enroll

Start enrollment for a new security key by prompting the user to register their hardware authenticator.

```ts theme={null}
const response = await authsignal.securityKey.enroll();
```

### Parameters

**hints** `string[]`

An array of [WebAuthn credential hints](https://www.w3.org/TR/webauthn-3/#enum-hints) which guide
the browser's UI, e.g. `["security-key"]`.

### Response

**response** `AuthsignalResponse\<EnrollResponse\>`

**properties**

**data** `EnrollResponse`

**properties**

**token** `string`

A new token which can be used to [validate the
challenge](https://docs.authsignal.com/sdks/server/challenges.md#validate-challenge) on your server.

**registrationResponse** `RegistrationResponseJSON`

The raw WebAuthn registration response returned by the browser. Most apps can ignore this.

**errorCode** `string`

See the [Error handling](https://docs.authsignal.com/sdks/client/web/error-handling.md) section for more details.

**errorDescription** `string`

## Verify

Re-authenticate an existing security key by prompting the user to present their hardware authenticator.

```ts theme={null}
const response = await authsignal.securityKey.verify();

if (response.data?.token) {
  // Send the response token to your server to validate the result of the challenge
}
```

### Response

**response** `AuthsignalResponse\<VerifyResponse\>`

**properties**

**data** `VerifyResponse`

**properties**

**isVerified** `boolean` *required*

True if the verification was successful.

**token** `string`

A token which can be used for [server-side
validation](https://docs.authsignal.com/sdks/server/challenges.md#validate-challenge).

**authenticationResponse** `AuthenticationResponseJSON`

The raw WebAuthn authentication response returned by the browser. Most apps can ignore this.

**errorCode** `string`

See the [Error handling](https://docs.authsignal.com/sdks/client/web/error-handling.md) section for more details.

**errorDescription** `string`

## Security key error handling

When any of the underlying native browser WebAuthn APIs fail, the SDK will throw a `WebAuthnError`. Most of these errors are benign and can be safely ignored, for example when the user cancels the ceremony. If you wish to handle them, catch the error in a `try/catch` block. See [Passkey error handling](https://docs.authsignal.com/sdks/client/web/passkeys.md#passkey-error-handling) for the common error codes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.