Skip to content
These docs describe Tradr v0.17.0. Running an older release? Check the release notes for what changed.

Finish signing in with a two-factor code.

POST
/api/auth/login/two-factor
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.

Media typeapplication/json
object
challenge
required

The single-use challenge from the login 202 response.

string
/^[0-9a-f]{64}$/
code
required

A 6-digit authenticator code or a backup code.

string
>= 6 characters <= 20 characters
Examplegenerated
{
"challenge": "example",
"code": "example"
}

The signed-in user. The session cookie is set.

Media typeapplication/json
object
user
object
email
string format: email
emailVerified
boolean
id
string format: uuid
isAdmin
boolean
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.