What is discovery?
Discovery refers to a state during authentication where an end user is not yet associated with an organization and is “discovering” the organizations that they are eligible to authenticate into.What happens
Anintermediate_session_token is returned in response to any of the Discovery authenticate methods (example).
A list of Discovered Organization objects is included in the response. This is a list of organizations associated with the member. This can be used to inform subsequent UI to list available organizations for the member to select from.
Stytch UI provides configurations, such as
directLoginForSingleMembership, to handle these scenarios out-of-the-box.Sample response
Response 200
Select or create an organization
At this point, you can have users select an organization to start a session with or allow them to create a new organization using either method.discovery.intermediateSessions.exchange()
Start a session with a selected organization.
discovery.organizations.create()
Allow users to create a new organization.
intermediate_session_token is automatically saved in browser cookies by the SDK and isn’t required to be explicitly passed into these methods.
Example
Next steps
If the end user selects an organization wheremember_authenticated is false, you will need to trigger additional MFA or step-up authentication steps based on the authentication requirements of the selected organization.
Instead of calling the endpoints above, you can proceed directly to step-up authentication (if the primary_required value is non-null) or MFA (if the mfa_required value is non-null).
Step-up authentication
Adding step-up authentication.
Multi-factor authentication (MFA)
Handling multi-factor authentication.