> ## 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
        project_id:
          type: string
          description: |
            Attach the new session to a project (workspace) at create time.
            Requires editor access to the project.
        roster:
          type: array
          description: |
            HAR-1582 - participants for a chain template's first step. Only
            meaningful when template_id resolves to a chain template; ignored
            otherwise.

            Four of the live chain templates declare roles and an assignment
            strategy (Delphi panel, Governance Meeting, Many-to-Many Readiness,
            Example Mapping) and cannot bootstrap without a roster; for those,
            omitting it returns chain.status "roster_incomplete" on an otherwise
            successful create. The other seven declare no roles and start with
            an empty roster.
          items:
            type: object
            required:
              - email
            properties:
              email:
                type: string
                format: email
              displayName:
                type: string
              auth0Sub:
                type: string
              rolesByStep:
                type: object
                additionalProperties:
                  type: string
                description: |
                  Chain step id to the role slug this participant holds. Read
                  only for steps whose assignment_strategy is "explicit".
        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
        chain:
          type: object
          description: >-
            Outcome of chain bootstrap. Present only when template_id named a
            chain template. Any status other than started or resumed means the
            session was created and is real but is NOT running as a chain, so
            treat this field as the authoritative signal rather than assuming a
            201 implies a running chain. The most common degraded status is
            roster_incomplete, because several chain templates declare roles and
            cannot start without a roster.
          properties:
            status:
              type: string
              enum:
                - started
                - resumed
                - noop
                - unsupported
                - roster_incomplete
                - step_cap_exceeded
                - project_cap_exceeded
                - project_creation_failed
                - bootstrap_failed
            chainInstanceId:
              type: string
              description: Present when status is started or resumed.
            stepId:
              type: string
              description: >-
                The first step of the chain. Present when status is started or
                resumed.
            message:
              type: string
              description: Why the chain did not start. Present on the degraded statuses.
            reason:
              type: string
              description: Present when status is noop.
          required:
            - status
      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
                - payment_required
                - transcript_revision_changed
                - 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
            - community-admin
            - slack
            - discord
            - buzz
          description: >-
            Distribution channel. The enum is the RESERVED vocabulary; only a
            subset has a live dispatcher behind it. A reserved channel without
            one is rejected at write time (422 validation_error) rather than
            stored and silently ignored, so this field never accepts something
            the platform will not act on. Live today: `telegram`. The others are
            reserved so integrators can see the namespace. Note
            `community-admin` is reserved but bound at the PROJECT level via
            community binding, not per session through this field.
        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.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.