{"record":{"id":"29366c49787f869d","repo":"mem0ai/mem0","slug":"admin-role-required-to-list-all-memories","errorCode":null,"errorMessage":"Admin role required to list all memories.","messagePattern":"Admin role required to list all memories\\.","errorType":"http","errorClass":"HTTPException","httpStatus":403,"severity":"error","filePath":"server/main.py","lineNumber":426,"sourceCode":"    return {\"results\": [_serialize_memory(row) for row in rows]}\n\n\n@app.get(\"/memories\", summary=\"Get memories\")\ndef get_all_memories(\n    request: Request,\n    user_id: Optional[str] = None,\n    run_id: Optional[str] = None,\n    agent_id: Optional[str] = None,\n    top_k: Optional[int] = Query(None, ge=0, le=ALL_MEMORIES_LIMIT),\n    show_expired: bool = Query(False),\n    _auth=Depends(verify_auth),\n):\n    \"\"\"Retrieve stored memories. Lists all memories when no identifier is provided (admin only).\"\"\"\n    try:\n        if not any([user_id, run_id, agent_id]):\n            auth_type = getattr(request.state, \"auth_type\", \"none\")\n            if _auth is not None and _auth.role != \"admin\" and auth_type not in {\"admin_api_key\", \"disabled\"}:\n                raise HTTPException(status_code=403, detail=\"Admin role required to list all memories.\")\n            # Admin all-memory listing is intentionally raw; scoped get_all below applies expiry visibility.\n            return _list_all_memories(limit=top_k if top_k is not None else ALL_MEMORIES_LIMIT)\n        filters = {\n            k: v for k, v in {\"user_id\": user_id, \"run_id\": run_id, \"agent_id\": agent_id}.items() if v\n        }\n        params = {\"filters\": filters}\n        if top_k is not None:\n            params[\"top_k\"] = top_k\n        params[\"show_expired\"] = show_expired\n        return get_memory_instance().get_all(**params)\n    except HTTPException:\n        raise\n    except Exception:\n        raise upstream_error()\n\n\n@app.get(\"/memories/{memory_id}\", summary=\"Get a memory\")\ndef get_memory(memory_id: str, _auth=Depends(verify_auth)):","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/server/main.py#L408-L444","documentation":"Error \"Admin role required to list all memories.\" thrown in mem0ai/mem0.","triggerScenarios":"Thrown at server/main.py:426 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an admin account to list all memories, or query with your own user_id."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}