Skip to main content
Docs

verifyTOTP()

Verify that the provided TOTP or backup code is valid for the user. Verifying a backup code will result it in being consumed (i.e. it will become invalid). Useful for custom auth flows and re-verification.

function verifyTOTP(params: VerifyTOTPParams): Promise<{ verified: true; code_type: 'totp' }>
  • Name
    userId
    Type
    string
    Description

    The ID of the user to verify the TOTP for.

  • Name
    code
    Type
    string
    Description

    The TOTP or backup code to verify

Note

Importing clerkClient varies based on your framework. Refer to the for usage details, including guidance on .

const userId = 'user_123'

const code = '123456'

const response = await clerkClient.users.verifyTOTP({
  userId,
  code,
})

Backend API (BAPI) endpoint

This method in the SDK is a wrapper around the BAPI endpoint POST/users/{user_id}/verify_totp. See the BAPI reference for more information.

Feedback

What did you think of this content?

Last updated on