docs/core-concepts/memory-operations/delete.mdx
Deleting memories is how you honor compliance requests, undo bad data, or clean up expired sessions. Mem0 lets you delete a specific memory, a list of IDs, or everything that matches a filter.
<Info> **Why it matters** - Satisfies user erasure (GDPR/CCPA) without touching the rest of your data. - Keeps knowledge bases accurate by removing stale or incorrect facts. - Works for both the managed Platform API and the OSS SDK. </Info>add/search identifying the record to delete.client = MemoryClient(api_key="your-api-key")
memory_id = "your_memory_id" client.delete(memory_id=memory_id)
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
client.delete("your_memory_id")
.then(result => console.log(result))
.catch(error => console.error(error));
client = MemoryClient(api_key="your-api-key")
delete_memories = [ {"memory_id": "id1"}, {"memory_id": "id2"} ]
response = client.batch_delete(delete_memories) print(response)
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
const deleteMemories = [
{ memory_id: "id1" },
{ memory_id: "id2" }
];
client.batchDelete(deleteMemories)
.then(response => console.log('Batch delete response:', response))
.catch(error => console.error(error));
client = MemoryClient(api_key="your-api-key")
client.delete_all(user_id="alice")
client.delete_all(agent_id="support-bot")
client.delete_all(run_id="session-xyz")
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
client.deleteAll({ userId: "alice" })
.then(result => console.log(result))
.catch(error => console.error(error));
You can also filter by other parameters such as:
agent_idrun_idmetadata (as JSON string)Setting a filter to "*" deletes all memories for that entity type across the entire project. This is an intentionally explicit opt-in to bulk deletion.
client = MemoryClient(api_key="your-api-key")
client.delete_all(user_id="*")
client.delete_all(agent_id="*")
client.delete_all(user_id="", agent_id="", app_id="", run_id="")
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
// Delete all memories across every user in the project
client.deleteAll({ userId: "*" })
.then(result => console.log(result))
.catch(error => console.error(error));
// Full project wipe: all four filters must be explicitly set to "*"
client.deleteAll({ userId: "*", agentId: "*", appId: "*", runId: "*" })
.then(result => console.log(result))
.catch(error => console.error(error));
memory = Memory()
memory.delete(memory_id="mem_123") memory.delete_all(user_id="alice")
```typescript TypeScript
import { Memory } from "mem0ai/oss";
const memory = new Memory();
await memory.delete("mem_123");
await memory.deleteAll({ userId: "alice" });
| Method | Use when | IDs required | Filters |
|---|---|---|---|
delete(memory_id) | You know the exact record | ✔️ | ✖️ |
batch_delete([...]) | You have a list of IDs to purge | ✔️ | ✖️ |
delete_all(...) | You need to forget a user/agent/run | ✖️ | ✔️ |