curl -X POST 'https://api.weir.ai/auth/validate/registration' \
-H 'Content-Type: application/json' \
-d '{
"otpSession": "otp_session_123456789",
"otp": "123456"
}'
{
"data": {
"userId": "user_123456789",
"email": "john.doe@example.com",
"verified": true
},
"message": "Email verified successfully. You can now login.",
"status": "success"
}
Verify email with OTP to activate user account
curl -X POST 'https://api.weir.ai/auth/validate/registration' \
-H 'Content-Type: application/json' \
-d '{
"otpSession": "otp_session_123456789",
"otp": "123456"
}'
{
"data": {
"userId": "user_123456789",
"email": "john.doe@example.com",
"verified": true
},
"message": "Email verified successfully. You can now login.",
"status": "success"
}
curl -X POST 'https://api.weir.ai/auth/validate/registration' \
-H 'Content-Type: application/json' \
-d '{
"otpSession": "otp_session_123456789",
"otp": "123456"
}'
{
"data": {
"userId": "user_123456789",
"email": "john.doe@example.com",
"verified": true
},
"message": "Email verified successfully. You can now login.",
"status": "success"
}
400 Bad Request
{
"error": {
"code": "INVALID_OTP",
"message": "Invalid OTP code",
"details": "The provided OTP is incorrect"
},
"status": "error"
}
401 Unauthorized
{
"error": {
"code": "OTP_EXPIRED",
"message": "OTP has expired",
"details": "Please request a new OTP"
},
"status": "error"
}
const validateRegistration = async (otpSession, otp) => {
try {
const response = await fetch('https://api.weir.ai/auth/validate/registration', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ otpSession, otp })
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const data = await response.json();
return data.data;
} catch (error) {
console.error('Validation error:', error);
throw error;
}
};
// Usage
const verificationData = await validateRegistration('otp_session_123456789', '123456');
console.log('User verified:', verificationData.userId);
Was this page helpful?