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

# Upsert Feedback

> Insert or update one feedback row, keyed by its anchor tuple.

The request schema validates that the aspect is valid for the scope and
that the sentiment/category combination is coherent (reports carry a
category and no sentiment; every other aspect carries a 3-point sentiment).



## OpenAPI

````yaml /openapi.json put /api/feedback
openapi: 3.1.0
info:
  title: HAI-Co² API
  description: Human-AI Co-Construction reference implementation.
  version: 0.1.0
servers:
  - url: https://haico.gr
    description: Production
  - url: https://dev.haico.gr
    description: Development
  - url: http://localhost:8000
    description: Local development
security: []
paths:
  /api/feedback:
    put:
      tags:
        - Feedback
      summary: Upsert Feedback
      description: >-
        Insert or update one feedback row, keyed by its anchor tuple.


        The request schema validates that the aspect is valid for the scope and

        that the sentiment/category combination is coherent (reports carry a

        category and no sentiment; every other aspect carries a 3-point
        sentiment).
      operationId: upsert_feedback_api_feedback_put
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FeedbackRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FeedbackItem'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    FeedbackRequest:
      properties:
        thread_id:
          type: string
          maxLength: 255
          minLength: 1
          title: Thread Id
        turn_index:
          type: integer
          minimum: 0
          title: Turn Index
        scope:
          type: string
          maxLength: 24
          title: Scope
        aspect:
          type: string
          maxLength: 40
          title: Aspect
        sentiment:
          anyOf:
            - type: string
              maxLength: 16
            - type: 'null'
          title: Sentiment
        category:
          anyOf:
            - type: string
              maxLength: 64
            - type: 'null'
          title: Category
        comment:
          anyOf:
            - type: string
              maxLength: 2000
            - type: 'null'
          title: Comment
        artifact_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Artifact Id
          description: >-
            scope='artifact' only: which artifact this rates (0/None = live
            document)
      type: object
      required:
        - thread_id
        - turn_index
        - scope
        - aspect
      title: FeedbackRequest
      description: >-
        Upsert payload for one piece of user feedback.


        Only the structural shape is validated here (the presentation vocabulary
        —

        dimension aspects, report categories, reason tags — is owned by the

        frontend, so it can evolve without a backend change). The rules are:

        the scope must be known; the aspect must be a well-formed slug; a report

        carries a ``category`` and no sentiment; every other aspect carries a

        3-point ``sentiment`` and an optional ``category``.
    FeedbackItem:
      properties:
        thread_id:
          type: string
          title: Thread Id
        turn_index:
          type: integer
          title: Turn Index
        scope:
          type: string
          title: Scope
        aspect:
          type: string
          title: Aspect
        sentiment:
          anyOf:
            - type: string
            - type: 'null'
          title: Sentiment
        category:
          anyOf:
            - type: string
            - type: 'null'
          title: Category
        comment:
          anyOf:
            - type: string
            - type: 'null'
          title: Comment
        artifact_id:
          anyOf:
            - type: integer
            - type: 'null'
          title: Artifact Id
        origin:
          type: string
          title: Origin
          default: user
      type: object
      required:
        - thread_id
        - turn_index
        - scope
        - aspect
      title: FeedbackItem
      description: One feedback row returned to the frontend for hydration.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      description: >-
        A personal access token (`haico_pat_...`), created under Profile → API
        keys. Send it as `Authorization: Bearer <key>`. The browser session JWT
        is also accepted but is an internal mechanism and is not part of the
        public contract.
      scheme: bearer

````