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

# Replace Memory

> Replace an existing memory with new content.

This completely replaces the memory content while preserving the memory ID.
Unlike update, this requires all fields to be provided and replaces the entire memory.
The original creation timestamp is preserved, but updated_at is set to now.

Only the memory owner can replace their memories.



## OpenAPI

````yaml api-reference/openapi.json post /api/v1/memories/{memory_id}/replace
openapi: 3.1.0
info:
  title: FastAPI app
  version: 0.1.0
servers: []
security: []
paths:
  /api/v1/memories/{memory_id}/replace:
    post:
      tags:
        - Memory
      summary: Replace Memory
      description: >-
        Replace an existing memory with new content.


        This completely replaces the memory content while preserving the memory
        ID.

        Unlike update, this requires all fields to be provided and replaces the
        entire memory.

        The original creation timestamp is preserved, but updated_at is set to
        now.


        Only the memory owner can replace their memories.
      operationId: replace_memory_api_v1_memories__memory_id__replace_post
      parameters:
        - name: memory_id
          in: path
          required: true
          schema:
            type: string
            title: Memory Id
        - 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
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MemoryReplace'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemoryReplaceResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - DualAuthScheme: []
components:
  schemas:
    MemoryReplace:
      properties:
        user_id:
          anyOf:
            - type: string
            - type: 'null'
          title: User Id
          description: The user ID who owns the memory.
        memory:
          type: string
          title: Memory
          description: The new memory content to replace the existing one.
        topics:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Topics
          description: New topics for the memory.
        metadata:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Metadata
          description: New metadata for the memory.
      type: object
      required:
        - memory
      title: MemoryReplace
      description: Schema for replacing a memory.
    MemoryReplaceResponse:
      properties:
        memory_id:
          type: string
          title: Memory Id
          description: ID of the replaced memory.
        message:
          type: string
          title: Message
          description: Success message.
        old_memory:
          $ref: '#/components/schemas/MemoryResponse'
          description: The old memory details.
        new_memory:
          $ref: '#/components/schemas/MemoryResponse'
          description: The new memory details.
      type: object
      required:
        - memory_id
        - message
        - old_memory
        - new_memory
      title: MemoryReplaceResponse
      description: Schema for memory replacement response.
    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

````