Skip to main content

memory.delete

Permanently deletes a memory from the database.

Parameters

id
string
required
UUID of the memory to delete

Response

success
boolean
Returns true if the memory was successfully deleted

Examples

await client.memory.delete.mutate({
  id: '550e8400-e29b-41d4-a716-446655440000',
});

console.log('Memory deleted');
{
  "success": true
}
Deletion is permanent and cannot be undone. Make sure you have the correct memory ID before deleting.

Use Cases

// User says "forget that I like TypeScript"
const memories = await client.memory.search.query({
  userId: 'user-123',
  query: 'TypeScript preference',
  threshold: 0.9,
});

if (memories.length > 0) {
  await client.memory.delete.mutate({
    id: memories[0].id,
  });
}
// Delete all memories for a user
const memories = await client.memory.getAll.query({
  userId: 'user-123',
});

for (const memory of memories) {
  await client.memory.delete.mutate({
    id: memory.id,
  });
}
// Delete old memories
const memories = await client.memory.getAll.query({
  userId: 'user-123',
});

const sixMonthsAgo = Date.now() - 6 * 30 * 24 * 60 * 60 * 1000;

for (const memory of memories) {
  if (new Date(memory.createdAt).getTime() < sixMonthsAgo) {
    await client.memory.delete.mutate({ id: memory.id });
  }
}