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

# Start a chat turn

> Start a chat turn and receive the SSE Location.

Returns **202** with a `Location` of the SSE stream. Subscribe to [Stream the turn](/api-reference/chats/stream). **409** if a turn is already running — the body names the stream to attach.

The model usage of that turn is billed at **1.5×**. Do not retry a 202 as a new POST.


## OpenAPI

````yaml POST /api/v2/chats/{thread_id}/messages/
openapi: 3.1.0
info:
  title: Abacus Docs API
  version: 1.0.0
  description: |
    REST + SSE surface for Abacus Docs on the same host as the web app
    (`https://abacusdocs.com`). Paths are `/api/v2/…`.

    Authenticate with an organisation API key (`sk-abacus-*`) as a Bearer
    token, or an Auth0 access token. Cross-tenant reads return **404**, not
    403. Page-based lists use `?page=` and `?page_size=`.

    Extraction, reprocess, schema tests, and chat turns spend credits.
    See the help centre Credits pages for rates.
  contact:
    name: Abacus Docs
    url: https://abacusdocs.com/contact
servers:
  - url: https://abacusdocs.com
    description: Production (Extract)
security: []
paths:
  /api/v2/chats/{thread_id}/messages/:
    post:
      tags:
        - v2/chats
      summary: Start a chat turn for SSE streaming
      description: >-
        When `CHAT_TURN_STREAMS_ENABLED` is on (AD-404): starts the durable turn
        immediately via TurnRunner and returns 202 + Location where `message_id`
        is the `turn_id`. Lock conflict → 409 with `{active_turn_id,
        stream_url}` so the SPA can attach. When the flag is off: legacy
        one-shot Redis buffer (graph runs on GET).
      operationId: v2_chats_messages_create
      parameters:
        - in: path
          name: thread_id
          schema:
            type: string
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MessageCreateRequestRequest'
        required: true
      responses:
        '202':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageCreateResponse'
          description: ''
        '400':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
          description: ''
        '404':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
          description: ''
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageConflictResponse'
          description: ''
        '503':
          content:
            application/json:
              schema:
                type: object
                additionalProperties: {}
          description: ''
      security:
        - extractApiKey: []
        - bearerAuth: []
        - cookieAuth: []
components:
  schemas:
    MessageCreateRequestRequest:
      type: object
      description: |-
        Body for ``POST /api/v2/chats/<thread_id>/messages/``.

        When ``CHAT_TURN_STREAMS_ENABLED`` is on (AD-404), the POST starts the
        durable turn immediately and ``message_id`` is the ``turn_id``. When the
        flag is off, the legacy one-shot Redis buffer path is used.

        Fields:
            message: The user's turn text. Plain UTF-8 (no base64 — that was a
                WebSocket-only transport detail). Non-empty.
            settings: Optional per-turn user settings (e.g. ``{"concise": true}``),
                threaded into the graph as ``user_settings``. Free-form to mirror
                the WebSocket ``user_settings`` payload; the graph ignores unknown
                keys.
            client_nonce: Optional opaque id for optimistic-paint dedup (AD-403/404).
      properties:
        message:
          type: string
          minLength: 1
          description: The user's message text for this chat turn (plain UTF-8, non-empty).
        settings:
          type: object
          additionalProperties: {}
          description: >-
            Optional per-turn user settings threaded into the graph as
            user_settings.
        client_nonce:
          type:
            - string
            - 'null'
          description: Optional client nonce for optimistic UI reconcile.
          maxLength: 128
      required:
        - message
    MessageCreateResponse:
      type: object
      description: |-
        ``202`` response for ``POST /api/v2/chats/<thread_id>/messages/``.

        Mirrors the ``Location`` header. The client subscribes to ``stream_url``
        (an ``EventSource`` / fetch-stream target) to receive the canonical
        ``StreamEvent`` sequence for this turn.

        Fields:
            message_id: Durable ``turn_id`` when streams are enabled; otherwise the
                legacy one-shot buffer handle.
            stream_url: Relative path of the SSE stream endpoint for this turn.
      properties:
        message_id:
          type: string
          description: Turn id / stream handle for this chat turn.
        stream_url:
          type: string
          description: Relative path of the SSE stream endpoint for this turn.
      required:
        - message_id
        - stream_url
    MessageConflictResponse:
      type: object
      description: '``409`` when a turn is already in flight (AD-404 attach contract).'
      properties:
        error:
          type: string
        active_turn_id:
          type: string
        stream_url:
          type: string
      required:
        - active_turn_id
        - error
        - stream_url
  securitySchemes:
    extractApiKey:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Organisation API key from Settings → API / `/api/keys/`. The secret is
        shown once. Send `Authorization: Bearer sk-abacus-…`. One active key
        per organisation. Ingest (`/api/v2/ingest/*`) refuses API keys — that
        surface is Auth0-only with `ingest:read` / `ingest:write` scopes.
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        Auth0 access token for a signed-in user. Send `Authorization: Bearer
        <token>`.

        The SPA and desktop agent use this. Prefer an organisation API key for

        server-to-server integrations.
    cookieAuth:
      type: apiKey
      in: cookie
      name: sessionid
      description: |
        Django session cookie from a browser login. Present so the web app can
        call `/api/v2` without a header. Do not rely on this for integrations.

````