{"record":{"id":"fcce7081ee17c7b6","repo":"BerriAI/litellm","slug":"only-proxy-admins-can-delete-prompts","errorCode":null,"errorMessage":"Only proxy admins can delete prompts","messagePattern":"Only proxy admins can delete prompts","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":965,"sourceCode":"        -H \"Authorization: Bearer <your_api_key>\"\n    ```\n\n    Example Response:\n    ```json\n    {\n        \"message\": \"Prompt my_prompt_id deleted successfully\"\n    }\n    ```\n    \"\"\"\n    from litellm.proxy.prompts.prompt_registry import IN_MEMORY_PROMPT_REGISTRY\n    from litellm.proxy.proxy_server import prisma_client\n\n    # Only allow proxy admins to delete prompts\n    if user_api_key_dict.user_role is None or (\n        user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN\n        and user_api_key_dict.user_role != LitellmUserRoles.PROXY_ADMIN.value\n    ):\n        raise HTTPException(status_code=403, detail=\"Only proxy admins can delete prompts\")\n\n    if prisma_client is None:\n        raise HTTPException(status_code=500, detail=CommonProxyErrors.db_not_connected_error.value)\n\n    try:\n        # Try to get prompt directly first\n        existing_prompt = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(prompt_id)\n\n        # If not found, try to find the latest version\n        if existing_prompt is None:\n            latest_prompt_id: Final = get_latest_version_prompt_id(\n                prompt_id=prompt_id,\n                all_prompt_ids=IN_MEMORY_PROMPT_REGISTRY.IN_MEMORY_PROMPTS,\n            )\n            existing_prompt = IN_MEMORY_PROMPT_REGISTRY.get_prompt_by_id(latest_prompt_id)\n            # Use the resolved prompt_id for deletion\n            prompt_id = latest_prompt_id\n","sourceCodeStart":947,"sourceCodeEnd":983,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L947-L983","documentation":"Authorization gate on prompt deletion: the caller's user_api_key_dict lacks the PROXY_ADMIN role, so deletion is refused before any lookup or removal happens.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:965 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a proxy admin key to delete prompts."],"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"}