{"record":{"id":"479e3dc2022811aa","repo":"bitwarden/server","slug":"cannot-get-a-type-connection-outside-of-a-self-h","errorCode":null,"errorMessage":"Cannot get a {type} connection outside of a self-hosted instance.","messagePattern":"Cannot get a (.+?) connection outside of a self-hosted instance\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs","lineNumber":134,"sourceCode":"    }\n\n    [HttpGet(\"{organizationId}/{type}\")]\n    public async Task<OrganizationConnectionResponseModel> GetConnection(Guid organizationId, OrganizationConnectionType type)\n    {\n        if (!await HasPermissionAsync(organizationId, type))\n        {\n            throw new BadRequestException($\"You do not have permission to retrieve a connection of type {type}.\");\n        }\n\n        var connections = await GetConnectionsAsync(organizationId, type);\n        var connection = connections.FirstOrDefault(c => c.Type == type);\n\n        switch (type)\n        {\n            case OrganizationConnectionType.CloudBillingSync:\n                if (!_globalSettings.SelfHosted)\n                {\n                    throw new BadRequestException($\"Cannot get a {type} connection outside of a self-hosted instance.\");\n                }\n                return new OrganizationConnectionResponseModel(connection, typeof(BillingSyncConfig));\n            case OrganizationConnectionType.Scim:\n                return new OrganizationConnectionResponseModel(connection, typeof(ScimConfig));\n            default:\n                throw new BadRequestException($\"Unknown Organization connection Type: {type}\");\n        }\n    }\n\n    [HttpDelete(\"{organizationConnectionId}\")]\n    public async Task DeleteConnection(Guid organizationConnectionId)\n    {\n        var connection = await _organizationConnectionRepository.GetByIdAsync(organizationConnectionId);\n\n        if (connection == null)\n        {\n            throw new NotFoundException();\n        }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/bitwarden/server/blob/e93b962371d80964556f5590c6615f5160a437a1/src/Api/AdminConsole/Controllers/OrganizationConnectionsController.cs#L116-L152","documentation":"Thrown by GetConnection (GET) in the CloudBillingSync branch when _globalSettings.SelfHosted is false. Cloud Billing Sync connections are only meaningful on self-hosted instances (they bridge a self-hosted org to the cloud), so retrieving one on the cloud/SaaS instance is rejected. Maps to HTTP 400.","triggerScenarios":"GET /organizations/connections/{orgId}/1 (CloudBillingSync) against a cloud (non-self-hosted) Bitwarden deployment where _globalSettings.SelfHosted is false.","commonSituations":"Running the call against api.bitwarden.com (cloud) instead of a self-hosted server; a local dev instance with SelfHosted not set in user secrets / env; configuration drift where a self-hosted install was reconfigured as cloud.","solutions":["Target a self-hosted Bitwarden instance for CloudBillingSync operations.","On a self-hosted install, confirm GlobalSettings.SelfHosted=true is set (env: globalSettings__selfHosted=true or appsettings).","On cloud, use the appropriate cloud-side billing endpoints instead of the connection endpoint.","Verify EnableCloudCommunication is also true (see ConnectionsEnabled) for the full feature path."],"exampleFix":"// before — calling cloud instance\nawait client.GetAsync($\"organizations/connections/{orgId}/1\");\n// after — calling self-hosted instance\nclient.BaseAddress = new Uri(selfHostedUrl);\nawait client.GetAsync($\"organizations/connections/{orgId}/1\");","handlingStrategy":"validation","validationCode":"// CloudBillingSync is self-hosted-only\nvar enabled = await client.GetAsync<bool>(\"organizations/connections/enabled\");\nif (!enabled) throw new InvalidOperationException(\"Connections not enabled on this instance.\");\nif (!isSelfHosted && type == OrganizationConnectionType.CloudBillingSync)\n    throw new InvalidOperationException(\"CloudBillingSync requires a self-hosted instance.\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call CloudBillingSync GET against a self-hosted server.","Use GET .../connections/enabled to confirm SelfHosted && EnableCloudCommunication.","On cloud, use cloud billing endpoints instead."],"tags":["self-hosted","configuration","organization-connections","http-400"],"backgroundTag":null,"analyzedSha":"e93b962371d80964556f5590c6615f5160a437a1","analyzedAt":"2026-08-13T14:22:19.382Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}