Opt-in. A wallet with no active 2FA can withdraw without a code (subject
to the address whitelist and AML
checks). 2FA and the whitelist are independent — neither implies the other.
When it is enforced
The withdraw-time gate runs only when the platform has withdrawal-security enforcement enabled (a server-side flag, off by default during rollout) and the caller is not apartner_sso integration of an active partner (SSO partners
carry their own KYB-level controls and are exempt; the users of a partner that is
no longer active are not exempt). Setup/management endpoints below are always
available so a wallet can arm 2FA ahead of enforcement.
Endpoints
Mutating endpoints (
setup, confirm, disable) require the broad vault:write
scope. The narrow withdraw:write scope only grants withdrawal request and cancellation;
it does not permit 2FA or whitelist configuration. Multi-wallet partner keys
must also include the X-User-Wallet header naming the acting wallet.Setup flow
1
Begin setup
POST /api/me/withdrawal-security/totp/setup returns the provisioning URI,
the base32 secret, and ten one-time backup codes — shown once, never
again. The secret is stored pending (not yet active) and can be confirmed
for 15 minutes; running setup again replaces it and restarts the 15 minutes.Response
otpauthUri as a QR code for the user’s authenticator app, or show
secret for manual entry. Persist the backup codes somewhere safe — each
authorises exactly one withdrawal if the authenticator is lost.2
Confirm
POST /api/me/withdrawal-security/totp/confirm with the current 6-digit
code from the authenticator app activates 2FA. Backup codes are not accepted here —
you confirm with the authenticator you just scanned.Body
{ "configured": true }. A wrong code → 403 totp_invalid; if
there is no pending setup, or it is older than 15 minutes →
403 totp_setup_not_pending (with an API key,
once the owner’s-signature check is enforced, also a pending setup the
wallet owner did not make; see
Confirming a setup with an API key).setup while 2FA is already active is refused with
409 totp_already_configured — disable first (a hijacked session cannot
silently rotate the secret).
Using 2FA at withdraw time
When the wallet has 2FA active, includetotpCode in the withdraw request
(POST /api/withdrawals/request):
totpCode is a 6-digit TOTP or a 16-hex backup code. It is verified only
after every other compliance check passes, so a single-use code is never burned
on a withdrawal that would have been rejected anyway. Codes are single-use:
- A matched TOTP time-step is recorded with ±1 step (90s) tolerance, so the same code cannot be replayed on a second withdrawal — even under concurrent double-submit.
- A backup code is consumed atomically on first use.
Gate errors (403)
All are
403 (never 401) — the session is authenticated; only the second
factor failed.
Wrong-code lockout protection
To prevent automated brute-force attacks, code verifications (attotp/confirm,
at totp/disable, on a withdrawal, and on a whitelist change made with an API
key once the owner’s-signature check is enforced) are capped across three fixed
windows:
- 5 codes per 15 minutes
- 20 codes per 24 hours
- 40 codes per 7 days
totp/setup again does not clear the count. A totp/confirm with no
pending setup, or an expired one, is refused without counting. After a 15-minute
lock the pending setup has usually expired too: run totp/setup again.
A correct code entered before a lockout clears the counter. Staff identity reset
(adminReset) removes 2FA and resets the lockout counters for the user channel.
Lockouts are tracked per channel (user vs partner:<partnerId>), preventing
partner API keys from locking out retail users or vice versa.
Disabling and compliance holds
POST /api/me/withdrawal-security/totp/disable deletes 2FA but is a step-up:
it requires a valid current TOTP or backup code ({ "code": "123456" }), so a
hijacked session cannot silently remove the factor.
Compliance holds: During an active account suspension, moratorium, or withdrawal
hold, calling
totp/disable is blocked (403 ACCOUNT_PAUSED or 403 account_blocked)
because weakening account security during a hold is prohibited. However, totp/setup
and totp/confirm remain available (arms) so an account holder can always increase
their security.API-key callers
Amulti_wallet partner provisions 2FA per end-user wallet via X-User-Wallet
vault:write. The acting wallet must already exist on the platform — on the very first request for a freshly-seen wallet, setup may return409 account_provisioningwhile partner-backed onboarding finishes writing the user record. This is transient and converges in seconds.
Owner signature on changes made with an API key
A change to withdrawal security made with an API key (a partner API key,single_wallet or multi_wallet; self-service keys cannot make these
changes, as they cannot hold vault:write) carries the
wallet owner’s EIP-712 signature of that exact change, so the key alone
cannot control the protections that guard withdrawals against that same
key. It applies to POST …/totp/setup and POST …/totp/disable (and to
the whitelist writes).
POST …/totp/confirm needs none: it activates a pending secret. Once
enforcement is on, a key can confirm only a setup the wallet owner made (see
Confirming a setup with an API key).
Requests from a signed-in web session or a partner SSO session send nothing.
Once enforcement is on, a signature is accepted once; sign a new one (new
nonce) for every change. In observation mode the nonce is not spent, but
send a fresh signature per change anyway. The signer is the wallet itself (an externally owned account, as
for the withdrawal signature).
Once enforcement is on, a key’s change is refused with:
On a signed request the route’s own refusals (
409 totp_already_configured
on setup; 403 totp_not_configured and the lockout 429 on disable) are
answered before the signature is spent. On disable the code in the body is
checked after the signature is spent, so a wrong code needs a new signature.
Confirming a setup with an API key
Once enforcement is on,POST …/totp/confirm made with an API key activates
only a pending setup that the wallet owner made: one started from a signed-in
web session or a partner SSO session, or a totp/setup sent through the key
with the owner’s signature while enforcement is on. Any other pending setup
is answered 403 totp_setup_not_pending, the same code as “nothing
pending”, before the code is checked: a setup started with the key alone, and
also a setup sent through the key in observation mode, even with a valid
signature (observation mode does not spend the nonce, so it does not count as
the owner’s proof). Start the setup again (with the owner’s signature), then
confirm the new secret. A signed-in web or partner SSO session can confirm
any pending setup. In observation mode nothing is refused here.
Change notices
Every change that takes effect, on any channel, sends the wallet owner a Withdrawal security changed notice: 2FA turned on (totp/confirm) or
turned off. It says whether the change was made in the app, in a partner app
session or with an API key, and asks the owner to contact support if it was
not them. It is a service notice: delivered in-app, by push and by e-mail
regardless of notification settings (a wallet with no e-mail address gets
it in-app and by push only). totp/setup alone, a refused change and a staff 2FA reset send none.
The notice is best-effort; the change stands if it cannot be delivered.
Next
Address whitelist
Restrict withdrawals to pre-approved destinations.
Withdrawals overview
The full dual-sig withdrawal flow.
Error codes
Every withdrawal-security code in one table.
State machine
All states and transitions.