{"record":{"id":"c90d47326b92d57e","repo":"BerriAI/litellm","slug":"401-c90d47","errorCode":"401","errorMessage":"User {user_api_key_dict.user_id} does not belong to team {team_table.team_id}. Team-scoped key management endpoints can only be used for keys in your own team.","messagePattern":"User (.+?) does not belong to team (.+?)\\. Team-scoped key management endpoints can only be used for keys in your own team\\.","errorType":"http","errorClass":"ProxyException","httpStatus":401,"severity":"error","filePath":"litellm/proxy/management_helpers/team_member_permission_checks.py","lineNumber":100,"sourceCode":"        team_table: Final = await get_team_object(\n            team_id=existing_key_row.team_id,\n            prisma_client=prisma_client,\n            user_api_key_cache=user_api_key_cache,\n            parent_otel_span=user_api_key_dict.parent_otel_span,\n            check_db_only=True,\n        )\n\n        # 4. Extract `Member` object from `team_table`\n        key_assigned_user_in_team: Final = _get_user_in_team(team_table=team_table, user_id=user_api_key_dict.user_id)\n\n        # 5. Check if the team member has permissions for the endpoint\n        has_permission: Final = TeamMemberPermissionChecks.does_team_member_have_permissions_for_endpoint(\n            team_member_object=key_assigned_user_in_team,\n            team_table=team_table,\n            route=route,\n        )\n        if not has_permission:\n            raise ProxyException(\n                message=f\"User {user_api_key_dict.user_id} does not belong to team {team_table.team_id}. Team-scoped key management endpoints can only be used for keys in your own team.\",\n                type=ProxyErrorTypes.team_member_permission_error,\n                param=route,\n                code=401,\n            )\n\n    @staticmethod\n    def does_team_member_have_permissions_for_endpoint(\n        team_member_object: Member | None,\n        team_table: LiteLLM_TeamTableCachedObj,\n        route: str,\n    ) -> bool | None:\n        \"\"\"\n        Raises an exception if the team member does not have permissions for calling the endpoint for a team\n        \"\"\"\n\n        # permission checks only run for non-admin users\n        # Non-Admin user trying to access information about a team's key","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_helpers/team_member_permission_checks.py#L82-L118","documentation":"HTTPException raised by the team-member permission check for team-scoped key management: the authenticated user does not appear as a member of the team that owns the target key. Team-scoped key endpoints only operate on keys in the caller's own team, so the request is rejected even though the key exists.","triggerScenarios":"Thrown at litellm/proxy/management_helpers/team_member_permission_checks.py:100 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use this endpoint only for keys in your own team, or call with a proxy admin key."],"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-14T00:17:10.932Z"}