Is there any way to check if an identity exists in...
# general
s
Is there any way to check if an identity exists in Kratos with a specific email without listing all identities until found?
e
https://www.ory.com/docs/kratos/reference/api#tag/identity/operation/listIdentities use the credentials_identifier set to the user's email.
This only works if the email is a credential identifier mind you, if it is just a verified address, we currently don't have a way of searching for that in OSS.
s
@early-magician-18981 Thank you for the swift reply! Will an identity schema like this work (not sure how to set the email as a credential identifier or if it's done already):
Copy code
{
  "$id": "<https://schemas.ory.sh/presets/kratos/quickstart/email-password/identity.schema.json>",
  "$schema": "<http://json-schema.org/draft-07/schema#>",
  "title": "User",
  "type": "object",
  "properties": {
    "traits": {
      "type": "object",
      "properties": {
        "email": {
          "type": "string",
          "format": "email",
          "title": "E-Mail",
          "minLength": 3,
          "<http://ory.sh/kratos|ory.sh/kratos>": {
            "credentials": {
              "passkey": {
                "display_name": true
              },
              "webauthn": {
                "identifier": true
              },
              "password": {
                "identifier": true
              }
            },
            "verification": {
              "via": "email"
            },
            "recovery": {
              "via": "email"
            }
          }
        },
        "firstName": {
          "type": "string",
          "minLength": 1,
          "title": "First Name"
        },
        "lastName": {
          "type": "string",
          "minLength": 1,
          "title": "Last Name"
        }
      },
      "required": [
        "email",
        "firstName",
        "lastName"
      ],
      "additionalProperties": false
    }
  }
}
e
Yeah that is done there, you see how
properties": { "email": {
you have a
<http://ory.sh/kratos|ory.sh/kratos>: { credentials:...
bit? That tells kratos that that property is used as an identifier for those set of credentials you have configured.
s
Thank you! Going to try this now.