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

# Add Memories

> Add memory messages to a project.

    The `types` field in the request specifies which memory types to add to:
    - If `types` is empty or not provided, memories are added to all types (episodic and semantic)
    - If `types` only contains `"episodic"`, memories are added only to Episodic memory
    - If `types` only contains `"semantic"`, memories are added only to Semantic memory
    - If `types` contains both, memories are added to both types

    Each memory message represents a discrete piece of information to be stored
    in the project's memory system. Messages can include content, metadata,
    timestamps, and other contextual details.

    The producer field indicates who created the message, while the
    produced_for field specifies the intended recipient. These fields help
    provide context for the memory and if provided should be user-friendly names.

    The endpoint accepts a batch of messages to be added in a single request.



## OpenAPI

````yaml /openapi.json post /api/v2/memories
openapi: 3.1.0
info:
  title: MemMachine API
  version: 0.3.10
  description: >-
    Architectural Memory Systems for AI Agents. Specialized in episodic and
    semantic memory management with strict namespace isolation.
servers:
  - url: http://localhost:8080
security: []
tags:
  - name: Configuration
    description: System overview and memory subsystem configuration.
  - name: Episodic Configuration
    description: Per-project episodic memory subsystem configuration.
  - name: Memories
    description: Core operations for episodic and semantic memory ingestion and retrieval.
  - name: Projects
    description: Lifecycle management for isolated memory namespaces.
  - name: Resources
    description: Embedder, language model, and reranker lifecycle management.
  - name: 'Semantic Memory: Categories'
    description: Category, template, and tag management for semantic sets.
  - name: 'Semantic Memory: Features'
    description: Add, retrieve, and update individual semantic features.
  - name: 'Semantic Memory: Sets'
    description: Set type and set ID lifecycle, listing, and configuration.
  - name: System
    description: Infrastructure, health, and observability.
paths:
  /api/v2/memories:
    post:
      tags:
        - Memories
      summary: Add Memories
      description: |-
        Add memory messages to a project.

            The `types` field in the request specifies which memory types to add to:
            - If `types` is empty or not provided, memories are added to all types (episodic and semantic)
            - If `types` only contains `"episodic"`, memories are added only to Episodic memory
            - If `types` only contains `"semantic"`, memories are added only to Semantic memory
            - If `types` contains both, memories are added to both types

            Each memory message represents a discrete piece of information to be stored
            in the project's memory system. Messages can include content, metadata,
            timestamps, and other contextual details.

            The producer field indicates who created the message, while the
            produced_for field specifies the intended recipient. These fields help
            provide context for the memory and if provided should be user-friendly names.

            The endpoint accepts a batch of messages to be added in a single request.
      operationId: add_memories
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddMemoriesSpec'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddMemoriesResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    AddMemoriesSpec:
      properties:
        org_id:
          type: string
          title: Org Id
          description: |2-

                The unique identifier of the organization.

                - Must not contain slashes (`/`).
                - Must contain only letters, numbers, underscores, hyphens, colon, and Unicode
                  characters (e.g., Chinese/Japanese/Korean). No slashes or other symbols
                  are allowed.

                This value determines the namespace the project belongs to.
                
          default: universal
          examples:
            - MemVerge
            - AI_Labs
        project_id:
          type: string
          title: Project Id
          description: |2-

                The identifier of the project.

                - Must be unique within the organization.
                - Must not contain slashes (`/`).
                - Must contain only letters, numbers, underscores, hyphens, colon, and Unicode
                  characters (e.g., Chinese/Japanese/Korean). No slashes or other symbols
                  are allowed.

                This ID is used in API paths and resource locations.
                
          default: universal
          examples:
            - memmachine
            - research123
            - qa_pipeline
        types:
          items:
            $ref: '#/components/schemas/MemoryType'
          type: array
          title: Types
          description: |2-

                A list of memory types to include in the search (e.g., episodic, semantic).
                If empty, all available types are searched.
                
          examples:
            - - episodic
              - semantic
        messages:
          items:
            $ref: '#/components/schemas/MemoryMessage'
          type: array
          minItems: 1
          title: Messages
          description: |2-

                A list of messages to be added (batch input).
                Must contain at least one message.
                
      type: object
      required:
        - messages
      title: AddMemoriesSpec
      description: Specification model for adding memories.
    AddMemoriesResponse:
      properties:
        results:
          items:
            $ref: '#/components/schemas/AddMemoryResult'
          type: array
          title: Results
          description: The list of results for each added memory message.
      type: object
      required:
        - results
      title: AddMemoriesResponse
      description: Response model for adding memories.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    MemoryType:
      type: string
      enum:
        - semantic
        - episodic
      title: MemoryType
      description: Memory type.
    MemoryMessage:
      properties:
        content:
          type: string
          title: Content
          description: The content or text of the message.
        producer:
          type: string
          title: Producer
          description: |2-

                The sender of the message. This is a user-friendly name for
                the LLM to understand the message context. Defaults to 'user'.
                
          default: user
        produced_for:
          type: string
          title: Produced For
          description: |2-

                The intended recipient of the message. This is a user-friendly name for
                the LLM to understand the message context. Defaults to an empty string.
                
          default: ''
        timestamp:
          type: string
          format: date-time
          title: Timestamp
          description: |2-

                The timestamp when the message was created, in ISO 8601 format.
                The formats supported are:
                - ISO 8601 string (e.g., '2023-10-01T12:00:00Z' or '2023-10-01T08:00:00-04:00')
                - Unix epoch time in seconds (e.g., 1633072800)
                - Unix epoch time in milliseconds (e.g., 1633072800000)
                If not provided, the server assigns the current time.
                If the format is unrecognized, an error is returned.
                
        role:
          type: string
          title: Role
          description: |2-

                The role of the message in a conversation (e.g., 'user', 'assistant',
                'system'). Optional; defaults to an empty string.
                
          default: ''
        metadata:
          additionalProperties:
            type: string
          type: object
          title: Metadata
          description: |2-

                Additional metadata associated with the message, represented as key-value
                pairs. Optional; defaults to an empty object.
                Retrieval operations may utilize this metadata for filtering.
                Use 'metadata.{key}' to filter based on specific metadata keys.
                
        episode_type:
          anyOf:
            - $ref: '#/components/schemas/EpisodeType'
            - type: 'null'
          description: |2-

                The type of an episode (e.g., 'message').
                
      type: object
      required:
        - content
      title: MemoryMessage
      description: Model representing a memory message.
    AddMemoryResult:
      properties:
        uid:
          type: string
          title: Uid
          description: The unique identifier of the memory message.
      type: object
      required:
        - uid
      title: AddMemoryResult
      description: Response model for adding memories.
    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
    EpisodeType:
      type: string
      enum:
        - message
      title: EpisodeType
      description: Episode type.

````