/
Contact usSee pricingStart building
    Introduction
    Overview
    Postman
    Organizations
      Organization object
      Create an organization
      Get an organization
      Update an organization
      Search for organizations
      Delete an organization
    Members
      Member object
      Create a Member
      Get a Member
      Get a Member (Dangerous)
      Update a Member
      Reactivate a Member
      Search for Members
      Unlink Retired Email
    • Delete

      • Delete a Member
        Delete Member password
        Delete Member MFA phone number
        Delete Member MFA TOTP
    RBAC
      Resource object
      Role object
      Scope object
      Get RBAC Policy
    Email magic links
    • Organization

      • Send login or signup email
        Send invite email
        Authenticate Magic Link
    • Discovery

      • Send discovery email
        Authenticate discovery Magic Link
    Email one-time passcodes (OTP)
    • Organization

      • Send login or signup OTP
        Authenticate OTP
    • Discovery

      • Send discovery OTP
        Authenticate discovery OTP
    OAuth
    • Discovery

      • Use Google for discovery
        Use Microsoft for discovery
        Use HubSpot for discovery
        Use Slack for discovery
        Use GitHub for discovery
        Authenticate discovery OAuth
    • Organization

      • Login with Google
        Login with Microsoft
        Login with HubSpot
        Login with Slack
        Login with GitHub
        Authenticate OAuth
    • Token

      • Get Google Access Token
        Get Microsoft Access Token
        Get HubSpot Access Token
        Get Slack Access Token
        Get GitHub Access Token
    Session management
      Session object
      Get JWKS
      Get Session
      Authenticate Session
      Exchange Session
      Revoke Session
      Migrate Session
    Single sign-on (SS0)
      SAML Connection object
      OIDC Connection object
      External Connection object
    • SAML

      • Create SAML Connection
        Update SAML Connection
        Update SAML Connection by Metadata URL
        Delete SAML Verification Certificate
    • OIDC

      • Create OIDC Connection
        Update OIDC Connection
        Get OIDC Access Token
    • External

      • Create External Connection
        Update External Connection
    • Shared

      • Get SSO Connections
        Delete SSO Connection
        Start SSO Authenticate
        Complete SSO Authenticate
    SCIM
      SCIM Connection Object
    • Connection management

      • Create SCIM Connection
        Update SCIM Connection
        Delete SCIM Connection
        Get SCIM Connection
    • Token management

      • Start SCIM Token Rotation
        Complete SCIM Token Rotation
        Cancel SCIM Token Rotation
    • SCIM groups

      • Get SCIM Connection Groups
    Discovery
      Discovered Organization object
      Create Organization via Discovery
      List Organizations
      Exchange Intermediate Session
    Passwords
      Authenticate
      Discovery Authenticate
      Strength check
      Migrate
    • Reset Options

      • Password reset by email start
        Password reset by email
        Password reset by existing password
        Password reset by session
        Discovery Password reset by email start
        Discovery Password reset by email
        Require Password reset by email
    Multi-Factor Authentication (MFA)
    • One-time passcodes

      • Send SMS OTP
        Authenticate SMS OTP
    • Time-based one-time passcodes

      • Create TOTP
        Authenticate TOTP
        Migrate TOTP
    • Recovery codes

      • Get recovery codes
        Recover
        Rotate recovery codes
    M2M Authentication
      M2M Client Object
    • TOKEN

      • Get Access Token
        Authenticate Access Token
    • M2M Client

      • Create M2M client
        Get M2M client
        Search M2M clients
        Update M2M client
        Delete M2M client
    • Rotate secret

      • Start secret rotation
        Rotate secret
        Cancel secret rotation
    Connected AppsBeta
      Get Access Token
    • Tokens

      • Connected App ID Token Object
        Connected App Access Token Object
    • Configuration

      • Get JWKS
        Get OpenID Configuration
    • Methods

      • Introspect Token
        Authenticate Access Token (Local)
        Exchange Access Token
        Revoke Token
        Get UserInfo
    Impersonation
      Authenticate Token
    Resources
      Organization authentication settings
      Common email domains
      Member states
      Email templates
      URL validation
      Metadata
      SAML overview
      SAML Certificates
    Errors
      Overview
      Error object
      400
      401
      403
      404
      405
      429
      499
      500
      503
Get support on SlackVisit our developer forum

Contact us

B2B Saas Authentication

/

API reference

/

Multi-Factor Authentication (MFA)

/

One-time passcodes

/

Send SMS OTP

Send SMS OTP

POST
https://test.stytch.com/v1/b2b/otps/sms/send

Send a One-Time Passcode (OTP) to a Member's phone number.

If the Member already has a phone number, the mfa_phone_number field is not needed; the endpoint will send an OTP to the number associated with the Member. If the Member does not have a phone number, the endpoint will send an OTP to the mfa_phone_number provided and link the mfa_phone_number with the Member.

An error will be thrown if the Member already has a phone number and the provided mfa_phone_number does not match the existing one.

OTP codes expire after two minutes. Note that sending another OTP code before the first has expired will invalidate the first code.

If a Member has a phone number and is enrolled in MFA, then after a successful primary authentication event (e.g. email magic link or SSO login is complete), an SMS OTP will automatically be sent to their phone number. In that case, this endpoint should only be used for subsequent authentication events, such as prompting a Member for an OTP again after a period of inactivity.

Passing an intermediate session token, session token, or session JWT is not required, but if passed must match the Member ID passed.

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.

Even when international SMS is enabled, we do not support sending SMS to countries on our Unsupported countries list.

Note: SMS to phone numbers outside of the US and Canada is disabled by default for customers who did not use SMS prior to October 2023. If you're interested in sending international SMS, please reach out to support@stytch.com.


Body parameters


organization_id* string

member_id* string

mfa_phone_number string

locale string

intermediate_session_token string

session_token string

session_jwt string

Response fields


request_id string

status_code int

member_id string

member object

organization object
const stytch = require('stytch');

const client = new stytch.B2BClient({
  project_id: 'PROJECT_ID',
  secret: 'SECRET',
});

const params = {
  organization_id: "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
  member_id: "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
};

client.otps.sms.send(params)
  .then(resp => { console.log(resp) })
  .catch(err => { console.log(err) });
RESPONSE
200
​
{
    "status_code": 200,
    "request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
    "member_id": "member-test-32fc5024-9c09-4da3-bd2e-c9ce4da9375f",
    "member": {...},
    "organization": {...}
}

Common Error Types

  • action_available_only_for_active_members
  • duplicate_member_phone_number
  • duplicate_member_phone_number_for_member
  • invalid_phone_number
  • invalid_phone_number_country_code
  • secondary_factor_not_found