Entity IDs vs. graph entities. This page covers the
user_id / agent_id / app_id / run_id identifiers used to scope memories. These are different from the graph entities (the people, places, and concepts surfaced in Graph Memory).You’ll use this when…
- You run assistants for multiple customers who each need private memory spaces
- Different agents (like a planner and a critic) need separate context for the same user
- Sessions should expire on their own schedule, making debugging and data removal more precise
Configure access
client.project.get() to verify your connection. It should return your project details including org_id and project_id. If you get a 401 error, generate a new API key in the Mem0 dashboard.
Feature anatomy
- Writes (
client.add) accept any combination of these fields. Absent fields default tonull. - Reads (
client.search,client.get_all, exports, deletes) accept the same identifiers inside thefiltersJSON object. - Implicit null scoping: Passing only
{"user_id": "alice"}automatically restricts results to records whereagent_id,app_id, andrun_idarenull. Add wildcards ("*"), explicit lists, or additional filters when you need broader joins.
Choose the right identifier
For more detailed examples, see the Partition Memories by Entity cookbook.
Configure it
The example below adds memories with entity tags:POST /v1/memories/ with the same identifiers in the JSON body. See the Add Memories API reference for REST details.
See it in action
1. Store scoped memoriesWildcards (
"*") include only non-null values. Use them when you want “any agent” or “any user” without limiting results to null-only records.A successful delete returns
{"message": "Memories deleted successfully!"}. Run the previous get_all call again to confirm the session memories were removed.Verify the feature is working
- Run
client.searchwith your filters and confirm only expected memories appear. Mismatched identifiers usually mean a typo in your scoping. - Check the Mem0 dashboard filter pills. User, agent, app, and run should all show populated values for your memory entry.
- Call
client.delete_allwith a uniquerun_idand confirm other sessions remain intact (the count inget_allshould only drop for that run).
Best practices
- Use consistent identifier formats (like
team-alphaorapp-ios-retail) so you can query or delete entire groups later - When debugging, print your filters before each call to verify wildcards (
"*"), lists, and run IDs are spelled correctly - Combine entity filters with metadata filters (categories, created_at) for precise exports or audits
- Use
run_idfor temporary sessions like support tickets or experiments, then schedule cleanup jobs to delete them