Authenticate a TOTP code entered by a user.
Authenticate TOTP
POST
https://test.stytch.com/v1/totps/authenticateBody parameters
user_id* string
totp_code* string
session_custom_claims map<string, any>
session_duration_minutes int
session_jwt string
session_token string
Response fields
status_code int
request_id string
totp_id string
session object
session_jwt string
session_token string
user object
user_id string
const stytch = require('stytch');
const client = new stytch.Client({
project_id: 'PROJECT_ID',
secret: 'SECRET',
});
const params = {
user_id: "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6",
totp_code: "576831",
session_duration_minutes: 60,
};
client.totps.authenticate(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
RESPONSE
200
{
"status_code": 200,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"totp_id": "totp-test-41920359-8bbb-4fe8-8fa3-aaa83f35f02c",
"session": "{...}",
"session_token": "mZAYn5aLEqKUlZ_Ad9U_fWr38GaAQ1oFAhT8ds245v7Q",
"session_jwt": "eyJ...",
"user": {...},
"user_id": "user-test-16d9ba61-97a1-4ba4-9720-b03761dc50c6"
}