<?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 quickly delete all users in a tenant for frequent test environment resets?]]></title><description><![CDATA[<p dir="auto">I'm running a FusionAuth migration in the cloud where we need to frequently sync user data into non-production environments. Each sync requires wiping all users from a tenant and re-importing a fresh set — sometimes with millions of users.</p>
<p dir="auto">Currently using <code>Delete Users by Query</code> with <code>hardDelete: true</code> and <code>queryString: registrations.applicationId:&lt;id&gt;</code>, but running into issues:</p>
<ul>
<li>Getting 504 timeouts even with a limit of 1500 users per request</li>
<li>Observing CloudFront terminating requests after 30 seconds, though the delete likely continues server-side</li>
<li>Best measured throughput is ~15 seconds per 1,000 users, which would take hours for full user delete of millions of users</li>
<li>Retries feel risky since we have no visibility into how many users were actually removed before the timeout</li>
</ul>
<p dir="auto"><strong>Questions:</strong></p>
<ol>
<li>Is there a faster path to zero users than query-based bulk delete — ideally close to instantaneous?</li>
<li>Is <code>Delete Users by Query</code> driven by the search index?</li>
<li>Would deleting and recreating the tenant itself be faster?</li>
<li>What are recommended approaches for maintaining user parity across multiple environments with large user populations?</li>
</ol>
]]></description><link>https://fusionauth.io/community/forum/topic/3226/how-to-quickly-delete-all-users-in-a-tenant-for-frequent-test-environment-resets</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 00:33:42 GMT</lastBuildDate><atom:link href="https://fusionauth.io/community/forum/topic/3226.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 08 Oct 2026 16:08:36 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to quickly delete all users in a tenant for frequent test environment resets? on Thu, 08 Oct 2026 16:08:47 GMT]]></title><description><![CDATA[<p dir="auto">For frequent, large-scale user resets in test environments, <strong>deleting and recreating the tenant</strong> is the recommended approach over bulk user deletion. While there's no "near-instant" bulk deletion method, tenant recreation is significantly faster than iterative bulk deletes at scale.</p>
<h2>Key Points About Bulk Delete</h2>
<ul>
<li><code>Delete Users by Query</code> <strong>is driven by the search index</strong> (specifically Elasticsearch). The <code>queryString</code> parameter has limited support when using the database as the search engine (only simple single-term searches on basic fields like <code>firstName</code>, <code>lastName</code>, <code>fullName</code>, <code>email</code>, and <code>username</code>).</li>
<li>CloudFront has a <strong>30-second timeout</strong> for origin responses, which explains the 504 errors you're seeing</li>
<li>The delete operation likely continues on the FusionAuth side even after CloudFront terminates the connection, making retries risky</li>
</ul>
<h2>Recommended Approach: Tenant Delete/Recreate</h2>
<p dir="auto">For test environments with large user populations, follow this workflow:</p>
<ol>
<li><strong>Cannot delete the Default tenant</strong> — the default tenant contains the FusionAuth application and cannot be deleted. Create separate tenants for testing purposes.</li>
<li>Delete the test tenant when ready to reset using the admin UI or the <a href="https://fusionauth.io/docs/apis/tenants/delete-a-tenant" rel="nofollow ugc">Delete Tenant API</a>. This will permanently delete all users, applications, and groups belonging to that tenant.</li>
<li>Use <code>docker compose down -v</code> to fully clean the environment</li>
<li>Use <code>docker compose up -d</code> to restart</li>
<li><strong>Use Kickstart</strong> to automatically recreate tenants, applications, and API keys</li>
</ol>
<p dir="auto">Kickstart will only run on an empty instance, so the <code>down -v</code> step is necessary. Configure a <a href="https://fusionauth.io/docs/get-started/download-and-install/development/kickstart" rel="nofollow ugc">Kickstart file</a> with your test environment configuration (tenants, applications, API keys) for reproducible deployments.</p>
<p dir="auto">Note that tenant deletion is an <strong>asynchronous operation</strong> (as of FusionAuth 1.22), meaning it runs in the background. For very large tenants (2M users), this will still take time but is considerably faster than bulk deleting millions of users through the API.</p>
<h2>Note on Import Timeouts</h2>
<p dir="auto">If you're also seeing CloudFront timeouts during large batch imports (e.g., 100k users), the same 30-second CloudFront limit applies. Consider reducing batch sizes when users have multiple registrations, as each registration inserts additional rows into related tables (registrations, application role mappings, etc.), significantly increasing processing time. For best import performance, minimize network hops and consider setting <code>validateDbConstraints</code> to <code>false</code>.</p>
<h2>Related Documentation</h2>
<ul>
<li><a href="https://fusionauth.io/docs/apis/tenants/delete-a-tenant" rel="nofollow ugc">Delete Tenant API</a> - API for permanently deleting a tenant and all its users</li>
<li><a href="https://fusionauth.io/docs/apis/users/bulk-delete" rel="nofollow ugc">Bulk Delete Users API</a> - API for deleting users by query, with limitations noted for search engine configuration</li>
<li><a href="https://fusionauth.io/docs/get-started/download-and-install/development/kickstart" rel="nofollow ugc">Kickstart</a> - Declarative tool for quickly replicating environments</li>
<li><a href="https://fusionauth.io/docs/lifecycle/migrate-users/provider-specific/cognito#clean-up-your-test-environment" rel="nofollow ugc">Clean Up Test Environments</a> - Migration guide with recommendations for test tenant cleanup</li>
<li><a href="https://fusionauth.io/docs/lifecycle/migrate-users/#how-to-delete-users-after-testing-a-migration" rel="nofollow ugc">How to Delete Users After Testing a Migration</a> - Documentation on fastest methods for removing test users</li>
<li><a href="https://fusionauth.io/blog/announcing-fusionauth-1-22" rel="nofollow ugc">Asynchronous Tenant Deletion</a> - Background on how tenant deletion works asynchronously</li>
<li><a href="https://fusionauth.io/docs/apis/users/import" rel="nofollow ugc">Import Users API</a> - Bulk import API documentation</li>
<li><a href="https://fusionauth.io/docs/lifecycle/migrate-users/#performance-tips" rel="nofollow ugc">Performance Tips for Migrations</a> - Best practices for importing large numbers of users</li>
</ul>
]]></description><link>https://fusionauth.io/community/forum/post/8789</link><guid isPermaLink="true">https://fusionauth.io/community/forum/post/8789</guid><dc:creator><![CDATA[FASupportBot]]></dc:creator><pubDate>Thu, 08 Oct 2026 16:08:47 GMT</pubDate></item></channel></rss>