> ## Documentation Index
> Fetch the complete documentation index at: https://developer.demand-iq.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Answer a question

> Answers a viewer question. Checks FAQs first (exact then semantic match at >= 0.6 confidence), falls back to GPT-4o with slide context. Returns answer text plus synthesized audio.

`deckId` and `presentationId` must be valid UUIDs; other values are rejected with a 400. When a `presentationId` is provided, the answer is drawn from the deck that presentation belongs to; the body's `deckId` is used only as a fallback when that deck has been deleted. If `slideId` doesn't match a slide in the deck, the question is answered without slide context instead of failing.

**Authentication**: Accepts either a session cookie (admin) or a `presentationId` (public viewer).



## OpenAPI

````yaml /openapi.json post /api/qa
openapi: 3.0.0
info:
  title: AI Presentations API
  version: 1.0.0
  description: >-
    REST API for AI Presentations — an AI-powered presentation platform with
    narrated slides, live Q&A, and deck management.


    **Authentication**: Most endpoints require a session cookie obtained from
    `POST /api/auth/login`. Presentation playback endpoints (`/api/qa`,
    `/api/narration/*`) also accept a `presentationId` for unauthenticated
    viewer access.
  contact:
    name: Demand IQ
    url: https://demand-iq.com
servers:
  - url: https://app.demand-iq.com
    description: Production
  - url: http://localhost:3000
    description: Local development
security: []
tags:
  - name: Decks
    description: Manage presentation decks
  - name: Slides
    description: Manage slides within a deck
  - name: FAQs
    description: Manage pre-built Q&A pairs
  - name: Branding
    description: Colors, logo, and call-to-action configuration
  - name: Q&A
    description: Live question answering and Q&A settings
  - name: Narration
    description: Text-to-speech synthesis
  - name: Presentations
    description: Create and manage personalized presentation instances
  - name: Generation
    description: AI-powered content generation from slide images
  - name: Images
    description: Image upload and management
  - name: Voices
    description: Available TTS voices
  - name: Utility
    description: Health check and diagnostics
  - name: Authentication
    description: Session-based login, logout, and identity
  - name: Company
    description: Organization contact info and knowledge base
  - name: Notifications
    description: Event subscriptions and delivery log
  - name: Contracts
    description: Contract template import and e-signature
  - name: Fonts
    description: Available Google Fonts for branding
  - name: Roof Measurements
    description: Request and track automated roof measurements
  - name: Actions
    description: Voice/text command detection for presentation control
  - name: Appointments
    description: Appointment scheduling for presentation viewers
  - name: Activity
    description: Recent presentation activity feed
  - name: Onboarding
    description: >-
      Per-user product onboarding milestones (ENG-641). Milestone endpoints are
      idempotent and are called by the app UI — they should not be treated as
      tenant-integration surface.
paths:
  /api/qa:
    post:
      tags:
        - Q&A
      summary: Answer a question
      description: >-
        Answers a viewer question. Checks FAQs first (exact then semantic match
        at >= 0.6 confidence), falls back to GPT-4o with slide context. Returns
        answer text plus synthesized audio.


        `deckId` and `presentationId` must be valid UUIDs; other values are
        rejected with a 400. When a `presentationId` is provided, the answer is
        drawn from the deck that presentation belongs to; the body's `deckId` is
        used only as a fallback when that deck has been deleted. If `slideId`
        doesn't match a slide in the deck, the question is answered without
        slide context instead of failing.


        **Authentication**: Accepts either a session cookie (admin) or a
        `presentationId` (public viewer).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - question
                - slideId
              properties:
                question:
                  type: string
                  minLength: 3
                slideId:
                  type: string
                  minLength: 1
                  maxLength: 100
                  description: >-
                    Current slide ID for context. Accepts a slide UUID or a
                    legacy semantic ID such as `slide-1`.
                deckId:
                  type: string
                  format: uuid
                  description: >-
                    Deck to answer from. Ignored when `presentationId` is
                    provided — the deck is resolved from the presentation, and
                    this value is used only as a fallback if that deck has been
                    deleted.
                presentationId:
                  type: string
                  format: uuid
                  description: Required for unauthenticated viewer access
                history:
                  type: array
                  items:
                    type: object
                    required:
                      - role
                      - content
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - assistant
                      content:
                        type: string
                voiceId:
                  type: string
                language:
                  type: string
                  example: en
                  description: BCP-47 language tag
      responses:
        '200':
          description: Answer with audio
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QaResponse'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    QaResponse:
      type: object
      properties:
        answer:
          type: string
        audioUrl:
          type: string
          description: Accessible URL for the TTS audio of the answer
        wordTimings:
          type: array
          items:
            $ref: '#/components/schemas/WordTiming'
        source:
          type: string
          enum:
            - faq
            - cached
            - openai
            - fallback
        relatedSlideId:
          type: string
          nullable: true
      required:
        - answer
        - audioUrl
        - source
    Error:
      type: object
      properties:
        error:
          type: string
      required:
        - error
    WordTiming:
      type: object
      properties:
        word:
          type: string
        startTime:
          type: number
          description: Start time in milliseconds
        endTime:
          type: number
          description: End time in milliseconds
      required:
        - word
        - startTime
        - endTime

````