> ## Documentation Index
> Fetch the complete documentation index at: https://memos-api.openmem.net/llms.txt
> Use this file to discover all available pages before exploring further.

# Add memories

> Add memories for a specific user.

This endpoint uses the class-based AddHandler for better code organization.



## OpenAPI

````yaml mintdocs/openapi.json post /product/add
openapi: 3.1.0
info:
  title: MemOS API
  version: 1.0.0
servers: []
security: []
paths:
  /product/add:
    post:
      tags:
        - Server API
      summary: Add memories
      description: >-
        Add memories for a specific user.


        This endpoint uses the class-based AddHandler for better code
        organization.
      operationId: add_memories_product_add_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/APIADDRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MemoryResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    APIADDRequest:
      properties:
        user_id:
          type: string
          title: User Id
          description: User ID
        session_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Session Id
          description: Session ID. If not provided, a default session will be used.
        task_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Task Id
          description: Task ID for monitering async tasks
        writable_cube_ids:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Writable Cube Ids
          description: List of cube IDs user can write for multi-cube add
        async_mode:
          type: string
          enum:
            - async
            - sync
          title: Async Mode
          description: >-
            Whether to add memory in async mode. Use 'async' to enqueue
            background add (non-blocking), or 'sync' to add memories in the
            current call. Default: 'async'.
          default: async
        mode:
          anyOf:
            - type: string
              enum:
                - fast
                - fine
            - type: 'null'
          title: Mode
          description: >-
            (Internal) Add mode used only when async_mode='sync'. If set to
            'fast', the handler will use a fast add pipeline. Ignored when
            async_mode='async'.
        custom_tags:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Custom Tags
          description: >-
            Custom tags for this add request, e.g. ['Travel', 'family']. These
            tags can be used as filters in search.
        info:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Info
          description: >-
            Additional metadata for the add request. All keys can be used as
            filters in search. Example: {'agent_id': 'xxxxxx', 'app_id': 'xxxx',
            'source_type': 'web', 'source_url': 'https://www.baidu.com',
            'source_content': '西湖是杭州最著名的景点'}.
        messages:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionSystemMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionUserMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionAssistantMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionToolMessageParam'
              type: array
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
                  - $ref: '#/components/schemas/File'
              type: array
            - type: 'null'
          title: Messages
          description: >-
            List of messages to store. Supports: - system / user / assistant
            messages with 'content' and 'chat_time'; - tool messages
            including:   * tool_description (name, description, parameters),   *
            tool_input (call_id, name, argument),   * raw tool messages where
            content is str or list[str],   * tool_output with structured output
            items     (input_text / input_image / input_file, etc.). Also
            supports pure input items when there is no dialog.
        chat_history:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionSystemMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionUserMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionAssistantMessageParam'
                  - $ref: '#/components/schemas/ChatCompletionToolMessageParam'
              type: array
            - type: 'null'
          title: Chat History
          description: >-
            Historical chat messages used internally by algorithms. If None,
            internal stored history will be used; if provided (even an empty
            list), this value will be used as-is.
        is_feedback:
          type: boolean
          title: Is Feedback
          description: 'Whether this request represents user feedback. Default: False.'
          default: false
        mem_cube_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Mem Cube Id
          description: >-
            (Deprecated) Target cube ID for this add request (optional for
            developer API).
        memory_content:
          anyOf:
            - type: string
            - type: 'null'
          title: Memory Content
          description: (Deprecated) Plain memory content to store. Prefer using `messages`.
        doc_path:
          anyOf:
            - type: string
            - type: 'null'
          title: Doc Path
          description: (Deprecated / internal) Path to document to store.
        source:
          anyOf:
            - type: string
            - type: 'null'
          title: Source
          description: >-
            (Deprecated) Simple source tag of the memory. Prefer using
            `info.source_type` / `info.source_url`.
        operation:
          anyOf:
            - items:
                $ref: '#/components/schemas/PermissionDict'
              type: array
            - type: 'null'
          title: Operation
          description: (Internal) Operation definitions for multi-cube write permissions.
      type: object
      title: APIADDRequest
      description: Request model for creating memories.
    MemoryResponse:
      properties:
        code:
          type: integer
          title: Code
          description: Response status code
          default: 200
        message:
          type: string
          title: Message
          description: Response message
        data:
          anyOf:
            - items: {}
              type: array
            - type: 'null'
          title: Data
          description: Response data
      type: object
      required:
        - message
      title: MemoryResponse
      description: Response model for memory operations.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ChatCompletionSystemMessageParam:
      properties:
        content:
          anyOf:
            - type: string
            - items:
                $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
              type: array
            - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
          title: Content
        role:
          type: string
          const: system
          title: Role
        name:
          type: string
          title: Name
        chat_time:
          anyOf:
            - type: string
            - type: 'null'
          title: Chat Time
        message_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Message Id
      type: object
      required:
        - content
        - role
      title: ChatCompletionSystemMessageParam
    ChatCompletionUserMessageParam:
      properties:
        content:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
                  - $ref: '#/components/schemas/ChatCompletionContentPartImageParam'
                  - $ref: >-
                      #/components/schemas/ChatCompletionContentPartInputAudioParam
                  - $ref: '#/components/schemas/File'
              type: array
            - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
            - $ref: '#/components/schemas/ChatCompletionContentPartImageParam'
            - $ref: '#/components/schemas/ChatCompletionContentPartInputAudioParam'
            - $ref: '#/components/schemas/File'
          title: Content
        role:
          type: string
          const: user
          title: Role
        name:
          type: string
          title: Name
        chat_time:
          anyOf:
            - type: string
            - type: 'null'
          title: Chat Time
        message_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Message Id
      type: object
      required:
        - content
        - role
      title: ChatCompletionUserMessageParam
    ChatCompletionAssistantMessageParam:
      properties:
        role:
          type: string
          const: assistant
          title: Role
        audio:
          anyOf:
            - $ref: '#/components/schemas/Audio'
            - type: 'null'
        content:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
                  - $ref: '#/components/schemas/ChatCompletionContentPartRefusalParam'
              type: array
            - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
            - $ref: '#/components/schemas/ChatCompletionContentPartRefusalParam'
            - type: 'null'
          title: Content
        refusal:
          anyOf:
            - type: string
            - type: 'null'
          title: Refusal
        tool_calls:
          anyOf:
            - items:
                anyOf:
                  - $ref: >-
                      #/components/schemas/ChatCompletionMessageFunctionToolCallParam
                  - $ref: >-
                      #/components/schemas/ChatCompletionMessageCustomToolCallParam
              type: array
            - $ref: '#/components/schemas/ChatCompletionMessageFunctionToolCallParam'
            - $ref: '#/components/schemas/ChatCompletionMessageCustomToolCallParam'
          title: Tool Calls
        chat_time:
          anyOf:
            - type: string
            - type: 'null'
          title: Chat Time
        message_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Message Id
      type: object
      required:
        - role
      title: ChatCompletionAssistantMessageParam
    ChatCompletionToolMessageParam:
      properties:
        content:
          anyOf:
            - type: string
            - items:
                anyOf:
                  - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
                  - $ref: '#/components/schemas/ChatCompletionContentPartImageParam'
                  - $ref: >-
                      #/components/schemas/ChatCompletionContentPartInputAudioParam
                  - $ref: '#/components/schemas/File'
              type: array
            - $ref: '#/components/schemas/ChatCompletionContentPartTextParam'
            - $ref: '#/components/schemas/ChatCompletionContentPartImageParam'
            - $ref: '#/components/schemas/ChatCompletionContentPartInputAudioParam'
            - $ref: '#/components/schemas/File'
          title: Content
        role:
          type: string
          const: tool
          title: Role
        tool_call_id:
          type: string
          title: Tool Call Id
        chat_time:
          anyOf:
            - type: string
            - type: 'null'
          title: Chat Time
        message_id:
          anyOf:
            - type: string
            - type: 'null'
          title: Message Id
      type: object
      required:
        - content
        - role
        - tool_call_id
      title: ChatCompletionToolMessageParam
    ChatCompletionContentPartTextParam:
      properties:
        text:
          type: string
          title: Text
        type:
          type: string
          const: text
          title: Type
      type: object
      required:
        - text
        - type
      title: ChatCompletionContentPartTextParam
    File:
      properties:
        file:
          $ref: '#/components/schemas/FileFile'
        type:
          type: string
          const: file
          title: Type
      type: object
      required:
        - file
        - type
      title: File
    PermissionDict:
      properties:
        permissions:
          items:
            type: string
            enum:
              - read
              - write
              - delete
              - execute
          type: array
          title: Permissions
        mem_cube_id:
          type: string
          title: Mem Cube Id
      type: object
      title: PermissionDict
      description: Typed dictionary for chat message dictionaries.
    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
    ChatCompletionContentPartImageParam:
      properties:
        image_url:
          $ref: '#/components/schemas/ImageURL'
        type:
          type: string
          const: image_url
          title: Type
      type: object
      required:
        - image_url
        - type
      title: ChatCompletionContentPartImageParam
    ChatCompletionContentPartInputAudioParam:
      properties:
        input_audio:
          $ref: '#/components/schemas/InputAudio'
        type:
          type: string
          const: input_audio
          title: Type
      type: object
      required:
        - input_audio
        - type
      title: ChatCompletionContentPartInputAudioParam
    Audio:
      properties:
        id:
          type: string
          title: Id
      type: object
      required:
        - id
      title: Audio
    ChatCompletionContentPartRefusalParam:
      properties:
        refusal:
          type: string
          title: Refusal
        type:
          type: string
          const: refusal
          title: Type
      type: object
      required:
        - refusal
        - type
      title: ChatCompletionContentPartRefusalParam
    ChatCompletionMessageFunctionToolCallParam:
      properties:
        id:
          type: string
          title: Id
        function:
          $ref: '#/components/schemas/Function'
        type:
          type: string
          const: function
          title: Type
      type: object
      required:
        - id
        - function
        - type
      title: ChatCompletionMessageFunctionToolCallParam
    ChatCompletionMessageCustomToolCallParam:
      properties:
        id:
          type: string
          title: Id
        custom:
          $ref: '#/components/schemas/Custom'
        type:
          type: string
          const: custom
          title: Type
      type: object
      required:
        - id
        - custom
        - type
      title: ChatCompletionMessageCustomToolCallParam
    FileFile:
      properties:
        file_data:
          type: string
          title: File Data
        file_id:
          type: string
          title: File Id
        filename:
          type: string
          title: Filename
      type: object
      title: FileFile
    ImageURL:
      properties:
        url:
          type: string
          title: Url
        detail:
          type: string
          enum:
            - auto
            - low
            - high
          title: Detail
      type: object
      required:
        - url
      title: ImageURL
    InputAudio:
      properties:
        data:
          type: string
          title: Data
        format:
          type: string
          enum:
            - wav
            - mp3
          title: Format
      type: object
      required:
        - data
        - format
      title: InputAudio
    Function:
      properties:
        arguments:
          type: string
          title: Arguments
        name:
          type: string
          title: Name
      type: object
      required:
        - arguments
        - name
      title: Function
    Custom:
      properties:
        input:
          type: string
          title: Input
        name:
          type: string
          title: Name
      type: object
      required:
        - input
        - name
      title: Custom

````