BerriAI/litellm · error · ProxyException

401

401

Error message

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.

What it means

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.

Solutions

  1. Use this endpoint only for keys in your own team, or call with a proxy admin key.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at litellm/proxy/management_helpers/team_member_permission_checks.py:100 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/c90d47326b92d57e. Report an issue: GitHub.

Appendix: source

Thrown at litellm/proxy/management_helpers/team_member_permission_checks.py:100

        team_table: Final = await get_team_object(
            team_id=existing_key_row.team_id,
            prisma_client=prisma_client,
            user_api_key_cache=user_api_key_cache,
            parent_otel_span=user_api_key_dict.parent_otel_span,
            check_db_only=True,
        )

        # 4. Extract `Member` object from `team_table`
        key_assigned_user_in_team: Final = _get_user_in_team(team_table=team_table, user_id=user_api_key_dict.user_id)

        # 5. Check if the team member has permissions for the endpoint
        has_permission: Final = TeamMemberPermissionChecks.does_team_member_have_permissions_for_endpoint(
            team_member_object=key_assigned_user_in_team,
            team_table=team_table,
            route=route,
        )
        if not has_permission:
            raise ProxyException(
                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.",
                type=ProxyErrorTypes.team_member_permission_error,
                param=route,
                code=401,
            )

    @staticmethod
    def does_team_member_have_permissions_for_endpoint(
        team_member_object: Member | None,
        team_table: LiteLLM_TeamTableCachedObj,
        route: str,
    ) -> bool | None:
        """
        Raises an exception if the team member does not have permissions for calling the endpoint for a team
        """

        # permission checks only run for non-admin users
        # Non-Admin user trying to access information about a team's key

View on GitHub (pinned to 77b7c6c40c)