> ## 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.

# List User Memories

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 --request GET \
      --url 'https://api.usecortex.ai/user_memory/list_user_memories?tenant_id=tenant_1234&sub_tenant_id=sub_tenant_4567' \
      --header 'Authorization: Bearer YOUR_API_KEY'
    ```
  </Tab>

  <Tab title="TypeScript">
    ```ts theme={null}
    const memories = await client.userMemory.listUserMemories({
      tenant_id: "tenant_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
    memories = client.user_memory.list_user_memories(
        tenant_id="tenant_1234",
        sub_tenant_id="sub_tenant_4567"
    )
    ```
  </Tab>
</Tabs>

## Overview

Retrieve all stored memories for a specific user within a tenant/sub-tenant combination to view and manage the user's complete memory profile.

## Functionality

* **Complete Memory Retrieval**: Fetches all user memories
* **Tenant-Based Filtering**: Returns memories specific to the provided tenant and sub-tenant combination
* **Simplified Response**: Provides essential memory information including unique IDs and content
* **User Context Integration**: Automatically filters memories based on the authenticated user
* **Memory Management**: Enables you to review and manage stored user memories

## Use Cases

* **Memory Audit**: Review all stored memories for a user to ensure data quality
* **User Profile Overview**: Get a complete picture of what the system knows about a user
* **Memory Management**: Identify memories that may need updating or deletion
* **Debugging**: Troubleshoot issues with user personalization by examining stored memories
* **Data Export**: Retrieve all user memories for data analysis or migration

### With Optional Sub-tenant

```bash theme={null}
curl -X GET "https://api.usecortex.ai/user_memory/list_user_memories?tenant_id=company_123" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json"
```

<Note>
  **Sub-tenant Default**: If no sub\_tenant\_id is provided, the system uses DEFAULT sub-tenant which was created while creating the tenant.
</Note>

## Important Notes

<Warning>
  **Memory Privacy**: This API returns all memories for the authenticated user. Ensure proper access controls are in place to prevent unauthorized access to user memory data.
</Warning>

<Info>
  **Memory IDs**: Each memory has a unique `memory_id` that can be used with the [Delete User Memory](/api-reference/endpoint/delete-user-memory) endpoint to remove specific memories.
</Info>

<Tip>
  **Pro Tip**: Use this API in combination with [Retrieve User Memory](/api-reference/endpoint/retrieve-user-memory) to first search for relevant memories, then list all memories to get the complete context.
</Tip>

## Response Fields

| Field                            | Type    | Description                                    |
| -------------------------------- | ------- | ---------------------------------------------- |
| `success`                        | boolean | Indicates whether the operation was successful |
| `user_memories`                  | array   | List of user memory objects                    |
| `user_memories[].source_id`      | string  | Unique identifier for the memory               |
| `user_memories[].source_content` | string  | The actual content of the memory               |

## 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.
