> ## 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 /platform.openapi.json post /v2/memories
openapi: 3.0.4
info:
  description: >-
    Public REST API for the MemMachine memory system. Manages projects and
    memories.
  title: MemMachine Public API
  version: 0.1.0
servers:
  - url: https://api.memmachine.ai
security:
  - BearerAuth: []
tags:
  - name: Projects
  - name: Memories
  - name: Metrics
  - name: Health
paths:
  /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: AddMemories
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AddMemoriesSpec'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AddMemoriesResponse'
          description: Successful Response
        default:
          $ref: '#/components/responses/UnexpectedError'
components:
  schemas:
    AddMemoriesSpec:
      allOf:
        - $ref: '#/components/schemas/ProjectScope'
        - properties:
            messages:
              description: |
                A list of messages to be added (batch input).
                Must contain at least one message.
              items:
                $ref: '#/components/schemas/MemoryMessage'
              minItems: 1
              title: Messages
              type: array
            types:
              description: |
                A list of memory types to add (e.g., episodic, semantic).
                If empty, all available types are added.
              example:
                - episodic
                - semantic
              items:
                $ref: '#/components/schemas/MemoryType'
              title: Types
              type: array
          required:
            - messages
          type: object
      description: Specification model for adding memories.
      title: AddMemoriesSpec
    AddMemoriesResponse:
      description: Response model for adding memories.
      properties:
        results:
          description: The list of results for each added memory message.
          items:
            $ref: '#/components/schemas/AddMemoryResult'
          title: Results
          type: array
      required:
        - results
      title: AddMemoriesResponse
      type: object
    ProjectScope:
      properties:
        project_id:
          default: ''
          description: >-
            The identifier of the project. If empty, the user's default project
            is used.
          maxLength: 255
          pattern: ^[\p{L}\p{N}_:-]*$
          title: Project Id
          type: string
          x-go-type-skip-optional-pointer: true
      type: object
    MemoryMessage:
      description: Model representing a memory message.
      properties:
        content:
          description: The content or text of the message.
          title: Content
          type: string
        episode_type:
          $ref: '#/components/schemas/EpisodeType'
        metadata:
          additionalProperties:
            type: string
          description: >
            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.
          title: Metadata
          type: object
        produced_for:
          default: ''
          description: >
            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.
          title: Produced For
          type: string
        producer:
          default: user
          description: |
            The sender of the message. This is a user-friendly name for
            the LLM to understand the message context. Defaults to 'user'.
          title: Producer
          type: string
        role:
          default: ''
          description: >
            The role of the message in a conversation (e.g., 'user',
            'assistant',

            'system'). Optional; defaults to an empty string.
          title: Role
          type: string
        timestamp:
          description: >
            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.
          format: date-time
          title: Timestamp
          type: string
      required:
        - content
      title: MemoryMessage
      type: object
    MemoryType:
      description: Memory type.
      enum:
        - semantic
        - episodic
      title: MemoryType
      type: string
    AddMemoryResult:
      description: Response model for adding memories.
      properties:
        uid:
          description: The unique identifier of the memory message.
          title: Uid
          type: string
      required:
        - uid
      title: AddMemoryResult
      type: object
    Error:
      properties:
        code:
          description: Error code.
          format: int32
          type: integer
        message:
          description: Error message.
          type: string
      required:
        - code
        - message
      type: object
    EpisodeType:
      default: message
      description: Episode type.
      enum:
        - message
      title: EpisodeType
      type: string
  responses:
    UnexpectedError:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      description: Unexpected error.
  securitySchemes:
    BearerAuth:
      scheme: bearer
      type: http

````