{"record":{"id":"7f75112c01181bbc","repo":"bitwarden/server","slug":"managed-service-providers-cannot-manage-organizati","errorCode":null,"errorMessage":"Managed Service Providers cannot manage organizations with the plan type {requestedType}. Only Teams (Monthly) and Enterprise (Monthly) are allowed.","messagePattern":"Managed Service Providers cannot manage organizations with the plan type (.+?)\\. Only Teams \\(Monthly\\) and Enterprise \\(Monthly\\) are allowed\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs","lineNumber":742,"sourceCode":"    }\n\n    private async Task<bool> HasConfirmedProviderAdminExceptAsync(Guid providerId, IEnumerable<Guid> providerUserIds)\n    {\n        var providerAdmins = await _providerUserRepository.GetManyByProviderAsync(providerId,\n            ProviderUserType.ProviderAdmin);\n        var confirmedOwners = providerAdmins.Where(o => o.Status == ProviderUserStatusType.Confirmed);\n        var confirmedOwnersIds = confirmedOwners.Select(u => u.Id);\n        return confirmedOwnersIds.Except(providerUserIds).Any();\n    }\n\n    private void ThrowOnInvalidPlanType(ProviderType providerType, PlanType requestedType)\n    {\n        switch (providerType)\n        {\n            case ProviderType.Msp:\n                if (requestedType is not (PlanType.TeamsMonthly or PlanType.EnterpriseMonthly))\n                {\n                    throw new BadRequestException($\"Managed Service Providers cannot manage organizations with the plan type {requestedType}. Only Teams (Monthly) and Enterprise (Monthly) are allowed.\");\n                }\n                break;\n            case ProviderType.BusinessUnit:\n                if (requestedType is not (PlanType.EnterpriseMonthly or PlanType.EnterpriseAnnually))\n                {\n                    throw new BadRequestException($\"Business Unit Providers cannot manage organizations with the plan type {requestedType}. Only Enterprise (Monthly) and Enterprise (Annually) are allowed.\");\n                }\n                break;\n            case ProviderType.Reseller:\n                if (_resellerDisallowedOrganizationTypes.Contains(requestedType))\n                {\n                    throw new BadRequestException($\"Providers cannot manage organizations with the requested plan type ({requestedType}). Only Teams and Enterprise accounts are allowed.\");\n                }\n                break;\n            default:\n                throw new BadRequestException($\"Unsupported provider type {providerType}.\");\n        }\n    }","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/bitwarden_license/src/Commercial.Core/AdminConsole/Services/ProviderService.cs#L724-L760","documentation":"Thrown by ProviderService.ThrowOnInvalidPlanType for an Msp provider when the requested organization PlanType is not TeamsMonthly or EnterpriseMonthly. MSPs may only manage Teams (Monthly) and Enterprise (Monthly) organizations. BadRequestException (HTTP 400).","triggerScenarios":"Adding/assigning an organization whose PlanType is Free, Families, TeamsAnnually, EnterpriseAnnually, or any non-monthly tier to an MSP provider via AddOrganization or a flow calling ThrowOnInvalidPlanType.","commonSituations":"Migrating an annually-billed org under an MSP without first switching billing; attempting to add a Free-tier org; plan data mismatch after a pricing migration.","solutions":["Convert the organization's plan to TeamsMonthly or EnterpriseMonthly before adding it to the MSP.","Validate requestedType against the MSP-allowed set client-side and block the add.","For annual plans, use a BusinessUnit or Reseller provider, or change the org to monthly."],"exampleFix":"// before\nawait providerService.AddOrganization(mspProviderId, orgId, key);\n\n// after\nvar allowed = new[] { PlanType.TeamsMonthly, PlanType.EnterpriseMonthly };\nif (!allowed.Contains(org.PlanType))\n{\n    return BadRequest(\"Switch the org to a Monthly Teams/Enterprise plan first.\");\n}\nawait providerService.AddOrganization(mspProviderId, orgId, key);","handlingStrategy":"validation","validationCode":"var allowed = new[] { PlanType.TeamsMonthly, PlanType.EnterpriseMonthly };\nif (!allowed.Contains(org.PlanType)) return BadRequest(\"Plan not allowed for MSP.\");","typeGuard":"static bool MspAllows(PlanType t) => t is PlanType.TeamsMonthly or PlanType.EnterpriseMonthly;","tryCatchPattern":null,"preventionTips":["Switch orgs to a monthly Teams/Enterprise plan before MSP assignment.","Validate plan type against provider type in the UI."],"tags":["provider","msp","plan-type","billing","bad-request"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}