Verify OTP (One-time passcode)
Verify an OTP (one-time passcode) against a method ID (email, phone number) to authenticate the user. This endpoints verifies that the OTP sent in is valid for the given method ID.
HTTP Request
POST /v1/auth/otps/verify
Returns
A successful response returns an object with method_id, method_type, and verified user_id properties.
Body
-
Method ID to verify the OTP against. This can either be the
phone_number_idoremail_idreturned by the send or login or create endpoints.Minimum length is
1. -
OTP received by the User.
Minimum length is
1. -
Device fingerprinting metadata for fraud detection during OTP code 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 by matching fields in the
device_fingerprintsuch as IP, User Agent or the combination of them (more fraud detection features coming soon!) -
OptionalExtend the session expiration time to N minutes from now, must be between 5 to 525600 minutes (365 days). This parameter will create a new session if there is no existing session along with asession_tokenandsession_jwt. However, if a validsession_tokenorsession_jwtis sent in, it will extend that session by the minutes specified. If not sent in, no session will be created by default. -
OptionalUnique session token to verify. -
OptionalUnique Session JWT to verify.
curl \
--request POST 'https://api.streambird.io/v1/auth/otps/verify' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"otp":"829994","method_id":"pn_24oXBLRv6BoHXbNZoTAZkAFlRsy","device_fingerprint":{"ip":"123.2.1.1"},"session_expires_in":100}'
{
"otp": "829994",
"method_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"device_fingerprint": {
"ip": "123.2.1.1"
},
"session_expires_in": 100
}
{
"session": {
"id": "sess_24tZ6tlJ7CxlTwB6Zoj6SHQ9vU3",
"factors": [
{
"type": "otp",
"method": {
"method_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"method_type": "phone_number",
"phone_number": "+14152222222",
"phone_number_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"last_verified_at": 1643496805
},
"delivery_channel": "sms"
}
],
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"created_at": 1643496805,
"expires_at": 1643502805,
"started_at": 1643496805,
"updated_at": 1643496805,
"session_token": "7hssInGtOjKGUh8w7T4NjgLIKKSw6UdZ8uOduBYmJzrtfV6GrNtaUYoGehRS6jBh",
"last_active_at": 1643496805,
"device_fingerprint": {
"ip": "123.2.1.1",
"user_agent": ""
}
},
"user_id": "user_24wFP9pDa9YiMJLun94iKykoZs2",
"method_id": "pn_24oXBLRv6BoHXbNZoTAZkAFlRsy",
"method_type": "phone_number",
"session_token": "7hssInGtOjKGUh8w7T4NjgLIKKSw6UdZ8uOduBYmJzrtfV6GrNtaUYoGehRS6jBh"
}