> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memsync.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Memory

> Permanently delete a memory entry and its associated embeddings

Permanently removes a memory entry from the user's memory store. This action cannot be undone.

<Warning>
  This operation is irreversible. Once a memory is deleted, it cannot be recovered.
</Warning>

<RequestExample>
  ```bash cURL theme={null}
  curl -X DELETE 'https://api.memchat.io/memories/mem_123abc' \
    -H 'X-API-Key: YOUR_API_KEY'
  ```

  ```python Python theme={null}
  import requests

  url = "https://api.memchat.io/memories/mem_123abc"
  headers = {
      "X-API-Key": "YOUR_API_KEY"
  }

  response = requests.delete(url, headers=headers)
  result = response.json()
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.memchat.io/memories/mem_123abc', {
    method: 'DELETE',
    headers: {
      'X-API-Key': 'YOUR_API_KEY',
    },
  });

  const result = await response.json();
  ```
</RequestExample>

## Path Parameters

<ParamField path="memory_id" type="string" required>
  The unique identifier of the memory to delete
</ParamField>

## Query Parameters

<ParamField query="cascade" type="boolean" default="false">
  Whether to cascade delete related data (e.g., derived insights, profile updates)
</ParamField>

<ParamField query="backup" type="boolean" default="true">
  Whether to create a backup before deletion (for compliance/audit purposes)
</ParamField>

## Response

<ResponseField name="success" type="boolean">
  Indicates if the deletion was successful
</ResponseField>

<ResponseField name="memory_id" type="string">
  ID of the deleted memory
</ResponseField>

<ResponseField name="deleted_at" type="string">
  ISO 8601 timestamp when the memory was deleted
</ResponseField>

<ResponseField name="cascade_deletions" type="object">
  Information about related data that was also deleted (if cascade=true)

  <Expandable title="Cascade Deletions">
    <ResponseField name="profile_updates" type="number">
      Number of profile updates removed
    </ResponseField>

    <ResponseField name="derived_insights" type="number">
      Number of derived insights removed
    </ResponseField>

    <ResponseField name="embeddings" type="number">
      Number of embedding vectors removed
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="backup_id" type="string">
  ID of the backup created (if backup=true)
</ResponseField>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "memory_id": "mem_123abc",
    "deleted_at": "2024-01-15T16:45:00Z",
    "cascade_deletions": {
      "profile_updates": 2,
      "derived_insights": 1,
      "embeddings": 1
    },
    "backup_id": "backup_456def"
  }
  ```
</ResponseExample>

## Error Responses

<ResponseField name="404" type="object">
  Memory not found

  ```json theme={null}
  {
    "error": "Memory not found",
    "code": "MEMORY_NOT_FOUND",
    "memory_id": "mem_123abc"
  }
  ```
</ResponseField>

<ResponseField name="401" type="object">
  Unauthorized access

  ```json theme={null}
  {
    "error": "Invalid or expired token",
    "code": "UNAUTHORIZED"
  }
  ```
</ResponseField>

<ResponseField name="403" type="object">
  Access denied - memory belongs to another user

  ```json theme={null}
  {
    "error": "Access denied",
    "code": "FORBIDDEN"
  }
  ```
</ResponseField>

<ResponseField name="409" type="object">
  Cannot delete - memory is being processed

  ```json theme={null}
  {
    "error": "Memory is currently being processed and cannot be deleted",
    "code": "DELETION_CONFLICT",
    "processing_status": "embedding_generation"
  }
  ```
</ResponseField>

<ResponseField name="500" type="object">
  Internal server error during deletion

  ```json theme={null}
  {
    "error": "Failed to delete memory",
    "code": "DELETION_FAILED",
    "retry_after": 30
  }
  ```
</ResponseField>

## Batch Deletion

For deleting multiple memories at once, use the batch endpoint:

```bash theme={null}
POST /memories/batch-delete
{
  "memory_ids": ["mem_123abc", "mem_456def", "mem_789ghi"],
  "cascade": true,
  "backup": true
}
```

## Recovery Options

While deleted memories cannot be restored through the API, backups are created for compliance purposes:

* **Backups**: Available for 30 days for compliance/audit purposes
* **Contact Support**: For accidental deletions, contact support with the backup\_id
* **Data Export**: Consider using the data export feature before bulk deletions

## Impact on User Profile

Deleting memories may affect:

* **Profile Bio**: Auto-generated bio may be updated
* **Category Profiles**: Statistics and insights for the memory's category
* **Derived Insights**: Any insights based on the deleted memory
* **Search Results**: Memory will no longer appear in search results

Use the `cascade=true` parameter to automatically clean up related data, or `cascade=false` to preserve derived insights for analysis.
