Logout
Endpoint: /action/logout
Terminates the currently active WalletTwo user session and notifies the host page. Use this action when your application needs to trigger a WalletTwo sign-out as part of your own sign-out flow — for example, when the user logs out of your platform and you want to clean up the embedded wallet session at the same time.
Required user state
User is logged in
LoggedMiddleware
/auth/login
Email is verified
EmailVerifiedMiddleware
/auth/email/verify
Wallet is created
WalletMiddleware
/auth/wallet/register
Iframe URL
https://<WALLETTWO_ORIGIN>/action/logout?iframe=trueOptional parameters:
redirect_uri
No
string (absolute URL)
If provided, the iframe navigates here after logout completes
iframe
Yes (for embedding)
"true"
Activates bare rendering mode
Full example:
https://<WALLETTWO_ORIGIN>/action/logout?iframe=true&redirect_uri=https%3A%2F%2Fexample.com%2Fsigned-outWhat happens when the action runs
On mount,
logout()is called immediately (no user confirmation prompt).Regardless of whether logout succeeds or fails,
window.parent.postMessage(...)is fired.If
redirect_uriis present, the iframe navigates to that URL.While waiting, a centered loading spinner is shown.
The logout always completes silently from the user's perspective. Errors are logged to the browser console only.
postMessage event
Fired to window.parent after the logout attempt finishes (whether it succeeded or failed):
event
Always "wallet_logout"
type
Always "wallet_logout" (legacy alias, same value)
There is no success/failure distinction in the event. If your application needs to confirm the logout actually succeeded, use the redirect_uri path together with a server-side session check.
redirect_uri callback
The iframe navigates to redirect_uri with no additional query params appended:
Host page integration
Option A: postMessage only
Option B: redirect_uri
If you prefer not to use postMessage, pass a redirect_uri to your own page and handle the arrival there:
When the iframe lands on https://example.com/logout-complete, your server can clear the session cookie and redirect the top-level page as needed.
Triggering logout programmatically from the parent page
You can create the logout iframe dynamically when a user signs out of your platform, without keeping it in the DOM at all times:
Notes
The action logs out the user immediately on mount without any confirmation step. Do not navigate to this route unless you intend to end the session.
Logout errors are swallowed silently in the UI. Even if the server-side logout call fails, the
wallet_logoutevent is still fired.After logout, if the user navigates to any
/action/*or/wallet/*route, they will be redirected to/auth/loginbyLoggedMiddleware.
Last updated