{"record":{"id":"ee90a4055d6dceff","repo":"BerriAI/litellm","slug":"you-are-not-authorized-to-access-this-prompt-your","errorCode":null,"errorMessage":"You are not authorized to access this prompt. Your role - {user_api_key_dict.user_role}, Your key's prompts - {prompts}","messagePattern":"You are not authorized to access this prompt\\. Your role - (.+?), Your key's prompts - (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"litellm/proxy/prompts/prompt_endpoints.py","lineNumber":641,"sourceCode":"            \"prompt_type\": \"config\"\n        },\n        \"created_at\": \"2023-11-09T12:34:56.789Z\",\n        \"updated_at\": \"2023-11-09T12:34:56.789Z\",\n        \"content\": \"System: You are a helpful assistant.\\n\\nUser: {{user_message}}\"\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    ## CHECK IF USER HAS ACCESS TO PROMPT\n    prompts: list[str] | None = None\n    if user_api_key_dict.metadata is not None:\n        prompts = cast(list[str] | None, user_api_key_dict.metadata.get(\"prompts\", None))\n        if prompts is not None and prompt_id not in prompts:\n            raise HTTPException(status_code=400, detail=f\"Prompt {prompt_id} not found\")\n    if not user_api_key_has_admin_view(user_api_key_dict):\n        raise HTTPException(\n            status_code=403,\n            detail=f\"You are not authorized to access this prompt. Your role - {user_api_key_dict.user_role}, Your key's prompts - {prompts}\",\n        )\n\n    base_prompt_id: Final = get_base_prompt_id(prompt_id=prompt_id)\n\n    # Query all environments this prompt exists in (lightweight: distinct on environment)\n    all_environments: list[str] = []\n    if prisma_client is not None:\n        all_prompt_rows: Final = await _prompt_table(prisma_client).find_many(\n            where={\"prompt_id\": base_prompt_id},\n            distinct=[\"environment\"],\n        )\n        all_environments = sorted(set(row.environment for row in all_prompt_rows if row.environment))\n\n    # If environment is specified, find the version in that environment from DB\n    # If prompt_id has a version suffix (e.g., \"testprompt.v2\"), fetch that specific version\n    # Otherwise fetch the latest version in that environment","sourceCodeStart":623,"sourceCodeEnd":659,"githubUrl":"https://github.com/BerriAI/litellm/blob/77b7c6c40c0c5aa5fbcb1d6a1825ac39ca8829b8/litellm/proxy/prompts/prompt_endpoints.py#L623-L659","documentation":"Authorization failure on prompt fetch: the key's metadata restricts access to a list of allowed prompt IDs and the requested prompt_id is not in it, so the caller is refused with their role and allowed list echoed.","triggerScenarios":"Thrown at litellm/proxy/prompts/prompt_endpoints.py:641 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use a key whose allowed prompts include this prompt, or a proxy admin key.","Ask an admin to grant the key/role access to the prompt."],"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"}