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.Create a User with a password
First, prompt your user for their email address and ask them to create a password. Then, call our Create User with Password endpoint with that information in order to create a new Stytch User.Be sure to add a Save the
session_duration_minutes parameter to that call 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 Create User with Password response for use in the next steps.Send a verification email
At this point, you’ll have a new Stytch User with a password and an unverified email address, along with a newly-created Stytch session.Send a verification email by calling our Send one-time passcode by email endpoint. Include the Save the
session_token from the previous step – otherwise, the user will be required to reset their password in order to prevent an account takeover attack vector:email_id from the Send one-time passcode by email 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
email_id from the previous step (known in this next call as the method_id). As in the previous step, include the session_token from Step 1 in your API call: