class Stytch::WebAuthn

def authenticate(

The type of this field is nilable +DeviceInfo+ (+object+).
If a valid `telemetry_id` was passed in the request and the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) returned results, the `user_device` response field will contain information about the user's device attributes.
user_device::
The type of this field is nilable +Session+ (+object+).

See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.

If you initiate a Session, by including `session_duration_minutes` in your authenticate call, you'll receive a full Session object in the response.
session::
The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +User+ (+object+).
The `user` object affected by this API call. See the [Get user endpoint](https://stytch.com/docs/api/get-user) for complete response field details.
user::
The type of this field is +String+.
The JSON Web Token (JWT) for a given Stytch Session.
session_jwt::
The type of this field is +String+.
A secret token for a given Stytch Session.
session_token::
The type of this field is +String+.
The unique ID for the Passkey or WebAuthn registration.
webauthn_registration_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +String+.
If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the User. Your workspace must be enabled for Device Fingerprinting to use this feature.
telemetry_id::
The type of this field is nilable +object+.
Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.

Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
session_custom_claims::
The type of this field is nilable +String+.
The `session_jwt` associated with a User's existing Session.
session_jwt::
The type of this field is nilable +Integer+.
If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.

If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.

This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).

five minutes regardless of the underlying session duration, and will need to be refreshed over time.
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
session_duration_minutes::
The type of this field is nilable +String+.
The `session_token` associated with a User's existing Session.
session_token::
The type of this field is +String+.
The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
public_key_credential::
== Parameters:

See our [WebAuthn setup guide](https://stytch.com/docs/guides/webauthn/api) for additional usage instructions and example code.

Complete the authentication of a Passkey or WebAuthn registration by passing the response from the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request to the authenticate endpoint.
def authenticate(
  public_key_credential:,
  session_token: nil,
  session_duration_minutes: nil,
  session_jwt: nil,
  session_custom_claims: nil,
  telemetry_id: nil
)
  headers = {}
  request = {
    public_key_credential: public_key_credential
  }
  request[:session_token] = session_token unless session_token.nil?
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
  request[:session_jwt] = session_jwt unless session_jwt.nil?
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
  request[:telemetry_id] = telemetry_id unless telemetry_id.nil?
  post_request('/v1/webauthn/authenticate', request, headers)
end

def authenticate_start(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Options used for Passkey or WebAuthn authentication.
public_key_credential_request_options::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +Boolean+.
If true, values in the `public_key_credential_creation_options` will be base64 URL encoded. Set this option to true when using built-in browser methods like `navigator.credentials.create` and `navigator.credentials.get`.
use_base64_url_encoding::
The type of this field is nilable +Boolean+.

If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `userVerification` set to `"preferred"`.
return_passkey_credential_options::
The type of this field is nilable +String+.
The `user_id` of an active user the Passkey or WebAuthn registration should be tied to. You may use an `external_id` here if one is set for the user.
user_id::
The type of this field is +String+.
The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
domain::
== Parameters:

See our [WebAuthn setup guide](https://stytch.com/docs/guides/webauthn/api) for additional usage instructions and example code.

When using built-in browser methods like `navigator.credentials.get()`, set the `use_base64_url_encoding` option to `true`.

After calling this endpoint, the browser will need to call [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) with the data from `public_key_credential_request_options` passed to the [navigator.credentials.get()](https://www.w3.org/TR/webauthn-2/#sctn-getAssertion) request via the public key argument.

To optimize for Passkeys, set the `return_passkey_credential_options` field to `true`.

Initiate the authentication of a Passkey or WebAuthn registration.
def authenticate_start(
  domain:,
  user_id: nil,
  return_passkey_credential_options: nil,
  use_base64_url_encoding: nil
)
  headers = {}
  request = {
    domain: domain
  }
  request[:user_id] = user_id unless user_id.nil?
  request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
  request[:use_base64_url_encoding] = use_base64_url_encoding unless use_base64_url_encoding.nil?
  post_request('/v1/webauthn/authenticate/start', request, headers)
end

def initialize(connection)

def initialize(connection)
  @connection = connection
end

def list_credentials(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
The type of this field is list of +WebAuthnCredential+ (+object+).
A list of WebAuthn credential objects.
credentials::
An object with the following fields:
== Returns:

The type of this field is +String+.
The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
domain::
The type of this field is +String+.
The `user_id` of an active user the Passkey or WebAuthn registration should be tied to.
user_id::
== Parameters:

List the public key credentials of the WebAuthn Registrations or Passkeys registered to a specific User.
def list_credentials(
  user_id:,
  domain:
)
  headers = {}
  query_params = {}
  request = request_with_query_params("/v1/webauthn/credentials/#{user_id}/#{domain}", query_params)
  get_request(request, headers)
end

def register(

The type of this field is nilable +DeviceInfo+ (+object+).
If a valid `telemetry_id` was passed in the request and the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) returned results, the `user_device` response field will contain information about the user's device attributes.
user_device::
The type of this field is nilable +Session+ (+object+).

See [Session object](https://stytch.com/docs/api/session-object) for complete response fields.

If you initiate a Session, by including `session_duration_minutes` in your authenticate call, you'll receive a full Session object in the response.
session::
The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +User+ (+object+).
(no documentation yet)
user::
The type of this field is +String+.
The JSON Web Token (JWT) for a given Stytch Session.
session_jwt::
The type of this field is +String+.
A secret token for a given Stytch Session.
session_token::
The type of this field is +String+.
The unique ID for the Passkey or WebAuthn registration.
webauthn_registration_id::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +String+.
If the `telemetry_id` is passed, as part of this request, Stytch will call the [Fingerprint Lookup API](https://stytch.com/docs/fraud/api/fingerprint-lookup) and store the associated fingerprints and IPGEO information for the User. Your workspace must be enabled for Device Fingerprinting to use this feature.
telemetry_id::
The type of this field is nilable +object+.
Custom claims made with reserved claims ("iss", "sub", "aud", "exp", "nbf", "iat", "jti") will be ignored. Total custom claims size cannot exceed four kilobytes.

Add a custom claims map to the Session being authenticated. Claims are only created if a Session is initialized by providing a value in `session_duration_minutes`. Claims will be included on the Session object and in the JWT. To update a key in an existing Session, supply a new value. To delete a key, supply a null value.
session_custom_claims::
The type of this field is nilable +String+.
The `session_jwt` associated with a User's existing Session.
session_jwt::
The type of this field is nilable +Integer+.
If the `session_duration_minutes` parameter is not specified, a Stytch session will not be created.

If a `session_token` or `session_jwt` is provided then a successful authentication will continue to extend the session this many minutes.

This value must be a minimum of 5 and a maximum of 527040 minutes (366 days).

five minutes regardless of the underlying session duration, and will need to be refreshed over time.
returning both an opaque `session_token` and `session_jwt` for this session. Remember that the `session_jwt` will have a fixed lifetime of
Set the session lifetime to be this many minutes from now. This will start a new session if one doesn't already exist,
session_duration_minutes::
The type of this field is nilable +String+.
The `session_token` associated with a User's existing Session.
session_token::
The type of this field is +String+.
The response of the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential).
public_key_credential::
The type of this field is +String+.
The `user_id` of an active user the Passkey or WebAuthn registration should be tied to. You may use an `external_id` here if one is set for the user.
user_id::
== Parameters:

See our [WebAuthn setup guide](https://stytch.com/docs/guides/webauthn/api) for additional usage instructions and example code.

Complete the creation of a WebAuthn registration by passing the response from the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request to this endpoint as the `public_key_credential` parameter.
def register(
  user_id:,
  public_key_credential:,
  session_token: nil,
  session_duration_minutes: nil,
  session_jwt: nil,
  session_custom_claims: nil,
  telemetry_id: nil
)
  headers = {}
  request = {
    user_id: user_id,
    public_key_credential: public_key_credential
  }
  request[:session_token] = session_token unless session_token.nil?
  request[:session_duration_minutes] = session_duration_minutes unless session_duration_minutes.nil?
  request[:session_jwt] = session_jwt unless session_jwt.nil?
  request[:session_custom_claims] = session_custom_claims unless session_custom_claims.nil?
  request[:telemetry_id] = telemetry_id unless telemetry_id.nil?
  post_request('/v1/webauthn/register', request, headers)
end

def register_start(

The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Options used for Passkey or WebAuthn registration.
public_key_credential_creation_options::
The type of this field is +String+.
The unique ID of the affected User.
user_id::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is nilable +Boolean+.
If true, values in the `public_key_credential_creation_options` will be base64 URL encoded. Set this option to true when using built-in browser methods like `navigator.credentials.create` and `navigator.credentials.get`.
use_base64_url_encoding::
The type of this field is nilable +String+.
(no documentation yet)
override_display_name::
The type of this field is nilable +String+.
(no documentation yet)
override_name::
The type of this field is nilable +String+.
(no documentation yet)
override_id::
The type of this field is nilable +Boolean+.

If true, the `public_key_credential_creation_options` returned will be optimized for Passkeys with `residentKey` set to `"required"` and `userVerification` set to `"preferred"`.
return_passkey_credential_options::
The type of this field is nilable +String+.
The requested authenticator type of the Passkey or WebAuthn device. The two valid values are platform and cross-platform. If no value passed, we assume both values are allowed.
authenticator_type::
The type of this field is nilable +String+.
The user agent of the client.
user_agent::
The type of this field is +String+.
The domain for Passkeys or WebAuthn. Defaults to `window.location.hostname`.
domain::
The type of this field is +String+.
The `user_id` of an active user the Passkey or WebAuthn registration should be tied to. You may use an `external_id` here if one is set for the user.
user_id::
== Parameters:

See our [WebAuthn setup guide](https://stytch.com/docs/guides/webauthn/api) for additional usage instructions and example code.

When using built-in browser methods like `navigator.credentials.create()`, set the `use_base64_url_encoding` option to `true`.

After calling this endpoint, the browser will need to call [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) with the data from [public_key_credential_creation_options](https://w3c.github.io/webauthn/#dictionary-makecredentialoptions) passed to the [navigator.credentials.create()](https://www.w3.org/TR/webauthn-2/#sctn-createCredential) request via the public key argument.

To optimize for Passkeys, set the `return_passkey_credential_options` field to `true`.

Initiate the process of creating a new Passkey or WebAuthn registration.
def register_start(
  user_id:,
  domain:,
  user_agent: nil,
  authenticator_type: nil,
  return_passkey_credential_options: nil,
  override_id: nil,
  override_name: nil,
  override_display_name: nil,
  use_base64_url_encoding: nil
)
  headers = {}
  request = {
    user_id: user_id,
    domain: domain
  }
  request[:user_agent] = user_agent unless user_agent.nil?
  request[:authenticator_type] = authenticator_type unless authenticator_type.nil?
  request[:return_passkey_credential_options] = return_passkey_credential_options unless return_passkey_credential_options.nil?
  request[:override_id] = override_id unless override_id.nil?
  request[:override_name] = override_name unless override_name.nil?
  request[:override_display_name] = override_display_name unless override_display_name.nil?
  request[:use_base64_url_encoding] = use_base64_url_encoding unless use_base64_url_encoding.nil?
  post_request('/v1/webauthn/register/start', request, headers)
end

def update(

The type of this field is nilable +WebAuthnRegistration+ (+object+).
A Passkey or WebAuthn registration.
webauthn_registration::
The type of this field is +Integer+.
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors.
status_code::
The type of this field is +String+.
Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue.
request_id::
An object with the following fields:
== Returns:

The type of this field is +String+.
The `name` of the WebAuthn registration or Passkey.
name::
The type of this field is +String+.
Globally unique UUID that identifies a Passkey or WebAuthn registration in the Stytch API. The `webauthn_registration_id` is used when you need to operate on a specific User's WebAuthn registration.
webauthn_registration_id::
== Parameters:

Updates a Passkey or WebAuthn registration.
def update(
  webauthn_registration_id:,
  name:
)
  headers = {}
  request = {
    name: name
  }
  put_request("/v1/webauthn/#{webauthn_registration_id}", request, headers)
end