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

# Add Files to Memory

> Add a file to a memory

<Warning>
  Please note this endpoint can only be used with memories created on or after
  17-Dec-2024.
</Warning>


## OpenAPI

````yaml POST /memories/add-files
openapi: 3.1.0
info:
  title: duohub Retriever API
  description: >-
    Retrieve assisted or non-assisted memory from a duohub knowledge graph. For
    best performance, use the official `duohub` Python package.
  version: 1.0.0
servers:
  - url: https://api.duohub.ai
security:
  - APIKeyHeader: []
paths:
  /memories/add-files:
    post:
      tags:
        - Memories
      summary: Add Files to Memory
      description: Add a file to a memory
      operationId: addFilesToMemory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - files
                - memoryID
              properties:
                files:
                  type: array
                  items:
                    type: string
                    description: ID of the file to add to the memory
                memoryID:
                  type: string
                  description: ID of the memory to add the file to
            example:
              files:
                - 123e4567-e89b-12d3-a456-426614174000
                - 987fcdeb-51a2-43b7-91fa-987654321000
              memoryID: 987fcdeb-51a2-43b7-91fa-987654321000
      responses:
        '201':
          description: File added to memory successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    enum:
                      - success
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        description: Unique identifier for the sample
                      fileID:
                        type: string
                        description: ID of the file
                      memoryID:
                        type: string
                        description: ID of the memory
                      userID:
                        type: string
                        description: ID of the user
                      type:
                        type: string
                        enum:
                          - human
                          - ai
                          - document
                        description: Type of the sample
                      createdAt:
                        type: string
                        format: date-time
                        description: Creation timestamp
                      updatedAt:
                        type: string
                        format: date-time
                        description: Last update timestamp
                example:
                  status: success
                  data:
                    id: 456e7890-c12d-34e5-b678-426614174000
                    fileID: 123e4567-e89b-12d3-a456-426614174000
                    memoryID: 987fcdeb-51a2-43b7-91fa-987654321000
                    userID: user123
                    type: document
                    createdAt: '2024-01-01T00:00:00.000Z'
                    updatedAt: '2024-01-01T00:00:00.000Z'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                  status:
                    type: string
                    enum:
                      - bad_request
                required:
                  - error
                  - status
                examples:
                  no_headers:
                    value:
                      error: No headers provided
                      status: bad_request
                  invalid_json:
                    value:
                      error: Invalid JSON in request body
                      status: bad_request
                  missing_file_id:
                    value:
                      error: fileID is required
                      status: bad_request
                  missing_memory_id:
                    value:
                      error: memoryID is required
                      status: bad_request
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                  status:
                    type: string
                    enum:
                      - unauthorized
                required:
                  - error
                  - status
                example:
                  error: API key is required
                  status: unauthorized
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                  status:
                    type: string
                    enum:
                      - forbidden
                required:
                  - error
                  - status
                examples:
                  invalid_api_key:
                    value:
                      error: Invalid API key
                      status: forbidden
                  unauthorized_file:
                    value:
                      error: You don't have permission to access this file
                      status: forbidden
                  unauthorized_memory:
                    value:
                      error: You don't have permission to access this memory
                      status: forbidden
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                  status:
                    type: string
                    enum:
                      - not_found
                required:
                  - error
                  - status
                examples:
                  file_not_found:
                    value:
                      error: File not found
                      status: not_found
                  memory_not_found:
                    value:
                      error: Memory not found
                      status: not_found
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: Error message
                  status:
                    type: string
                    enum:
                      - error
                required:
                  - error
                  - status
                example:
                  error: Internal server error
                  status: error
components:
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: 'Your duohub API key. Type: str'

````