> ## Documentation Index
> Fetch the complete documentation index at: https://cortex-ad5578da.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete User Memory

> Permanently remove a specific user memory from storage.

    This API allows you to delete a user memory by its unique identifier.
    Once deleted, the memory cannot be recovered, so use this operation carefully.

    The memory will be removed from your tenant's storage and will no longer
    appear in search results or memory listings.

export const TableOfContents = ({title = 'On this page', items, minHeadingLevel = 2, maxHeadingLevel = 3, className = '', activeClassName = 'text-primary dark:text-primary-light border-primary dark:border-primary-light hover:border-primary dark:hover:border-primary-light', inactiveClassName = 'hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-300'}) => {
  const [toc, setToc] = useState(items ?? []);
  const [activeId, setActiveId] = useState('');
  useEffect(() => {
    if (items && items.length) return;
    if (typeof document === 'undefined') return;
    const selectors = [];
    for (let lvl = minHeadingLevel; lvl <= maxHeadingLevel; lvl++) {
      selectors.push(`h${lvl}`);
    }
    const nodes = Array.from(document.querySelectorAll(selectors.join(','))).filter(el => el.id);
    const built = [];
    let currentTop = null;
    nodes.forEach(el => {
      const level = Number(el.tagName.slice(1));
      const node = {
        id: el.id,
        label: el.textContent.trim(),
        href: `#${el.id}`,
        children: []
      };
      if (level === minHeadingLevel) {
        built.push(node);
        currentTop = node;
      } else if (level > minHeadingLevel && currentTop) {
        currentTop.children.push(node);
      } else {
        built.push(node);
      }
    });
    setToc(built);
  }, [items, minHeadingLevel, maxHeadingLevel]);
  useEffect(() => {
    if (typeof document === 'undefined') return;
    const applyHash = () => {
      const h = window.location.hash.replace('#', '');
      if (h) setActiveId(h);
    };
    applyHash();
    const observer = new IntersectionObserver(entries => {
      entries.forEach(entry => {
        if (entry.isIntersecting) {
          setActiveId(entry.target.id);
        }
      });
    }, {
      rootMargin: '0px 0px -70% 0px',
      threshold: 0.1
    });
    const ids = toc.flatMap(i => [i, ...i.children ?? []]).map(i => i.id);
    ids.forEach(id => {
      const el = document.getElementById(id);
      if (el) observer.observe(el);
    });
    window.addEventListener('hashchange', applyHash);
    return () => {
      window.removeEventListener('hashchange', applyHash);
      observer.disconnect();
    };
  }, [toc]);
  const Item = ({node, depth = 0}) => {
    const isActive = activeId === node.id;
    return <li className="toc-item relative ml-6" data-depth={depth}>
        <a href={node.href} className={`py-1 block font-medium ${isActive ? activeClassName : inactiveClassName}`} style={depth > 0 ? {
      marginLeft: `${depth}rem`
    } : {}} onClick={() => setActiveId(node.id)}>
          {node.label}
        </a>
        {node.children && node.children.length > 0 && <>
            {node.children.map(child => <Item node={child} depth={depth + 1} key={child.href} />)}
          </>}
      </li>;
  };
  const data = toc && toc.length ? toc : items || [];
  return <div className={`text-gray-600 text-sm leading-6 w-[18rem] pb-4 -mt-10 pt-10 hidden xl:block ${className}`} id="table-of-contents-custom">
      <ul id="table-of-contents-custom-content" className="toc">
        <li className="toc-item relative">
          <div className="text-gray-700 dark:text-gray-300 font-medium flex items-center space-x-2 py-1">
            <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="2" xmlns="http://www.w3.org/2000/svg" className="h-3 w-3">
              <path d="M2.44434 12.6665H13.5554" strokeLinecap="round" strokeLinejoin="round"></path>
              <path d="M2.44434 3.3335H13.5554" strokeLinecap="round" strokeLinejoin="round"></path>
              <path d="M2.44434 8H7.33323" strokeLinecap="round" strokeLinejoin="round"></path>
            </svg>
            <span>{title}</span>
          </div>
        </li>
        {data.map(node => <Item node={node} key={node.href} />)}
      </ul>
    </div>;
};

<Panel>
  <TableOfContents />
</Panel>

<Tip> Hit the `Try it` button to try this API now in our playground. It's the best way to check the full request and response in one place, customize your parameters, and generate ready-to-use code snippets.</Tip>

### Examples

<Tabs>
  <Tab title="API Request">
    ```bash theme={null}
    curl -X 'DELETE' \
      'https://api.usecortex.ai/memories/delete-memory?tenant_id=tenant_123&memory_id=memory_123' \
      -H 'accept: application/json'
      --header 'Authorization: Bearer YOUR_API_KEY'
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    const result = await client.userMemory.deleteUserMemory({
      tenant_id: "tenant_1234",
      memory_id: "memory_1234",
      sub_tenant_id: "sub_tenant_4567"
    });
    ```
  </Tab>

  <Tab title="Python (Sync)">
    ```python theme={null}
    # Async usage is similar, just use async_client and await
    result = client.user_memory.delete_user_memory(
        tenant_id="tenant_1234",
        memory_id="memory_1234",
        sub_tenant_id="sub_tenant_4567"
    )
    ```
  </Tab>
</Tabs>

## Overview

The Delete User Memory endpoint allows you to remove specific memories from a user's memory profile. This is useful for maintaining data quality, removing outdated information, or giving users control over their stored personal data.

## Functionality

* **Targeted Deletion**: Removes a specific memory using its unique memory ID
* **User Context Validation**: Ensures the memory belongs to the authenticated user
* **Immediate Removal**: Permanently deletes the memory from the vector store
* **Confirmation Response**: Returns clear success/failure status for the deletion operation
* **Tenant Isolation**: Operates within the specified tenant/sub-tenant context

## Use Cases

* **Data Cleanup**: Remove outdated or incorrect memories
* **Privacy Compliance**: Allow users to delete their personal data
* **Memory Management**: Maintain high-quality memory profiles by removing irrelevant information
* **Error Correction**: Delete memories that were added incorrectly
* **User Control**: Give users the ability to manage their own memory data

## Important Notes

<Warning>
  **Permanent Deletion**: Once a memory is deleted, it cannot be recovered. Make sure you have the correct memory ID before proceeding with deletion.
</Warning>

<Note>
  **Memory ID Source**: Memory IDs (source\_id) can be obtained from the [List User Memories](/api-reference/endpoint/list-user-memories) endpoint or from the response of [Add User Memory](/api-reference/endpoint/add-user-memory) and [Generate User Memory](/api-reference/endpoint/generate-user-memory) endpoints.
</Note>

<Info>
  **Best Practices**:

  * Always verify the memory content before deletion using the List endpoint
  * Consider implementing user confirmation for memory deletion
  * Log deletion activities for audit purposes
  * Provide users with a way to review their memories before deletion
</Info>

<Tip>
  **Pro Tip**: For bulk memory management, you can combine this API with the List API to create a memory management interface that allows users to review and selectively delete their memories.
</Tip>

## Response Fields

| Field                 | Type    | Description                                                   |
| --------------------- | ------- | ------------------------------------------------------------- |
| `success`             | boolean | Indicates whether the operation was successful                |
| `user_memory_deleted` | boolean | Confirms whether the specific memory was successfully deleted |

## Parameters

| Parameter       | Type   | Required | Description                               |
| --------------- | ------ | -------- | ----------------------------------------- |
| `tenant_id`     | string | Yes      | Primary organizational identifier         |
| `sub_tenant_id` | string | Yes      | Secondary organizational identifier       |
| `memory_id`     | string | Yes      | Unique identifier of the memory to delete |

## Error Responses

All endpoints return consistent error responses following the standard format. For detailed error information, see our [Error Responses](/api-reference/error-responses) documentation.


## OpenAPI

````yaml DELETE /memories/delete-memory
openapi: 3.1.0
info:
  title: Cortex SDK API
  description: REST APIs for Cortex AI retrieval engine
  version: 0.0.1
servers:
  - url: /
    description: Local
    x-fern-server-name: cortex-backend-local
  - url: https://api.usecortex.ai
    description: Production
    x-fern-server-name: cortex-prod
    x-fern-audiences:
      - public
  - url: https://preprod.usecortex.ai
    description: Staging
    x-fern-server-name: cortex-staging
security: []
paths:
  /memories/delete-memory:
    delete:
      tags:
        - Memories
      summary: Delete user memory
      description: |-
        Permanently remove a specific user memory from storage.

            This API allows you to delete a user memory by its unique identifier.
            Once deleted, the memory cannot be recovered, so use this operation carefully.

            The memory will be removed from your tenant's storage and will no longer
            appear in search results or memory listings.
      operationId: delete_user_memory_memories_delete_memory_delete
      parameters:
        - name: tenant_id
          in: query
          required: true
          schema:
            type: string
            title: Tenant Id
            description: Tenant ID
            example: tenant_1234
          description: Tenant ID
        - name: memory_id
          in: query
          required: true
          schema:
            type: string
            description: Unique identifier of the memory to delete
            title: Memory Id
            example: memory_1234
          description: Unique identifier of the memory to delete
        - name: sub_tenant_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Sub Tenant Id
            description: Sub-tenant ID
            example: sub_tenant_4567
          description: Sub-tenant ID
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DeleteUserMemoryResponse'
        '400':
          description: Bad Request - Invalid input parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '401':
          description: Unauthorized - Authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '403':
          description: Forbidden - Access denied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '404':
          description: Not Found - Resource does not exist
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '422':
          description: Unprocessable Entity - Validation failed
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
        '503':
          description: Service Unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ActualErrorResponse'
      security:
        - HTTPBearer: []
components:
  schemas:
    DeleteUserMemoryResponse:
      properties:
        success:
          type: boolean
          title: Success
          description: Indicates whether the memory deletion operation was successful
          default: true
          example: true
        user_memory_deleted:
          type: boolean
          title: User Memory Deleted
          description: Confirms whether the specific memory was successfully deleted
          example: true
      type: object
      required:
        - user_memory_deleted
      title: DeleteUserMemoryResponse
      description: Response model for deleting a user memory.
    ActualErrorResponse:
      properties:
        detail:
          $ref: '#/components/schemas/ErrorResponse'
      type: object
      required:
        - detail
      title: ActualErrorResponse
    ErrorResponse:
      properties:
        success:
          type: boolean
          title: Success
          default: false
        message:
          type: string
          minLength: 1
          title: Message
          default: Error occurred
        error_code:
          anyOf:
            - type: string
            - type: 'null'
          title: Error Code
      type: object
      title: ErrorResponse
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````