{"record":{"id":"572a9d4b16976649","repo":"BerriAI/litellm","slug":"unable-to-find-team-object-in-database-team-id","errorCode":null,"errorMessage":"Unable to find team object in database. Team ID: {data.team_id}","messagePattern":"Unable to find team object in database\\. Team ID: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"error","filePath":"litellm/proxy/management_endpoints/key_management_endpoints.py","lineNumber":505,"sourceCode":"\ndef key_generation_check(\n    team_table: LiteLLM_TeamTableCachedObj | None,\n    user_api_key_dict: UserAPIKeyAuth,\n    data: GenerateKeyRequest,\n    route: KeyManagementRoutes,\n) -> bool:\n    \"\"\"\n    Check if admin has restricted key creation to certain roles for teams or individuals\n    \"\"\"\n\n    ## check if key is for team or individual\n    is_team_key: Final = _is_team_key(data=data)\n    _is_admin: Final = (\n        user_api_key_dict.user_role is not None and user_api_key_dict.user_role == LitellmUserRoles.PROXY_ADMIN.value\n    )\n    if is_team_key:\n        if team_table is None and litellm.key_generation_settings is not None:\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Unable to find team object in database. Team ID: {data.team_id}\",\n            )\n        elif team_table is None:\n            if _is_admin:\n                return True  # admins can assign team_id without team table\n            # Non-admin callers must have a valid team (LIT-1884)\n            raise HTTPException(\n                status_code=400,\n                detail=f\"Unable to find team object in database. Team ID: {data.team_id}\",\n            )\n        return _team_key_generation_check(\n            team_table=team_table,\n            user_api_key_dict=user_api_key_dict,\n            data=data,\n            route=route,\n        )\n    else:","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/management_endpoints/key_management_endpoints.py#L487-L523","documentation":"Error \"Unable to find team object in database. Team ID: {data.team_id}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/proxy/management_endpoints/key_management_endpoints.py:505 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the team_id exists via /team/list before creating the key.","Create the team first, then retry key creation."],"exampleFix":null,"handlingStrategy":null,"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"}