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

# Abort chat stream

> Stops an in-progress chat stream — for example, when the user cancels a request or navigates away while the agent is still generating a response.

The abort URL is derived from the Chat API URL by replacing `/stream-chat-state` with `/abort`.

A successful cancellation is indicated solely by the `204 No Content` status — the response has no body. Note that the aborted `stream-chat-state` request itself does not fail with an HTTP error: the streaming response already returned `200 OK` when the stream opened, so treat this endpoint's `204` as the confirmation that the stream was aborted.



## OpenAPI

````yaml /api-reference/chat.yaml post /chat/abort
openapi: 3.1.0
info:
  title: Cube Cloud Chat API
  version: 1.0.0
  description: >-
    Real-time streaming conversations with Cube Cloud AI agents for analytics
    and

    data exploration. Copy the exact Chat API URL from your agent settings

    (Admin → Agents → Chat API URL).
servers:
  - url: >-
      https://ai.{cloudRegion}.cubecloud.dev/api/v1/public/{accountName}/agents/{agentId}
    description: >-
      Chat API base URL. Copy the exact URL from your agent settings (Admin →
      Agents → Chat API URL).
    variables:
      cloudRegion:
        default: gcp-us-central1
        description: Cloud region identifier
      accountName:
        default: your-account
        description: Your Cube Cloud account/tenant name
      agentId:
        default: '1'
        description: AI agent identifier (Admin → Agents)
security:
  - apiKey: []
  - cubeToken: []
tags:
  - name: Chat
paths:
  /chat/abort:
    post:
      tags:
        - Chat
      summary: Abort chat stream
      description: >-
        Stops an in-progress chat stream — for example, when the user cancels a
        request or navigates away while the agent is still generating a
        response.


        The abort URL is derived from the Chat API URL by replacing
        `/stream-chat-state` with `/abort`.


        A successful cancellation is indicated solely by the `204 No Content`
        status — the response has no body. Note that the aborted
        `stream-chat-state` request itself does not fail with an HTTP error: the
        streaming response already returned `200 OK` when the stream opened, so
        treat this endpoint's `204` as the confirmation that the stream was
        aborted.
      operationId: abortChat
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/AbortChatRequest'
        description: Abort request identifying the chat thread to stop.
        required: true
      responses:
        '204':
          description: Chat streaming was aborted successfully. The response has no body.
        '403':
          description: The authenticated user does not own the specified chat thread.
        '404':
          description: The specified `chatId` does not exist.
      security:
        - apiKey: []
        - cubeToken: []
components:
  schemas:
    AbortChatRequest:
      properties:
        chatId:
          description: >-
            Chat thread ID to abort. Must match the `chatId` of an active or
            recently completed chat session.
          type: string
        sessionSettings:
          $ref: '#/components/schemas/SessionSettingsDto'
      required:
        - chatId
      type: object
    SessionSettingsDto:
      properties:
        email:
          description: User's email address.
          type: string
        externalId:
          description: >-
            Unique identifier for an external user. Must be lowercase and
            trimmed (no leading/trailing whitespace). Either `externalId` or
            `internalId` is required.
          type: string
        groups:
          description: >-
            Array of group names the user belongs to. Not allowed together with
            `internalId`.
          items:
            type: string
          type: array
        internalId:
          description: >-
            Username of an internal Cube Cloud user, matched lowercased and
            trimmed; the user must already exist and must not be external. An
            email is a common username form but is not required. Either
            `externalId` or `internalId` is required.
          type: string
        publicDashboardId:
          type: string
        roles:
          items:
            type: string
          type: array
        securityContext:
          description: >-
            Custom security context object for Cube queries. Not allowed
            together with `internalId`.
          type: object
        userAttributes:
          description: >-
            Array of `{ name, value }` pairs for row-level security. Not allowed
            together with `internalId`.
          items: {}
          type: array
      type: object
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: 'API key authentication. Send `Authorization: Api-Key <YOUR_API_KEY>`.'
    cubeToken:
      type: apiKey
      in: header
      name: X-Cube-Auth-Token
      description: >-
        Cube token authentication. Send your deployment's own Cube token (JWT)
        in the `X-Cube-Auth-Token` header. The token must be valid for the
        agent's deployment, include an `externalId` (or `sub`) claim identifying
        the external user, and carry the `chat` scope in its `scope` claim (an
        array). Disabled by default — enable it in your deployment settings.

````