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

# Create session

> Creates a new deliberation session owned by the authenticated user.
If `prompt` is omitted, a facilitation prompt is auto-generated server-side
from the topic, goal, context, and critical fields (with a fallback to a basic prompt).
Returns the created session with a `join_url` for sharing with participants.




## OpenAPI

````yaml /api-reference/openapi.yaml post /sessions
openapi: 3.1.0
info:
  title: Harmonica API
  version: 1.0.0
  description: >
    REST API for the Harmonica structured deliberation platform.

    Provides access to sessions and their data, including creating, updating,
    and querying sessions, plus response submission for active sessions.
  contact:
    name: Harmonica
    url: https://harmonica.chat
servers:
  - url: https://app.harmonica.chat/api/v1
    description: Production
  - url: http://localhost:3000/api/v1
    description: Local development
security:
  - apiKey: []
paths:
  /sessions:
    post:
      tags:
        - Sessions
      summary: Create session
      description: >
        Creates a new deliberation session owned by the authenticated user.

        If `prompt` is omitted, a facilitation prompt is auto-generated
        server-side

        from the topic, goal, context, and critical fields (with a fallback to a
        basic prompt).

        Returns the created session with a `join_url` for sharing with
        participants.
      operationId: createSession
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSessionRequest'
      responses:
        '201':
          description: Session created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SessionCreated'
        '400':
          description: Validation error (missing required fields)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: validation_error
                  message: topic is required
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    CreateSessionRequest:
      type: object
      description: Request body for creating a new session.
      properties:
        topic:
          type: string
          description: Session topic / title
        goal:
          type: string
          description: What the session aims to achieve
        context:
          type: string
          description: >-
            Background context for participants (e.g. SESSION.md from a prior
            session)
        critical:
          type: string
          description: Critical question or constraint
        prompt:
          type: string
          description: >
            Custom facilitation prompt. If omitted, a prompt is auto-generated
            server-side

            from the topic, goal, context, and critical fields. Falls back to a
            basic

            facilitation prompt if generation fails.
        template_id:
          type: string
          description: ID of a template to use
        questions:
          type: array
          items:
            type: object
            properties:
              text:
                type: string
            required:
              - text
          description: >-
            Pre-session questions shown to participants before facilitation
            begins
        cross_pollination:
          type: boolean
          default: false
          description: Enable cross-pollination of ideas between participant threads
        widgets_enabled:
          type: boolean
          default: false
          description: |
            Enable AI-emitted Polls and ratings widgets (SingleSelect,
            MultiSelect, RatingScale, RankingList) during the session. When
            true, the facilitator may call widget tools mid-conversation to
            present interactive inputs instead of plain text questions.
        results_visibility:
          type: string
          enum:
            - public
            - participants
            - host
          default: host
          description: |
            Who can see aggregated session results.
            - `host` (default) — only the session owner can see results.
            - `participants` — anyone who completed the session can see what
              others said (drives the end-of-chat "See what others said" link).
            - `public` — anyone with the session URL can see results without
              participating.
            MCP / harmonica-chat callers typically pass `participants` since
            programmatic and Telegram-distributed sessions usually want
            distributed visibility.
        distribution:
          type: array
          items:
            $ref: '#/components/schemas/DistributionTarget'
          description: Distribution channels for the session (e.g. Telegram groups)
      required:
        - topic
        - goal
    SessionCreated:
      type: object
      description: >-
        Session object returned after creation. Extends SessionListItem with a
        join URL.
      properties:
        id:
          type: string
          format: uuid
        topic:
          type: string
        goal:
          type: string
        status:
          type: string
          enum:
            - active
        participant_count:
          type: integer
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        join_url:
          type: string
          format: uri
          description: Direct URL for participants to join the session
      required:
        - id
        - topic
        - goal
        - status
        - participant_count
        - created_at
        - updated_at
        - join_url
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              enum:
                - unauthorized
                - forbidden
                - not_found
                - validation_error
                - rate_limited
                - internal_error
                - unprocessable
            message:
              type: string
          required:
            - code
            - message
      required:
        - error
    DistributionTarget:
      type: object
      description: A distribution channel where the session should be announced.
      properties:
        channel:
          type: string
          enum:
            - telegram
          description: Distribution channel type
        group_id:
          type: string
          description: Channel-specific group identifier (e.g. Telegram chat ID)
      required:
        - channel
        - group_id
  responses:
    Unauthorized:
      description: Missing or invalid API key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthorized
              message: Invalid or missing API key
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: |
        API key authentication. Pass your key as a Bearer token.
        Keys use the format `hm_live_<32 hex chars>`.
        Generate keys from your Harmonica dashboard settings.

````