Overview

Memories can become outdated, irrelevant, or need to be removed for privacy or compliance reasons. Mem0 offers flexible ways to delete memory:

  1. Delete a Single Memory: Using a specific memory ID
  2. Batch Delete: Delete multiple known memory IDs (up to 1000)
  3. Filtered Delete: Delete memories matching a filter (e.g., user_id, metadata, run_id)

This page walks through code example for each method.

Use Cases

  • Forget a user’s past preferences by request
  • Remove outdated or incorrect memory entries
  • Clean up memory after session expiration
  • Comply with data deletion requests (e.g., GDPR)

1. Delete a Single Memory by ID

from mem0 import MemoryClient

client = MemoryClient(api_key="your-api-key")

memory_id = "your_memory_id"
client.delete(memory_id=memory_id)

2. Batch Delete Multiple Memories

from mem0 import MemoryClient

client = MemoryClient(api_key="your-api-key")

delete_memories = [
    {"memory_id": "id1"},
    {"memory_id": "id2"}
]

response = client.batch_delete(delete_memories)
print(response)

3. Delete Memories by Filter (e.g., user_id)

from mem0 import MemoryClient

client = MemoryClient(api_key="your-api-key")

# Delete all memories for a specific user
client.delete_all(user_id="alice")

You can also filter by other parameters such as:

  • agent_id
  • run_id
  • metadata (as JSON string)

Key Differences

MethodUse WhenIDs NeededFilters
delete(memory_id)You know exactly which memory to remove
batch_delete([...])You have a known list of memory IDs
delete_all(...)You want to delete by user/agent/run/etc

More Details

For request/response schema and additional filtering options, see:

You’ve now seen how to add, search, update, and delete memories in Mem0.


Need help?

If you have any questions, please feel free to reach out to us using one of the following methods: