openapi: 3.0.3
info:
  title: SOAT Memories API
  version: 1.0.0
  description: API for managing memory configurations for RAG (Retrieval-Augmented Generation)
  contact:
    name: SOAT Team
    url: https://github.com/ttoss/soat
servers:
  - url: '{baseUrl}'
    description: Base URL of your SOAT deployment (e.g. https://your-soat.com or http://localhost:5047)
    variables:
      baseUrl:
        description: The base URL of your SOAT deployment
        default: http://localhost:5047
tags:
  - name: Memories
    description: Manage memory configurations for document retrieval
security:
  - bearerAuth: []
paths:
  /api/v1/memories:
    get:
      tags:
        - Memories
      summary: List memories
      description: Returns a list of memory configurations for a project
      operationId: listMemories
      parameters:
        - name: project_id
          in: query
          description: Project ID (required if not using project key auth)
          schema:
            type: string
            example: proj_V1StGXR8Z5jdHi6B
        - name: tags
          in: query
          description: >
            Filter memories by tag patterns. Supports glob syntax (`*` matches
            any substring, `?` matches any single character). Multiple values
            are ORed — a memory is returned if any of its tags match any of the
            provided patterns. Omit to return all memories.
          schema:
            type: array
            items:
              type: string
          style: form
          explode: true
          example:
            - 'customer*'
            - 'support'
      responses:
        '200':
          description: List of memories
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Memory'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '500':
          description: Internal server error
    post:
      tags:
        - Memories
      summary: Create a memory
      description: Creates a new memory configuration in a project
      operationId: createMemory
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - name
              properties:
                project_id:
                  type: string
                  description: Project ID (required if not using project key auth)
                  example: proj_V1StGXR8Z5jdHi6B
                name:
                  type: string
                  description: Memory name
                  example: Product Documentation
                description:
                  type: string
                  description: Optional description
                  example: Retrieves product docs for support queries
                tags:
                  type: array
                  items:
                    type: string
                  description: Optional list of tags for filtering in knowledge search
                  example: ['projectA', 'customer-support']
      responses:
        '201':
          description: Memory created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Memory'
        '400':
          description: Bad request (missing required fields or invalid config)
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '500':
          description: Internal server error
  /api/v1/memories/{memory_id}:
    get:
      tags:
        - Memories
      summary: Get a memory
      description: Returns a single memory configuration by ID
      operationId: getMemory
      parameters:
        - name: memory_id
          in: path
          required: true
          schema:
            type: string
            example: mem_V1StGXR8Z5jdHi6B
      responses:
        '200':
          description: Memory found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Memory'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Memory not found
        '500':
          description: Internal server error
    put:
      tags:
        - Memories
      summary: Update a memory
      description: Updates an existing memory configuration
      operationId: updateMemory
      parameters:
        - name: memory_id
          in: path
          required: true
          schema:
            type: string
            example: mem_V1StGXR8Z5jdHi6B
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                  description: Memory name
                description:
                  type: string
                  nullable: true
                  description: Optional description
                tags:
                  type: array
                  nullable: true
                  items:
                    type: string
                  description: Optional list of tags for filtering in knowledge search
      responses:
        '200':
          description: Memory updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Memory'
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Memory not found
        '500':
          description: Internal server error
    delete:
      tags:
        - Memories
      summary: Delete a memory
      description: Deletes a memory configuration
      operationId: deleteMemory
      parameters:
        - name: memory_id
          in: path
          required: true
          schema:
            type: string
            example: mem_V1StGXR8Z5jdHi6B
      responses:
        '204':
          description: Memory deleted
        '401':
          description: Unauthorized
        '403':
          description: Forbidden
        '404':
          description: Memory not found
        '500':
          description: Internal server error
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
  schemas:
    Memory:
      type: object
      properties:
        id:
          type: string
          example: mem_V1StGXR8Z5jdHi6B
        project_id:
          type: string
          example: proj_V1StGXR8Z5jdHi6B
        name:
          type: string
          example: Product Documentation
        description:
          type: string
          nullable: true
          example: Retrieves product docs for support queries
        tags:
          type: array
          nullable: true
          items:
            type: string
          description: List of tags for filtering in knowledge search
          example: ['projectA', 'customer-support']
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
