/api/auth/two-factor/verify-backup-code
const url = 'https://example.com/api/auth/two-factor/verify-backup-code';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"code":"example","disableSession":true,"trustDevice":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://example.com/api/auth/two-factor/verify-backup-code \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "code": "example", "disableSession": true, "trustDevice": true }'Verify a backup code for two-factor authentication
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
A backup code to verify. Eg: “123456”
If true, the session cookie will not be set.
If true, the device will be trusted for 30 days. It’ll be refreshed on every sign in request within this time. Eg: true
Examplegenerated
{ "code": "example", "disableSession": true, "trustDevice": true}Responses
Section titled “Responses”Backup code verified successfully
object
The authenticated user object with two-factor details
object
Unique identifier of the user
User’s email address
Whether the email is verified
User’s name
User’s profile image URL
Whether two-factor authentication is enabled for the user
Timestamp when the user was created
Timestamp when the user was last updated
The current session object, included unless disableSession is true
object
Session token
ID of the user associated with the session
Timestamp when the session was created
Timestamp when the session expires
Examplegenerated
{ "user": { "id": "example", "email": "hello@example.com", "emailVerified": true, "name": "example", "image": "https://example.com", "twoFactorEnabled": true, "createdAt": "2026-04-15T12:00:00Z", "updatedAt": "2026-04-15T12:00:00Z" }, "session": { "token": "example", "userId": "example", "createdAt": "2026-04-15T12:00:00Z", "expiresAt": "2026-04-15T12:00:00Z" }}Bad Request. Usually due to missing parameters, or invalid parameters.
object
Examplegenerated
{ "message": "example"}Unauthorized. Due to missing or invalid authentication.
object
Examplegenerated
{ "message": "example"}Forbidden. You do not have permission to access this resource or to perform this action.
object
Examplegenerated
{ "message": "example"}Not Found. The requested resource was not found.
object
Examplegenerated
{ "message": "example"}Too Many Requests. You have exceeded the rate limit. Try again later.
object
Examplegenerated
{ "message": "example"}Internal Server Error. This is a problem with the server that you cannot fix.
object
Examplegenerated
{ "message": "example"}