--- url: "https://web.dev/articles/webauthn-exclude-credentials" titulek: "Prevent creating a new passkey if one exists | web.dev" h1: "Prevent creating a new passkey if one exists Stay organized with collections Save and categorize content based on your preferences." popis: "Learn how to prevent creating a new passkey if one already exists in the user's password manager." jazyk: "en" kanonicka: "https://web.dev/articles/webauthn-exclude-credentials" drobecky: ["web.dev", "Resources", "Identity"] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 00:56:37" znaku: 2620 slov: 349 kodovani: "iso-8859-2" sha256: "e54e3f3d3c5de78dfe2228c26489c3f852019f56ad8367d71fb35613e3e04a0b" --- Prevent creating a new passkey if one exists Stay organized with collections Save and categorize content based on your preferences. To prevent creating a new passkey if one already exists in the same passkey provider, use the optional `excludeCredentials` property of WebAuthn's [`PublicKeyCredentialCreationOptions`](https://developer.mozilla.org/docs/Web/API/CredentialsContainer/create#excludecredentials) dictionary. The `excludeCredentials` property is an array of descriptors for public keys that already exist for a given user. This information is supplied by the [relying party's](https://www.w3.org/TR/webauthn/#webauthn-relying-party) server when it wants to prevent the creation of new credentials for an existing user on a single authenticator. The `excludeCredentials` array has the following attributes: **type**: A string that describes the type of public-key credential to be generated. The default value is "`public-key`". **id**: An `ArrayBuffer` that matches an existing public key credential identifier (`PublicKeyCredential.rawId`). This identifier is generated during the creation of the `PublicKeyCredential` instance. The [client](https://www.w3.org/TR/webauthn/#client) returns an **error** if the user tries to create a new credential on a platform authenticator that already contains one of the credentials listed in this parameter. If the authenticator already contains a public key credential of this type, the authenticator collects user consent as usual, and shows the user a success indicator with no new credential created. An `InvalidStateError` exception is thrown, indicating that the user already has a valid credential matched from `excludeCredentials`. `"excludeCredentials": [ {"id": "", "type": "public-key"}, {"id": "", "type": "public-key"} ]` This JSON can be used to prevent authenticators with one of the provided credentials from being registered more than once. Each "``" value should be populated with the identifier of the credential to be excluded. Learn more about `excludeCredentials` in the [W3C recommendation](https://www.w3.org/TR/webauthn/#dom-publickeycredentialcreationoptions-excludecredentials) Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see the [Google Developers Site Policies](https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates. Last updated 2024-02-02 UTC.