{"record":{"id":"a39b6fcbd028a646","repo":"BerriAI/litellm","slug":"400","errorCode":"400","errorMessage":"Project id = {data.project_id} already exists. Please use a different project id.","messagePattern":"Project id = (.+?) already exists\\. Please use a different project id\\.","errorType":"http","errorClass":"ProxyException","httpStatus":400,"severity":"error","filePath":"enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py","lineNumber":403,"sourceCode":"\n        if not has_permission:\n            raise HTTPException(\n                status_code=403,\n                detail={\n                    \"error\": f\"Only admins or team admins can create projects. Your role is {user_api_key_dict.user_role}\"\n                },\n            )\n\n        # Generate project_id if not provided\n        if data.project_id is None:\n            data.project_id = str(uuid.uuid4())\n        else:\n            # Check if project_id already exists\n            existing_project = await prisma_client.db.litellm_projecttable.find_unique(\n                where={\"project_id\": data.project_id}\n            )\n            if existing_project is not None:\n                raise ProxyException(\n                    message=f\"Project id = {data.project_id} already exists. Please use a different project id.\",\n                    type=\"bad_request\",\n                    code=400,\n                    param=\"project_id\",\n                )\n\n        # Create budget if not provided\n        if data.budget_id is None:\n            data.budget_id = await _create_budget_for_project(\n                data=data,\n                user_id=user_api_key_dict.user_id,\n                litellm_proxy_admin_name=litellm_proxy_admin_name,\n                prisma_client=prisma_client,\n            )\n\n        ## Handle Object Permission - MCP, Vector Stores etc.\n        object_permission_id = await _set_project_object_permission(\n            data=data,","sourceCodeStart":385,"sourceCodeEnd":421,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/enterprise/litellm_enterprise/proxy/management_endpoints/project_endpoints.py#L385-L421","documentation":"When a client supplies an explicit project_id on POST /project/new, LiteLLM checks litellm_projecttable.find_unique for a collision and throws a ProxyException (type bad_request, code 400, param project_id) if the id already exists. Omitting project_id is safe: the server generates a fresh uuid4 that cannot collide in practice.","triggerScenarios":"POST /project/new with a \"project_id\" that already exists in the database, e.g. re-running an idempotent provisioning script that specifies project_id after a successful first run.","commonSituations":"Terraform/Ansible or CI jobs re-applying project creation, retrying a request that actually succeeded server-side, or copying an environment's ids into another without dedup.","solutions":["Use a different project_id or omit the field and let the server generate a uuid","Make provisioning scripts check GET /project/info (or catch 400 on project_id) before creating","On retry-after-timeout, verify the project was not already created before resubmitting the same id"],"exampleFix":"# before\ncurl -X POST .../project/new -d '{\"project_id\":\"project-123\",\"team_id\":\"t1\"}'\n# after\ncurl -X POST .../project/new -d '{\"team_id\":\"t1\"}'  # server assigns a uuid project_id","handlingStrategy":"try-catch","validationCode":"try:\n    await client.get(f'/project/info?project_id={payload[\"project_id\"]}')\n    raise RuntimeError('project_id already exists; use update instead')\nexcept Exception as e:\n    if getattr(e, 'status_code', None) != 404:\n        raise","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e.status === 400 && /already exists/.test(e.body?.detail?.error ?? e.message ?? '')) {\n    return client.put('/project/update', body); // idempotent apply: switch to update\n  }\n  throw e;\n}","preventionTips":["Make provisioning scripts idempotent: check-then-create, or create without project_id and store the returned uuid","On request timeouts, verify whether the project was created before retrying with the same id"],"tags":["litellm","conflict","idempotency","enterprise","http-400"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}