Skip to content

Two-factor codes (TOTP)

Testing a login that requires a time-based one-time code usually means either disabling two-factor in test environments or scraping a phone. mailcatchr stores the authenticator instead and hands your test the current code.

Open Tools → Authenticators → Add authenticator. Pick a tab: QR code to upload, drop or paste a screenshot of the setup QR code the application shows when enabling two-factor, Setup link to paste its otpauth:// URL, or Secret key to type the base32 secret shown under the QR code and give it a name. The QR image is decoded in your browser and is not uploaded. The workspace now owns an authenticator that produces the same codes a phone app would.

Each authenticator has an id, shown with a copy button when it is registered and on its row in the list. That id is the {totpId} in the request below.

GET /v1/totp/{totpId}/code
{ "code": "482910", "expiresAt": "2026-09-20T09:41:30+00:00", "expiresInSeconds": 18 }

If expiresInSeconds is small, the next code may be what the application expects by the time your form submits. Waiting it out is simpler than handling the edge: sleep for expiresInSeconds + 1 and fetch again.

const totp = await mc.totps.code(authenticatorId);
await page.fill('input[name="otp"]', totp.code);

The key must include the authenticator in its authenticator scope. A key that does not gets 404. See API keys and scopes.

Plan Authenticators
Free 1
Business 250