Skip to main content
This page covers the integration of the OTPless Headless Web SDK. The SDK accepts the requestId generated by the Create API, performs the authentication, and reports progress through events. Your backend confirms the final result via the Status Check API.

Step 1: Install the SDK

Install the OTPless Headless SDK with your favorite package manager:
Check the latest version of the SDK on npm.
Make sure your authentication channel is enabled on the OTPLESS dashboard.

Step 2: Initialize the SDK

Initialize the SDK with your App ID and subscribe to its events. The useOTPless() hook is available for React; for any other framework, use the otpless object.
Replace YOUR_APP_ID with your actual App ID from the OTPLESS dashboard. For the Next.js App Router, add 'use client'; at the top of the component file.
Initialization is not reported as an event. In React, gate on the ready flag returned by useOTPless(); elsewhere, await otpless.init() before calling initiate(). A failed initialization arrives on FAILED with statusCode 5003.

Step 3: Initiate authentication with the requestId

Call initiate() with your normal authentication payload — channel plus the user’s phone/countryCode or email — and append the requestId returned by the Create API.
The requestId is appended to your usual payload — it does not replace any field. Keep sending channel and the identity exactly as you do for a standard headless integration.
Send the same identity you passed to the Create API. The server resolves the identity bound to the requestId and uses that one, so if the two disagree the requestId silently wins and the number you passed is ignored.
Start polling the Status Check API from your backend immediately after calling initiate(). The SDK events and the server status run in parallel.

Step 4: Handle events

Response type

initiate() and every event deliver an OTPlessResponse:

Event reference

These are the responseType values the Web SDK delivers to your callback. | OTP_AUTO_READ | Non-terminal | Mobile browsers only, OTP channels only — the OTP was read automatically. Optional to handle. |
Readiness is not an event on the web. Unlike the Android and iOS SDKs, the Web SDK emits no SDK_READY callback — check initialization with isReady() on the script tag, or the ready flag / await init() on npm. There is likewise no separate AUTH_TERMINATED event; terminal authentication failures arrive on FAILED.
This table covers the events relevant to the server-initiated flow. For the Web SDK’s full event and method surface, see the Headless Web SDK reference.
FAILED is a terminal failure. Always treat the Status Check API result as authoritative.
For the errorCode / statusCode values surfaced in SDK events, see SDK Error Codes.

Next step

Status Check API

Confirm the authoritative auth status from your server.