Consumer Authentication

/

Frontend SDKs

/

Headless

/

One-Time Passcodes (OTP)

/

Login or create via Email

Login or create via email

Wraps Stytch's login_or_create via email API endpoint. Call this method to send an email passcode to new or existing users.


Method parameters


email*string

Configurationobject

Additional configuration.

expiration_minutesint
login_template_idstring
signup_template_idstring
localestring
import React, { useCallback } from 'react';
import { useStytch } from '@stytch/react';
export const Login = () => {
  const stytch = useStytch();
  const sendPasscode = useCallback(() => {
    stytch.otps.email.loginOrCreate('sandbox@stytch.com', {
      expiration_minutes: 5,
    });
  }, [stytch]);
  return <button onClick={sendPasscode}>Send passcode</button>;
};

RESPONSE

200
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "method_id": "email-test-81bf03a8-86e1-4d95-bd44-bb3495224953"
  }