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

# List Memories

> List memories with cursor-based pagination.

Cursor-based pagination is more efficient for large datasets and handles
data changes better than offset-based pagination.

Args:
    user_id: Optional user ID to filter memories
    cursor: Cursor from previous response for next page (None for first page)
    limit: Number of items per page (default: 50, max: 100)
    sort_by: Field to sort by (default: 'updated_at')
    sort_order: Sort order - 'asc' or 'desc' (default: 'desc')

Returns:
    MemoryListResponse with memories and next_cursor

Examples:
    First page:
        GET /memories?user_id=user_123&limit=50
    
    Next page (using cursor from previous response):
        GET /memories?user_id=user_123&cursor=mem_xyz123&limit=50
    
    Sort by updated_at descending (most recent first):
        GET /memories?user_id=user_123&sort_by=updated_at&sort_order=desc
    
    Sort by memory_id ascending:
        GET /memories?user_id=user_123&sort_by=memory_id&sort_order=asc



## OpenAPI

````yaml api-reference/openapi.json get /api/v1/memories
openapi: 3.1.0
info:
  title: FastAPI app
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/memories:
    get:
      tags:
        - Memory
      summary: List Memories
      description: |-
        List memories with cursor-based pagination.

        Cursor-based pagination is more efficient for large datasets and handles
        data changes better than offset-based pagination.

        Args:
            user_id: Optional user ID to filter memories
            cursor: Cursor from previous response for next page (None for first page)
            limit: Number of items per page (default: 50, max: 100)
            sort_by: Field to sort by (default: 'updated_at')
            sort_order: Sort order - 'asc' or 'desc' (default: 'desc')

        Returns:
            MemoryListResponse with memories and next_cursor

        Examples:
            First page:
                GET /memories?user_id=user_123&limit=50
            
            Next page (using cursor from previous response):
                GET /memories?user_id=user_123&cursor=mem_xyz123&limit=50
            
            Sort by updated_at descending (most recent first):
                GET /memories?user_id=user_123&sort_by=updated_at&sort_order=desc
            
            Sort by memory_id ascending:
                GET /memories?user_id=user_123&sort_by=memory_id&sort_order=asc
      operationId: list_memories_api_v1_memories_get
      parameters:
        - name: user_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: User ID to filter memories
            title: User Id
          description: User ID to filter memories
        - name: cursor
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Cursor for pagination (use next_cursor from previous response)
            title: Cursor
          description: Cursor for pagination (use next_cursor from previous response)
        - name: limit
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
                maximum: 100
                minimum: 1
              - type: 'null'
            description: Number of memories to return per page
            default: 50
            title: Limit
          description: Number of memories to return per page
        - name: sort_by
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Field to sort memories by (e.g., 'memory_id', 'updated_at')
            default: updated_at
            title: Sort By
          description: Field to sort memories by (e.g., 'memory_id', 'updated_at')
        - name: sort_order
          in: query
          required: false
          schema:
            anyOf:
              - $ref: '#/components/schemas/SortOrder'
              - type: 'null'
            description: Sort order (asc or desc)
            default: desc
            title: Sort Order
          description: Sort order (asc or desc)
        - name: X-Workspace-Id
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: The workspace ID
            title: X-Workspace-Id
          description: The workspace ID
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemoryListResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - DualAuthScheme: []
components:
  schemas:
    SortOrder:
      type: string
      enum:
        - asc
        - desc
      title: SortOrder
    MemoryListResponse:
      properties:
        memories:
          items:
            $ref: '#/components/schemas/MemoryResponse'
          type: array
          title: Memories
          description: List of memories.
        total_count:
          type: integer
          title: Total Count
          description: Total number of memories returned in this request.
        next_cursor:
          anyOf:
            - type: string
            - type: 'null'
          title: Next Cursor
          description: Cursor for fetching the next page. None if no more pages.
        has_more:
          type: boolean
          title: Has More
          description: Whether there are more memories to fetch.
          default: false
      type: object
      required:
        - memories
        - total_count
      title: MemoryListResponse
      description: Schema for listing memories with cursor-based pagination.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MemoryResponse:
      properties:
        memory_id:
          type: string
          title: Memory Id
          description: Unique identifier for the memory.
        user_id:
          type: string
          title: User Id
          description: User ID who owns the memory.
        memory:
          type: string
          title: Memory
          description: The memory content.
        topics:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Topics
          description: Topics associated with the memory.
        created_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Created At
          description: When the memory was created.
        updated_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Updated At
          description: When the memory was last updated.
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: Additional metadata for the memory.
      type: object
      required:
        - memory_id
        - user_id
        - memory
      title: MemoryResponse
      description: Schema for memory response.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    DualAuthScheme:
      type: http
      scheme: bearer

````