Consumer Authentication

/

Frontend SDKs

/

Headless

/

One-Time Passcodes (OTP)

/

Send via SMS

Send via SMS

Wraps Stytch's send via SMS API endpoint. Call this method to send an SMS passcode to existing users.

This method is also used when you need to add a phone number to an existing Stytch User. If there is a currently valid Stytch session, and the user inputs a phone number that does not match one on their Stytch User object, upon successful authentication the new phone number will be added to the existing user. Note, this does expose a potential account enumeration vector, see our article on preventing account enumeration for more details.

Cost to send SMS OTP

Before configuring SMS or WhatsApp OTPs, please review how Stytch bills the costs of international OTPs and understand how to protect your app against toll fraud.


Method parameters


phone_number*string

Configurationobject

Additional configuration.

expiration_minutesint
localestring
enable_autofillboolean
autofill_session_duration_minutesnumber
import React, { useCallback } from 'react';
import { useStytch } from '@stytch/react';
export const Login = () => {
  const stytch = useStytch();
  const sendPasscode = useCallback(() => {
    stytch.otps.sms.send('+12025550162', {
      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": "phone-number-test-d5a3b680-e8a3-40c0-b815-ab79986666d0"
  }