{"record":{"id":"54de3d404a4bc50f","repo":"BerriAI/litellm","slug":"only-proxy-admins-can-delete-organizations","errorCode":null,"errorMessage":"Only proxy admins can delete organizations","messagePattern":"Only proxy admins can delete organizations","errorType":"http","errorClass":"HTTPException","httpStatus":401,"severity":"error","filePath":"litellm/proxy/management_endpoints/organization_endpoints.py","lineNumber":926,"sourceCode":"    user_api_key_dict: UserAPIKeyAuth = Depends(user_api_key_auth),\n):\n    \"\"\"\n    Delete an organization\n\n    # Parameters:\n\n    - organization_ids: List[str] - The organization ids to delete.\n    \"\"\"\n    from litellm.proxy.proxy_server import prisma_client\n\n    if prisma_client is None:\n        raise HTTPException(\n            status_code=500,\n            detail={\"error\": CommonProxyErrors.db_not_connected_error.value},\n        )\n\n    if user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN:\n        raise HTTPException(\n            status_code=401,\n            detail={\"error\": \"Only proxy admins can delete organizations\"},\n        )\n\n    deleted_orgs: Final = []\n    for organization_id in data.organization_ids:\n        # delete all teams in the organization\n        await _table(TeamRepository(prisma_client)).delete_many(where={\"organization_id\": organization_id})\n        # delete all members in the organization\n        await _table(OrganizationMembershipRepository(prisma_client)).delete_many(\n            where={\"organization_id\": organization_id}\n        )\n        # delete all keys in the organization\n        await _table(VerificationTokenRepository(prisma_client)).delete_many(where={\"organization_id\": organization_id})\n        # delete the organization\n        deleted_org = await _table(OrganizationRepository(prisma_client)).delete(\n            where={\"organization_id\": organization_id},\n            include={\"members\": True, \"teams\": True, \"litellm_budget_table\": True},","sourceCodeStart":908,"sourceCodeEnd":944,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/organization_endpoints.py#L908-L944","documentation":"Role guard on organization delete: deletion cascades — it removes the org's teams, memberships, and keys — so it is restricted to PROXY_ADMIN. Any other role is rejected with 401 before the cascade begins.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/organization_endpoints.py:926 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a PROXY_ADMIN API key to delete organizations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8","analyzedAt":"2026-08-18T11:44:31.656Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}