{"record":{"id":"ee1bc5abd7aaeaa3","repo":"bitwarden/server","slug":"cannot-create-a-typedmodel-type-connection-outsi","errorCode":null,"errorMessage":"Cannot create a {typedModel.Type} connection outside of a self-hosted instance.","messagePattern":"Cannot create a (.+?) connection outside of a self-hosted instance\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs","lineNumber":199,"sourceCode":"    /// </remarks>\n    private async Task<bool> HasPermissionAsync(Guid? organizationId, OrganizationConnectionType? type = null)\n    {\n        if (!organizationId.HasValue)\n        {\n            return false;\n        }\n        return type switch\n        {\n            OrganizationConnectionType.Scim => await _currentContext.ManageScim(organizationId.Value),\n            _ => await _currentContext.OrganizationOwner(organizationId.Value),\n        };\n    }\n\n    private async Task ValidateBillingSyncConfig(OrganizationConnectionRequestModel<BillingSyncConfig> typedModel)\n    {\n        if (!_globalSettings.SelfHosted)\n        {\n            throw new BadRequestException($\"Cannot create a {typedModel.Type} connection outside of a self-hosted instance.\");\n        }\n        var license = await _licensingService.ReadOrganizationLicenseAsync(typedModel.OrganizationId);\n\n        if (license == null || !_licensingService.VerifyLicense(license))\n        {\n            throw new BadRequestException(\"Cannot verify license file.\");\n        }\n        typedModel.ParsedConfig.CloudOrganizationId = license.Id;\n    }\n\n    private async Task<OrganizationConnectionResponseModel> CreateOrUpdateOrganizationConnectionAsync<T>(\n        Guid? organizationConnectionId,\n        OrganizationConnectionRequestModel model,\n        Func<OrganizationConnectionRequestModel<T>, Task>? validateAction = null)\n        where T : IConnectionConfig\n    {\n        var typedModel = new OrganizationConnectionRequestModel<T>(model);\n        if (validateAction != null)","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs#L181-L217","documentation":"Thrown by ValidateBillingSyncConfig (invoked during create/update of a CloudBillingSync connection) when _globalSettings.SelfHosted is false. Billing Sync is a self-hosted-only feature that syncs billing data to the cloud, so creating one on a cloud instance is invalid. This is a second-layer check (the feature also gates reads via error 150). Maps to HTTP 400.","triggerScenarios":"POST or PUT /organizations/connections with type=CloudBillingSync (1) against a non-self-hosted deployment; the request passes the earlier permission/type checks but fails this config validator inside CreateOrUpdateOrganizationConnectionAsync.","commonSituations":"Dev/test running against the cloud API or a local server with SelfHosted unset; a misconfigured self-hosted install where the env var globalSettings__selfHosted is missing or false; environment promotion that dropped the setting.","solutions":["Run against a self-hosted instance for any CloudBillingSync operation.","On a self-hosted install, set GlobalSettings.SelfHosted=true (env globalSettings__selfHosted=true or appsettings SelfHosted=true).","On cloud, do not attempt to create CloudBillingSync connections; use cloud billing endpoints.","Confirm EnableCloudCommunication is also true for the full feature."],"exampleFix":"// appsettings.json or env — before\n{ \"globalSettings\": { \"selfHosted\": false } }\n// after\n{ \"globalSettings\": { \"selfHosted\": true, \"enableCloudCommunication\": true } }","handlingStrategy":"validation","validationCode":"// CloudBillingSync create is self-hosted-only\nvar enabled = await client.GetAsync<bool>(\"organizations/connections/enabled\");\nif (!enabled && model.Type == OrganizationConnectionType.CloudBillingSync)\n    throw new InvalidOperationException(\"CloudBillingSync requires a self-hosted instance with cloud communication enabled.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only create CloudBillingSync on self-hosted instances (SelfHosted=true && EnableCloudCommunication=true).","Use GET .../connections/enabled to confirm the feature path before creating.","On cloud, use cloud billing endpoints."],"tags":["self-hosted","configuration","billing-sync","organization-connections","http-400"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}