Finish signing in with a two-factor code.
const url = 'https://api.tradr.cloud/api/auth/login/two-factor';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"challenge":"example","code":"example"}'};
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://api.tradr.cloud/api/auth/login/two-factor \ --header 'Content-Type: application/json' \ --data '{ "challenge": "example", "code": "example" }'Public. Answers the single-use challenge from a 202 login response with the current authenticator code or an unused backup code. On success the session cookie is set, exactly as a password-only login, and the body carries the signed-in user. Rate limited to 10 requests per 15 minutes per client, tightening to 5 while the shared rate-limit store is unavailable. A valid TOTP code and a backup code are each single-use. A wrong code is refused 400 INVALID_TWO_FACTOR_CODE and counts toward the per-address lock; an expired, already-used or over-attempted challenge is 400 CHALLENGE_EXPIRED; a locked address is refused 429 ACCOUNT_LOCKED with Retry-After. If the stored secret cannot be decrypted the step fails closed with 500 TWO_FACTOR_UNAVAILABLE and never falls back to the password alone.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The single-use challenge from the login 202 response.
A 6-digit authenticator code or a backup code.
Examplegenerated
{ "challenge": "example", "code": "example"}Responses
Section titled “ Responses ”The signed-in user. The session cookie is set.
object
object
Examplegenerated
{ "user": { "email": "hello@example.com", "emailVerified": true, "id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "isAdmin": true }}Validation error, CHALLENGE_EXPIRED (dead challenge), or INVALID_TWO_FACTOR_CODE (wrong code).
Rate limit exceeded, or the address is temporarily locked (ACCOUNT_LOCKED).
The stored two-factor secret could not be decrypted (TWO_FACTOR_UNAVAILABLE); sign-in fails closed.