Login or Create User by SMS

POST /v1/auth/otps/sms/login_or_create

Create an SMS OTP (one-time passcode) to the provided phone number for login verification. If no user account exists for the provided phone number, a new user will be created and OTP sent by SMS.

HTTP Request

POST /v1/auth/otps/sms/login_or_create

Returns

A successful response returns an object with user_id, user_created indicating if the user has been newly created, and phone_number_id properties.

application/json

Body

  • phone_number string Required

    E.164 formatted mobile phone number that uniquely identifies the user.

    Minimum length is 1.

  • expires_in number

    Expiration time of the OTP in minutes. Must be between 1 to 10 minutes, defaults to 1 minute.

  • requires_verification boolean

    Determines if verification for the authentication method (email, phone_number) is required before marking the user as active.

  • device_fingerprint object

    Device fingerprinting metadata for fraud detection during verification step. This is useful to ensure that the user who originated the request matches the user that verifies the token. Verification requirements can be enabled in the Verify OTP step by matching fields in the device_fingerprint such as IP, User Agent or the combination of them (more fraud detection features coming soon!)

    Hide device_fingerprint attributes Show device_fingerprint attributes object
    • ip string

      IP of the user originating the request.

    • user_agent string

      User Agent of the browser originating the request.

Responses

  • 200 application/json

    OK

    Hide response attributes Show response attributes object
    • phone_number_id string Required

      Minimum length is 1.

    • user_created boolean Required
    • user_id string Required

      Minimum length is 1.

    • status string Required
POST /v1/auth/otps/sms/login_or_create
curl \
 --request POST 'https://api.streambird.io/v1/auth/otps/sms/login_or_create' \
 --header "Authorization: Bearer $ACCESS_TOKEN" \
 --header "Content-Type: application/json" \
 --data '{"expires_in":3,"phone_number":"+14152222222"}'
Request example
{
  "expires_in": 3,
  "phone_number": "+14152222222"
}
Response examples (200)
{
  "status": "pending",
  "user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
  "user_created": false,
  "phone_number_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy"
}