---
title: "Switch an in-progress login challenge to a different enrolled mechanism."
method: POST
path: "/api/v1/tokens/two-factor/switch-mechanism"
tags: ["Public"]
---

# Switch an in-progress login challenge to a different enrolled mechanism.

`POST /api/v1/tokens/two-factor/switch-mechanism`

## Request

- Base URL: `https://go.outseta.com`
- URL: `https://go.outseta.com/api/v1/tokens/two-factor/switch-mechanism`
- Auth: none declared

When a user has more than one method enrolled (see
`available_mechanisms` on the login response) they can switch the
active challenge — for example from `Totp` to `Email` when they have
lost access to their authenticator. Post the current challenge token
and the desired mechanism:
            
    { "challenge_token": "eyJ...", "mechanism": "Email" }
            
A fresh challenge for that mechanism is returned (and, for `Email`, a
code is sent), in the same shape as the `202` from `POST /api/v1/tokens`
minus `two_factor_required`. An unrecognized mechanism returns `400`
(`invalid_mechanism`); a mechanism the user has not enrolled returns
`400` (`not_enrolled`). Rate limited to 5 requests per minute (`429`).

## Query parameters

- `data` unknown, required

## Response `200`

The challenge was reissued for the requested mechanism.

- TwoFactorChallengePayload: Returned when a login cannot complete with a password alone because the user has two-factor authentication enabled. Carries the opaque challenge token that must be echoed back to POST /api/v1/tokens/two-factor (or the recovery / resend / switch-mechanism endpoints) along with enough metadata for a client to render the verification step without a second round-trip. The property names are snake_case to match the wire format of the other token endpoints (see TokenPayload).
  - `two_factor_required` boolean, nullable: Present and true on the 202 response from POST /api/v1/tokens when the user has at least one verified 2FA method. Absent on the resend / switch-mechanism responses, which only ever follow an already-issued login challenge.
  - `two_factor_enrollment_required` boolean, nullable: Present and true instead of two_factor_required when the tenant forces 2FA but the user has not yet enrolled any method. In that case only challenge_token and expires_in are populated and the client must route the user through the mid-login enrollment endpoints (/api/v1/tokens/two-factor/enroll/...) before a token can be issued.
  - `challenge_token` string, nullable: Short-lived signed JWT (audience outseta:2fa-challenge) that identifies this challenge. Echo it back verbatim to complete the login.
  - `mechanism` string, nullable: The mechanism this challenge was issued against: Email or Totp (authenticator app). For Email a code has already been sent to the user; for Totp the user reads the current code from their authenticator app and nothing is sent.
  - `masked_destination` string, nullable: A masked view of where an emailed code was sent (e.g. b***@outseta.com), suitable for display. Empty when mechanism is Totp.
  - `expires_in` integer: Seconds until the challenge expires (600). After this the challenge_token can no longer be verified and the login must restart.
  - `available_mechanisms` string[], nullable: Every verified mechanism enrolled for this user (excluding recovery codes), e.g. ["Totp", "Email"]. A client can offer a "use a different method" option for any value other than the current mechanism via POST /api/v1/tokens/two-factor/switch-mechanism.
  - `recovery_codes_available` boolean, nullable: true when the user has a batch of recovery codes on file, in which case POST /api/v1/tokens/two-factor/recovery can be used as a fallback if they cannot produce a primary code.

## Other responses

- `400`: Unknown mechanism (`invalid_mechanism`) or one the user has not enrolled (`not_enrolled`).

---

[API](https://skmtc.dev/outseta/apis/outseta-api.md) · [All operations](https://skmtc.dev/outseta/apis/outseta-api/llms.txt) · [OpenAPI document](https://skmtc.dev/outseta/apis/outseta-api/revisions/c362823af82d?raw)
