Before you start
Create a Stytch Consumer project via the Stytch Dashboard if you don’t have one already. To do so, click on your existing project name in top left corner of the Dashboard, click Create Project, and then select Consumer Authentication.Copy your
project_id and secret for the Test environment you would like to use. These values can be accessed from the Project ID & API keys section of the Project Overview. You’ll need to include these values in every backend Stytch API call.Send a verification email to your user
First, prompt your user for their email address, and then send them a verification OTP code using our Log in or create User by email endpoint. Here’s an example cURL request:Save the
email_id from the Log in or create User response for use in the next step.Authenticate the one-time passcode
Once your user submits the one-time passcode from the email that they received, call our Authenticate one-time passcode endpoint with the code and the Save the
email_id from the previous step (known in this next call as the method_id).Be sure to add a session_duration_minutes parameter so that a new Stytch session is started. We’ll use 30 minutes for the purposes of this guide, but feel free to tailor the session length to your own use case:session_token from the Authenticate one-time passcode response for use in the next step.Set a password
At this point, you’ll have a new Stytch User with a verified email address. You’ll now need to prompt your user to create a password and add it to the User via our Password reset by existing session endpoint, using the session that was created in the previous step:Note that for security purposes, you’ll need to complete this step within 5 minutes of creating the session in the previous step.