Account

Two-factor authentication

Turn on an authenticator app or email codes, keep recovery codes, and meet the enrolment deadline.

A second factor asks for a code in addition to your password when you sign in. Turn it on from the Account security page in the dashboard, or with the /auth/mfa routes.

The factors

Second factors
FactorHow it works
Authenticator appA time-based code of 6 digits that changes every 30 seconds (RFC 6238). You scan a QR code or type the setup key into the app.
Email codesA code of 6 digits sent to your account email. It works once and expires after 10 minutes.
Recovery codes10 codes shown once when you turn a factor on. Each works once, if you cannot get a code from the other factors.

Turn it on

  1. Start enrolment with your password: POST /auth/mfa/enrol for the authenticator app or POST /auth/mfa/email/enrol for email codes. The authenticator route returns the secret and an otpauthUri; the email route sends a code and returns where it went.
  2. Confirm with your password and the first code: POST /auth/mfa/enable (field code) or POST /auth/mfa/email/enable (field code).
  3. If the other factor is already on, prove it in the same request, so a stolen session and password cannot add a factor. To add the authenticator while email codes are on, also send an emailCode or a recoveryCode. To add email codes while the authenticator is on, also send an authenticatorCode or a recoveryCode. Send one of the two, not both; without one the route answers 400. A wrong confirmation code when turning a factor on also answers 400, not 403. To get an emailed code for the first case, call POST /auth/mfa/email/step-up.
  4. Save the recovery codes in the response. They are shown once. If you already had a factor on, the response carries no new codes and the existing set stays valid.

Turning a factor on or off ends your other sessions

Enabling or disabling a factor signs out every other session and revokes your API tokens. The response carries a new access token for the session you are using. Create API tokens again afterwards.

Sign in with a second factor

  1. POST /auth/login answers mfaRequired: true with an mfaToken that is valid for 5 minutes.
  2. To get an email code, call POST /auth/mfa/email/send with the mfaToken. It answers 202 with the same message for every account, so it does not reveal whether email codes are on.
  3. Call POST /auth/mfa/verify with the mfaToken and exactly one of code (authenticator), recoveryCode or emailCode. The answer is the session, in the same shape as a normal sign-in.

Manage it

  • GET /auth/mfa returns the status: which factors are on, how many recovery codes remain, and the enrolment deadline.
  • POST /auth/mfa/recovery-codes replaces the recovery codes. The previous set stops working. It ends no session.
  • POST /auth/mfa/disable turns the authenticator off and POST /auth/mfa/email/disable turns email codes off. Email codes keep working after the authenticator is turned off, and the recovery codes go when the last factor is turned off.
  • Each of these needs your password and proof of a second factor: a current authenticator code or an unused recoveryCode. Turning email codes off, and replacing recovery codes while only email codes are on, also accept an emailCode, which you get from POST /auth/mfa/email/step-up with your password. An emailed code never replaces the authenticator: it is refused while the authenticator is on. Operator accounts use the authenticator app only.
  • A wrong code on one of these manage routes answers 403 and counts towards the same lockout as a wrong sign-in code. A locked account gets 429 and nothing is checked.

The enrolment deadline

Every account has a deadline by which a second factor must be on. A new account gets 30 days from when it was created. Accounts that existed before this rule got 30 days from the day it was introduced. Read your own deadline as requiredBy in GET /auth/mfa, together with the days left. After the deadline, an account without a second factor can reach only its account routes, the two-factor routes and sign-out. Every other route answers 403 with the code mfa_enrolment_required, for sessions and for API tokens alike. Turning a factor on lifts it at once.