Two-factor
Authenticator app (TOTP), email codes and backup codes as a second step.
Use this endpoint to get the TOTP URI
application/json- body
password?stringUser password
Successful response
application/json- response
totpURI?stringcurl -X POST 'https://auth.example.com/api/auth/two-factor/get-totp-uri' \ -H 'Content-Type: application/json' \ -d '{}'{ "totpURI": "string"}Verify two factor TOTP
application/json- body
code*stringThe otp code to verify. Eg: "012345"
trustDevice?booleanIf true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. Eg: true
Successful response
application/json- response
status?booleancurl -X POST 'https://auth.example.com/api/auth/two-factor/verify-totp' \ -H 'Content-Type: application/json' \ -d '{ "code": "string"}'{ "status": true}Send two factor OTP to the user
application/json- body
trustDevice?booleanSuccessful response
application/json- response
status?booleancurl -X POST 'https://auth.example.com/api/auth/two-factor/send-otp' \ -H 'Content-Type: application/json' \ -d '{}'{ "status": true}Verify two factor OTP
application/json- body
code*stringThe otp code to verify. Eg: "012345"
trustDevice?booleanTwo-factor OTP verified successfully
application/json- response
token*stringSession token for the authenticated session
user*The authenticated user object
curl -X POST 'https://auth.example.com/api/auth/two-factor/verify-otp' \ -H 'Content-Type: application/json' \ -d '{ "code": "string"}'{ "token": "string", "user": { "id": "string", "email": "user@example.com", "emailVerified": true, "name": "string", "image": "http://example.com", "createdAt": "2019-08-24T14:15:22Z", "updatedAt": "2019-08-24T14:15:22Z" }}Verify a backup code for two-factor authentication
application/json- body
code*stringA backup code to verify. Eg: "123456"
disableSession?booleanIf true, the session cookie will not be set.
trustDevice?booleanIf true, the device will be trusted for 30 days. It'll be refreshed on every sign in request within this time. Eg: true
Backup code verified successfully
application/json- response
user*The authenticated user object with two-factor details
session*The current session object, included unless disableSession is true
curl -X POST 'https://auth.example.com/api/auth/two-factor/verify-backup-code' \ -H 'Content-Type: application/json' \ -d '{ "code": "string"}'{ "user": { "id": "string", "email": "user@example.com", "emailVerified": true, "name": "string", "image": "http://example.com", "twoFactorEnabled": true, "createdAt": "2019-08-24T14:15:22Z", "updatedAt": "2019-08-24T14:15:22Z" }, "session": { "token": "string", "userId": "string", "createdAt": "2019-08-24T14:15:22Z", "expiresAt": "2019-08-24T14:15:22Z" }}Generate new backup codes for two-factor authentication
application/json- body
password?stringThe users password.
Backup codes generated successfully
application/json- response
status*trueIndicates if the backup codes were generated successfully
truebackupCodes*array<string>Array of generated backup codes in plain text
curl -X POST 'https://auth.example.com/api/auth/two-factor/generate-backup-codes' \ -H 'Content-Type: application/json' \ -d '{}'{ "status": true, "backupCodes": [ "string" ]}Enable two factor authentication. Pass method 'totp' (default) to set up an authenticator app (returns TOTP URI and backup codes), or 'otp' to enable email/SMS-based codes immediately.
application/json- body
password?stringUser password
method?string"otp""totp"issuer?stringCustom issuer for the TOTP URI
Successful response
application/json- response
method*stringThe 2FA method that was enabled.
"otp""totp"totpURI?stringTOTP URI for authenticator app setup. Only present when method is 'totp'.
backupCodes?array<string>Recovery backup codes. Only present when method is 'totp'.
curl -X POST 'https://auth.example.com/api/auth/two-factor/enable' \ -H 'Content-Type: application/json' \ -d '{}'{ "method": "otp", "totpURI": "string", "backupCodes": [ "string" ]}Use this endpoint to disable two factor authentication.
application/json- body
password?stringUser password
Successful response
application/json- response
status?booleancurl -X POST 'https://auth.example.com/api/auth/two-factor/disable' \ -H 'Content-Type: application/json' \ -d '{}'{ "status": true}