<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to Retrieve Last Login Dates for Multiple Users in FusionAuth via the Search API]]></title><description><![CDATA[<p dir="auto">We have ~8,000 usernames/emails and want to look up each user’s <strong>last login date</strong>. The UI seems to allow searching only one email at a time. Is there a way to upload a <strong>CSV</strong> of usernames and get all of their <strong>lastLoginInstant</strong> values?</p>
]]></description><link>https://fusionauth.io/community/forum/topic/3067/how-to-retrieve-last-login-dates-for-multiple-users-in-fusionauth-via-the-search-api</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 21:13:17 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/3067.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 25 Oct 2025 02:07:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to Retrieve Last Login Dates for Multiple Users in FusionAuth via the Search API on Sat, 25 Oct 2025 02:19:16 GMT]]></title><description><![CDATA[<p dir="auto">FusionAuth doesn’t support uploading a CSV to retrieve last-login timestamps. However, you can do this efficiently with the <strong>Search for Users API</strong> and return <strong>lastLoginInstant</strong> for many users at once.</p>
<p dir="auto"><strong>How to do it (batch via API)</strong></p>
<ol>
<li>
<p dir="auto"><strong>Use the User Search endpoint</strong><br />
POST /api/user/search (set your X-FusionAuth-TenantId and Authorization headers).</p>
</li>
<li>
<p dir="auto"><strong>Send an Elasticsearch query</strong> using <strong>terms</strong> to match a batch of emails/usernames, and read <strong>lastLoginInstant</strong> from each returned user:</p>
</li>
</ol>
<pre><code> {
  "search": {
    "query": "{\"terms\":{\"email\":[\"a@example.com\",\"b@example.com\",\"c@example.com\"]}}",
    "numberOfResults": 500,
    "startRow": 0
  }
}
</code></pre>
<ul>
<li>Swap email for username if that’s what you have.</li>
<li>If your list is large, chunk it (e.g., 200–500 logins per request) and paginate with startRow / numberOfResults.</li>
</ul>
<ol start="3">
<li><strong>(Optional) Filter by last-login date</strong> with a range query on lastLoginInstant:</li>
</ol>
<pre><code> {
  "search": {
    "query": "{\"range\":{\"lastLoginInstant\":{\"gte\":\"2025-10-01T00:00:00Z\"}}}"
  }
}
</code></pre>
<p dir="auto">You can also query by <strong>epoch millis</strong> if you prefer.</p>
<ol start="4">
<li><strong>Map results</strong><br />
Each user object includes <strong>lastLoginInstant</strong> (epoch millis). Convert to your desired timezone/format in your script and write out a CSV.</li>
</ol>
<p dir="auto"><strong>Tips</strong></p>
<ul>
<li>If you need all users in a tenant (not just your list), you can search with a wildcard or a match-all query and page through results, then filter locally.</li>
<li>For ongoing metrics, consider subscribing to <strong>user.login.success</strong> webhooks and recording last logins as they happen.</li>
</ul>
<p dir="auto"><strong>Docs:</strong></p>
<ul>
<li>Search for Users API (Elasticsearch): <a href="https://fusionauth.io/docs/apis/users#elasticsearch-search-engine" rel="nofollow ugc">https://fusionauth.io/docs/apis/users#elasticsearch-search-engine</a></li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/8407</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/8407</guid><dc:creator><![CDATA[wesley]]></dc:creator><pubDate>Sat, 25 Oct 2025 02:19:16 GMT</pubDate></item></channel></rss>