docs/core-concepts/memory-operations/update.mdx
Mem0’s update operation lets you fix or enrich an existing memory without deleting it. When a user changes their preference or clarifies a fact, use update to keep the knowledge base fresh.
add or search results.data is a deprecated alias for text.client = MemoryClient(api_key="your-api-key")
memory_id = "your_memory_id" client.update( memory_id=memory_id, text="Updated memory content about the user", metadata={"category": "profile-update"}, timestamp="2025-01-15T12:00:00Z" )
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
const memory_id = "your_memory_id";
await client.update(memory_id, {
text: "Updated memory content about the user",
metadata: { category: "profile-update" },
timestamp: "2025-01-15T12:00:00Z"
});
Update up to 1000 memories in one call.
<CodeGroup> ```python Python from mem0 import MemoryClientclient = MemoryClient(api_key="your-api-key")
update_memories = [ {"memory_id": "id1", "text": "Watches football"}, {"memory_id": "id2", "text": "Likes to travel"} ]
response = client.batch_update(update_memories) print(response)
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: "your-api-key" });
const updateMemories = [
{ memoryId: "id1", text: "Watches football" },
{ memoryId: "id2", text: "Likes to travel" }
];
client.batchUpdate(updateMemories)
.then(response => console.log('Batch update response:', response))
.catch(error => console.error(error));
memory = Memory()
memory.update( memory_id="mem_123", text="Alex now prefers decaf coffee", )
memory.update( memory_id="mem_123", text="Alex now prefers decaf coffee", metadata={"category": "preferences"}, expiration_date="2030-01-31", )
```javascript JavaScript
import { Memory } from "mem0ai/oss";
const memory = new Memory();
// Replace the content
await memory.update("mem_123", { text: "Alex now prefers decaf coffee" });
// Update content plus metadata and an expiration date (null clears it)
await memory.update("mem_123", {
text: "Alex now prefers decaf coffee",
metadata: { category: "preferences" },
expirationDate: "2030-01-31",
});
// Update metadata only, leaving the stored text untouched
await memory.update("mem_123", { metadata: { category: "preferences" } });
text and metadata together to keep filters accurate.| Capability | Mem0 Platform | Mem0 OSS |
|---|---|---|
| Update call | client.update(memory_id, {...}) | memory.update(memory_id, text=...) |
| Batch updates | client.batch_update (up to 1000 memories) | Script your own loop or bulk job |
| Dashboard visibility | Inspect updates in the UI | Inspect via logs or custom tooling |
| Immutable handling | Returns descriptive error | Raises exception: delete and re-add |