bitwarden/server · warning · BadRequestException

You cannot import this much data at once.

Error message

You cannot import this much data at once.

What it means

Thrown as a 400 BadRequestException("You cannot import this much data at once.") from the public organization import endpoint when the deployment is NOT self-hosted, model.LargeImport is false, and either the groups count exceeds 2000 or the non-deleted members count exceeds 2000. Cloud deployments cap a standard import to protect shared infrastructure; callers must opt into large imports.

Source

Thrown at src/Api/AdminConsole/Public/Controllers/OrganizationController.cs:56

        _featureService = featureService;
    }

    /// <summary>
    /// Import members and groups.
    /// </summary>
    /// <remarks>
    /// Import members and groups from an external system.
    /// </remarks>
    /// <param name="model">The request model.</param>
    [HttpPost("import")]
    [ProducesResponseType(typeof(OkResult), (int)HttpStatusCode.OK)]
    [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
    public async Task<IActionResult> Import([FromBody] OrganizationImportRequestModel model)
    {
        if (!_globalSettings.SelfHosted && !model.LargeImport &&
            (model.Groups.Count() > 2000 || model.Members.Count(u => !u.Deleted) > 2000))
        {
            throw new BadRequestException("You cannot import this much data at once.");
        }

        await _importOrganizationUsersAndGroupsCommand.ImportAsync(
                _currentContext.OrganizationId.Value,
                model.Groups.Select(g => g.ToImportedGroup(_currentContext.OrganizationId.Value)),
                model.Members.Where(u => !u.Deleted).Select(u => u.ToImportedOrganizationUser()),
                model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),
                model.OverwriteExisting.GetValueOrDefault(),
                model.InviteUsersAfterProvisioning
                );

        return new OkResult();
    }
}

View on GitHub (pinned to e93b962371)

Solutions

  1. Split the import into batches of at most 2000 groups and 2000 non-deleted members each.
  2. Set model.LargeImport = true if the import genuinely exceeds the limit and the operation is intentional on cloud.
  3. For very large directories, prefer the SCIM connector which streams members incrementally rather than a single bulk import.

Example fix

// before
await api.post(`organizations/import`, { groups, members, largeImport: false });
// after (option A: page)
for (const batch of chunk(members, 2000)) {
  await api.post(`organizations/import`, { groups: [], members: batch, largeImport: false });
}
// after (option B: opt in)
await api.post(`organizations/import`, { groups, members, largeImport: true });
Defensive patterns

Strategy: validation

Validate before calling

const MAX = 2000;
function withinCloudLimit(groups, members) {
  return groups.length <= MAX && members.filter(u => !u.deleted).length <= MAX;
}
if (!withinCloudLimit(groups, members)) body.largeImport = true; // or page the batch

Prevention

When it happens

Trigger: POST organizations/import on cloud (SelfHosted=false) with model.LargeImport unset/false where model.Groups.Count() > 2000 or model.Members.Where(u => !u.Deleted).Count() > 2000.

Common situations: Bulk provisioning thousands of users/groups from an IdP without paging; a one-time migration that exceeds the cloud limit; client forgot to set the LargeImport flag for an oversized batch.

Related errors


AI-assisted analysis of bitwarden/server@e93b962371 (2026-08-13). Data as JSON: /api/errors/ec5badc39edffa86. Report an issue: GitHub.