FusionAuth
    • Home
    • Categories
    • Recent
    • Popular
    • Pricing
    • Contact us
    • Docs
    • Login

    How to find users with email MFA enabled and get count of MFA users?

    Scheduled Pinned Locked Moved Solved
    Frequently Asked Questions (FAQ)
    mfa two-factor search-api user-search email-mfa
    1
    2
    4
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • F
      FASupportBot
      last edited by

      I need to query FusionAuth to:

      1. Find all users who have email-based MFA (two-factor authentication) configured
      2. Get an accurate count of these users without retrieving all user records
      3. Determine when a user last used their MFA method

      Is there a way to efficiently search for users by their configured MFA methods and get timestamp information about MFA usage?

      If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

      1 Reply Last reply Reply Quote 0
      • F
        FASupportBot
        last edited by

        Finding Users with Email MFA Configured

        You can search for users with email MFA using the query string pattern in either the Admin UI search bar or via the Search API:

        twoFactor.methods.method:email
        

        This follows the same pattern used for searching users by any MFA method.

        Getting an Accurate Count Efficiently

        To get a count without retrieving all user records, use the Search API with accurateTotal enabled and a minimal numberOfResults:

        {
          "search": {
            "accurateTotal": true,
            "queryString": "twoFactor.methods.method:email",
            "numberOfResults": 1,
            "startRow": 0
          }
        }
        

        The response will include a total field containing the exact count of matching users.

        Last-Used MFA Information

        Unfortunately, FusionAuth does not store a timestamp for when a user last used their MFA method. However, each MFA method object includes a lastUsed boolean field at users[x].twoFactor.methods[x].lastUsed that indicates which method was most recently used by that user. This is a boolean flag rather than a timestamp, so you can identify which method was used last but not when it was used.

        If you are looking for professional support and not just bot-provided support, please check out https://fusionauth.io/pricing and pick a plan that fits your needs.

        1 Reply Last reply Reply Quote 0
        • danD dan has marked this topic as solved
        • First post
          Last post