> ## 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.

# Submit Response

> Submit one questionnaire instrument; re-submitting the same slot upserts.



## OpenAPI

````yaml /openapi.json post /api/study/sessions/{session_id}/responses
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/study/sessions/{session_id}/responses:
    post:
      tags:
        - Study
      summary: Submit Response
      description: >-
        Submit one questionnaire instrument; re-submitting the same slot
        upserts.
      operationId: submit_response_api_study_sessions__session_id__responses_post
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: integer
            title: Session Id
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubmitResponseRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SurveyResponseSchema'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    SubmitResponseRequest:
      properties:
        instrument_id:
          type: string
          maxLength: 64
          title: Instrument Id
        instrument_version:
          type: string
          maxLength: 16
          title: Instrument Version
          default: '1'
        condition:
          type: string
          maxLength: 32
          title: Condition
          default: ''
        task_id:
          type: string
          maxLength: 32
          title: Task Id
          default: ''
        answers:
          additionalProperties: true
          type: object
          title: Answers
        duration_ms:
          anyOf:
            - type: integer
              minimum: 0
            - type: 'null'
          title: Duration Ms
      type: object
      required:
        - instrument_id
        - answers
      title: SubmitResponseRequest
      description: |-
        Submit one questionnaire instrument's answers (upsert per slot).

        The answers are validated against the instrument's declared item ids and
        scales (``services/study_instruments.py``) before the row is written.
    SurveyResponseSchema:
      properties:
        id:
          type: integer
          title: Id
        instrument_id:
          type: string
          title: Instrument Id
        instrument_version:
          type: string
          title: Instrument Version
        condition:
          type: string
          title: Condition
        task_id:
          type: string
          title: Task Id
        answers:
          additionalProperties: true
          type: object
          title: Answers
        computed:
          additionalProperties: true
          type: object
          title: Computed
        duration_ms:
          anyOf:
            - type: integer
            - type: 'null'
          title: Duration Ms
        submitted_at:
          type: string
          format: date-time
          title: Submitted At
      type: object
      required:
        - id
        - instrument_id
        - instrument_version
        - condition
        - task_id
        - answers
        - computed
        - submitted_at
      title: SurveyResponseSchema
    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

````