//Passwordless Login

Passwordless Login with OTP

This tutorial demonstrates how to implement a passwordless login flow using a one-time password (OTP) sent to either the user's email address or phone number.

Flow 1: Email OTP Login

#### Step 1: Request an OTP via Email

Endpoint: POST /login_otp

Input: ~~~json { "email": "test.user@example.com", "app_uuid": "" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/api/auth/otp -H "Content-Type: application/json" -d '{ "email": "test.user@example.com", "app_uuid": "" }' ~~~

Output: ~~~json "email sent successfully" ~~~

#### Step 2: Verify the Email OTP

Endpoint: POST /api/auth/otp/verify

Input: ~~~json { "email": "test.user@example.com", "otp": "123456", "app_uuid": "" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/api/auth/otp_verify -H "Content-Type: application/json" -d '{ "email": "test.user@example.com", "otp": "123456", "app_uuid": "" }' ~~~

Output: ~~~json { "token": "jwt_token..." } ~~~

Flow 2: Phone OTP Login

#### Step 1: Request an OTP via SMS

Endpoint: POST /api/auth/phone/otp

Input: ~~~json { "phone": "+15551234567", "app_uuid": "" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/api/auth/phone/otp -H "Content-Type: application/json" -d '{ "phone": "+15551234567", "app_uuid": "" }' ~~~

Output: ~~~json { "status": "sms sent succesfully" } ~~~

#### Step 2: Verify the Phone OTP

Endpoint: POST /api/auth/phone/otp/verify

Input: ~~~json { "phone": "+15551234567", "otp": "123456", "app_uuid": "" } ~~~

~~~bash curl -X POST https://api.buttrbase.com/api/auth/otp_phoneverify -H "Content-Type: application/json" -d '{ "phone": "+15551234567", "otp": "123456", "app_uuid": "" }' ~~~

Output: ~~~json { "token": "jwt_token..." } ~~~