OTPless Passkey API Integration Guide
This document is designed to assist merchants in integrating the OTPless Passkey API to create user identities and initiate Passkey-based login through the OTPless SDK. Passkey provides secure, device-based authentication for end users, enhancing both security and user experience.
Prerequisite
Login on OTPless.com
Log in using your work email.
Navigate to Dev Settings
Once logged in, navigate to Dev Settings in the left menu.
Copy Credentials
Copy the clientId
, clientSecret
, and appId
.
Contact OTPless Team
Please contact the OTPless team to activate passkey functionality for your account.
Workflow
Initialize Passkey Identity
Use the initiate WebAuthn API to create the requestId
.
Initiate Login via SDK
Pass the requestId
to the OTPless SDK, which will handle the Passkey-based login flow.
Complete Authentication
The OTPless SDK validates the user’s authentication and notifies your system upon successful login or registration, providing a token.
Validate the Token
Use the validate token API to verify the authentication token.
Demo Link: Passkey Demo
1. Initiate API
The OTPless Passkey initiate API allows merchants to generate requestId
for a particular user identity.
API Endpoint
POST
https://auth.otpless.app/auth/v1/webauthn
Headers
Unique identifier for the merchant’s application.
Secret key associated with the clientId
.
Specifies JSON format.
Body
The request body must be a JSON object with the following fields:
Specifies the type of identity. Options: PHONE_NUMBER
, EMAIL
, CUSTOM
.
The actual value for the specified identityType
, e.g., the user’s phone number, email address, or user ID.
The name of the Relying Party (merchant) initiating the WebAuthn request.
The merchant’s application domain where Passkey is implemented.
The display name of the user initiating the request, typically used for personalization purposes.
Specifies the attachment type. Options: ALL
, PLATFORM
, CROSS_PLATFORM
. If isSPC
is true, this will always be set to PLATFORM
.
ALL
: The user has the option to authenticate with either a QR code (if the key is stored on a different device) or with the key stored on the same device.PLATFORM
: The user can authenticate only if the key is stored on the same device.CROSS_PLATFORM
: The user can authenticate only by scanning a QR code to use a key stored on another device.
Indicates whether the request is for a registration flow (true
). Don’t pass this key if you want a normal login or registration flow. Useful in case you want to enforce registration (for example: Registration of a new device).
Indicates if Secure Payment Confirmation (SPC) is required.
Secure Payment Confirmation details (required if isSPC
is true).
If
isSPC
is true, thespc
object is mandatory, otherwise it can be omitted.
Response
A unique identifier for the session initiation request.
Sample
Error Codes
The following error codes and responses help merchants handle errors during integration:
Status Code | Message | Error Code | Description | Solution |
---|---|---|---|---|
400 | Bad Request | 7134 | Invalid syntax or missing parameters for RP name | Verify the rpName format and ensure it’s valid. |
400 | Bad Request | 7135 | Invalid domain | Check and correct the domain parameter. |
400 | Bad Request | 7131 | Invalid identity type | Ensure identityType is PHONE_NUMBER , EMAIL , or CUSTOM . |
400 | Bad Request | 7133 | Invalid identity value | Verify the format and value of identityValue . |
400 | Bad Request | 7140 | spc object missing or invalid when isSPC is true | Ensure spc object is provided and valid if isSPC is true. |
401 | Unauthorized | - | Invalid or missing authentication credentials | Confirm clientId and clientSecret are valid. |
403 | Forbidden | - | Insufficient permissions | Check if the API key has the required permissions. |
404 | Not Found | - | Endpoint URL typo or resource does not exist | Verify the endpoint URL and resource. |
429 | Too Many Requests | - | Exceeding API rate limits | Reduce request frequency or use exponential backoff. |
500 | Internal Server Error | - | Server issues | Retry. Contact support if the issue persists. |
503 | Service Unavailable | - | Server overload or maintenance | Retry after a delay. Check the Status Page for issues. |
2. Initiate OTPless SDK with requestId
To initiate the OTPless SDK, include the following code snippet on your web page to load the SDK and use it to trigger the passkey authentication flow.
Step 1: Include the OTPless SDK Script
Replace
YOUR_APP_ID
with your actual application ID.
Step 2: Define the Callback Function
The callback function is used to handle the response after authentication. This function will receive user information and can be used to implement any custom logic.
Step 3: Initiate Passkey with requestId
Below is the code to initiate the Passkey flow using the OTPless SDK with a specific requestId
obtained from the identity creation API.
In this code:
- The
channel
is set to"WEB_AUTHN"
. - Replace
"unique_request_id"
with the actualrequestId
obtained from the initiate API. - Use the
initiate
method from the OTPless SDK to trigger the authentication flow.
3. Validate Token API
This endpoint validates an authentication token and retrieves user identity, authentication status, network, and device information associated with the token.
API Endpoint
POST
https://auth.otpless.app/auth/v1/validate/token
Headers
Unique identifier for the merchant’s application.
Secret key associated with the clientId
.
Specifies JSON format.
Body
The authentication token to be validated.
Response
The validated token.
Status of the validation, e.g., “SUCCESS”.
Unique identifier for the user.
The timestamp when the validation occurred.
List of user identity objects.
Network details of the user’s location.
Information about the user’s device, browser, and connection.
Sample
Was this page helpful?