API reference
Flows
Functions
User
export
Embedded Recovery Flow (V2)executeEmbeddedRecoveryFlowV2 drives a step-by-step account recovery flow (e.g., password reset) without a browser redirect.Parameters
config.urlrequiredstringFull endpoint URL. Mutually exclusive with `baseUrl`
config.baseUrlrequiredstringThunderID base URL
config.payloadrequiredEmbeddedRecoveryFlowRequestV2Flow request body
config.payload.applicationIdoptionalstringApplication ID. Required for the first step
config.payload.flowTypeoptionalstringRecovery flow type (e.g., `'PASSWORD_RECOVERY'`). Required for first step
config.payload.executionIdoptionalstringExecution ID from a prior response
config.payload.actionoptionalstringAction to take at the current step
config.payload.inputsoptionalRecordStep input fields
config.payload.challengeTokenoptionalstringChallenge token from a prior step
Example
import { executeEmbeddedRecoveryFlowV2, EmbeddedRecoveryFlowStatusV2 } from '@thunderid/javascript'
// Step 1 — Initiate recovery
const step1 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
applicationId: '<your-app-id>',
flowType: 'PASSWORD_RECOVERY',
},
})
// Step 2 — Provide the username/email to recover
const step2 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step1.executionId,
inputs: {
username: 'user@example.com',
},
},
})
// Step 3 — Submit the OTP/token received by email
const step3 = await executeEmbeddedRecoveryFlowV2({
baseUrl: 'https://localhost:8090',
payload: {
executionId: step2.executionId,
inputs: {
otp: '123456',
},
challengeToken: step2.challengeToken,
},
})
if (step3.flowStatus === EmbeddedRecoveryFlowStatusV2.Complete) {
// Recovery complete — prompt user for new password
}