POST
/
api
/
v1
/
memories
/
forget
Forget
curl --request POST \
  --url https://api.agent-mind.com/api/v1/memories/forget \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "<string>",
  "user_id": "<string>",
  "limit": 123,
  "confirm_all": true
}'

Overview

Intelligently forget or delete memories that match a specific query. This endpoint allows you to remove memories based on natural language queries, making it easy to clean up outdated or irrelevant information.

Request Body

query
string
required
Natural language query to identify memories to forget. The system will find and delete memories matching this query.
user_id
string
Limit deletion to memories associated with a specific user.
limit
integer
default:"10"
Maximum number of memories to delete in a single request. Default is 10.
confirm_all
boolean
default:"false"
If true, deletes all matching memories without limit. Use with caution.

Response

Returns information about the memories that were deleted.

Examples

Basic Forget Operation

import requests

url = "https://api.agent-mind.com/api/v1/memories/forget"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "query": "old error messages",
    "limit": 5
}

response = requests.post(url, json=data, headers=headers)
result = response.json()

User-Specific Forget

data = {
    "query": "temporary preferences",
    "user_id": "user_123",
    "limit": 10
}

response = requests.post(url, json=data, headers=headers)

Delete All Matching (Use Carefully)

data = {
    "query": "test data",
    "user_id": "test_user",
    "confirm_all": True
}

response = requests.post(url, json=data, headers=headers)

Response Example

{
  "deleted_count": 3,
  "deleted_memories": [
    {
      "id": "mem_abc123",
      "content": "Error: Connection timeout",
      "deleted_at": "2024-03-20T14:30:00Z"
    },
    {
      "id": "mem_def456",
      "content": "Error: Rate limit exceeded",
      "deleted_at": "2024-03-20T14:30:00Z"
    },
    {
      "id": "mem_ghi789",
      "content": "Error: Invalid token",
      "deleted_at": "2024-03-20T14:30:00Z"
    }
  ],
  "status": "success"
}

Error Responses

400 Bad Request

{
  "error": "Query parameter is required"
}

401 Unauthorized

{
  "error": "Invalid or missing API key"
}

404 Not Found

{
  "error": "No memories found matching the query"
}

500 Internal Server Error

{
  "error": "Failed to forget memories"
}