Skip to main content

DELETE /memory/

Delete a specific memory by its unique identifier.

Path Parameters

memory_id
string
required
The unique identifier of the memory to delete.

Response

success
boolean
Indicates whether the operation was successful.
result
object
Confirmation of the deletion operation.

Example Request

curl -X DELETE http://localhost:8000/memory/mem_abc123

Example Response

{
  "success": true,
  "result": {
    "message": "Memory deleted successfully"
  }
}

Error Responses

detail
string
Error message describing what went wrong.
500 Internal Server Error
{
  "detail": "Memory not found or deletion failed"
}

DELETE /memory/user/

Delete all memories for a specific user. This is a destructive operation that removes all stored memories associated with the user ID.
This operation is irreversible. All memories for the user will be permanently deleted.

Path Parameters

user_id
string
required
The unique identifier of the user whose memories should be deleted.

Response

success
boolean
Indicates whether the operation was successful.
result
object
Confirmation of the deletion operation.

Example Request

curl -X DELETE http://localhost:8000/memory/user/user_123

Example Response

{
  "success": true,
  "result": {
    "message": "All memories deleted successfully",
    "deleted_count": 42
  }
}

Use Cases

User Account Deletion When a user deletes their account, remove all their memories:
curl -X DELETE http://localhost:8000/memory/user/user_123
Privacy Compliance Handle GDPR “right to be forgotten” requests:
curl -X DELETE http://localhost:8000/memory/user/user_456
Testing & Development Clear test data between test runs:
curl -X DELETE http://localhost:8000/memory/user/test_user_001

Selective Deletion

Currently, the API doesn’t support selective deletion by memory type (e.g., delete only SHORT_TERM memories). To achieve this, you would need to:
  1. Search for memories with the specific type filter
  2. Delete each memory individually using /memory/{memory_id}
Example: Delete All Short-Term Memories
# Step 1: Get all SHORT_TERM memories
curl -X POST http://localhost:8000/memory/get_all \
  -H "Content-Type: application/json" \
  -d '{
    "user_id": "user_123",
    "memory_type": "SHORT_TERM"
  }'

# Step 2: Delete each memory ID from the response
curl -X DELETE http://localhost:8000/memory/mem_abc123
curl -X DELETE http://localhost:8000/memory/mem_def456
# ... etc

Error Responses

500 Internal Server Error
{
  "detail": "Failed to delete memories"
}
Common Error Scenarios
  1. Invalid Memory ID: The provided memory doesn’t exist (single delete)
  2. User Not Found: No memories found for the user ID (user delete)
  3. Database Connection: Failure to connect to the vector store
  4. Partial Deletion: Some memories deleted but operation failed partway through

Implementation Details

  • Single Delete Source: backend/main.py:332
  • User Delete Source: backend/main.py:344
  • Cascade Deletion: Removes vectors from Supabase and relationships from Neo4j (if enabled)
  • Atomic Operations: Single deletes are atomic; user deletes may be partial on errors

Build docs developers (and LLMs) love