{"record":{"id":"ec5badc39edffa86","repo":"bitwarden/server","slug":"you-cannot-import-this-much-data-at-once","errorCode":null,"errorMessage":"You cannot import this much data at once.","messagePattern":"You cannot import this much data at once\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"src/Api/AdminConsole/Public/Controllers/OrganizationController.cs","lineNumber":56,"sourceCode":"        _featureService = featureService;\n    }\n\n    /// <summary>\n    /// Import members and groups.\n    /// </summary>\n    /// <remarks>\n    /// Import members and groups from an external system.\n    /// </remarks>\n    /// <param name=\"model\">The request model.</param>\n    [HttpPost(\"import\")]\n    [ProducesResponseType(typeof(OkResult), (int)HttpStatusCode.OK)]\n    [ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]\n    public async Task<IActionResult> Import([FromBody] OrganizationImportRequestModel model)\n    {\n        if (!_globalSettings.SelfHosted && !model.LargeImport &&\n            (model.Groups.Count() > 2000 || model.Members.Count(u => !u.Deleted) > 2000))\n        {\n            throw new BadRequestException(\"You cannot import this much data at once.\");\n        }\n\n        await _importOrganizationUsersAndGroupsCommand.ImportAsync(\n                _currentContext.OrganizationId.Value,\n                model.Groups.Select(g => g.ToImportedGroup(_currentContext.OrganizationId.Value)),\n                model.Members.Where(u => !u.Deleted).Select(u => u.ToImportedOrganizationUser()),\n                model.Members.Where(u => u.Deleted).Select(u => u.ExternalId),\n                model.OverwriteExisting.GetValueOrDefault(),\n                model.InviteUsersAfterProvisioning\n                );\n\n        return new OkResult();\n    }\n}\n","sourceCodeStart":38,"sourceCodeEnd":71,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Public/Controllers/OrganizationController.cs#L38-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Split the import into batches of at most 2000 groups and 2000 non-deleted members each.","Set model.LargeImport = true if the import genuinely exceeds the limit and the operation is intentional on cloud.","For very large directories, prefer the SCIM connector which streams members incrementally rather than a single bulk import."],"exampleFix":"// before\nawait api.post(`organizations/import`, { groups, members, largeImport: false });\n// after (option A: page)\nfor (const batch of chunk(members, 2000)) {\n  await api.post(`organizations/import`, { groups: [], members: batch, largeImport: false });\n}\n// after (option B: opt in)\nawait api.post(`organizations/import`, { groups, members, largeImport: true });","handlingStrategy":"validation","validationCode":"const MAX = 2000;\nfunction withinCloudLimit(groups, members) {\n  return groups.length <= MAX && members.filter(u => !u.deleted).length <= MAX;\n}\nif (!withinCloudLimit(groups, members)) body.largeImport = true; // or page the batch","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Page imports into batches of <=2000 groups and <=2000 non-deleted members.","Set largeImport=true only for intentional oversized imports on cloud.","Prefer the SCIM connector for very large directories."],"tags":["bitwarden","import","limits","organization","cloud","aspnet"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}