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

# Close (remove) a document from a multi-document session.

> Remove document_id from the session's open documents (the tab close button). If it's the
focused document, focus another open document — `next_focus` if it's still open (so the client
can pick the adjacent tab), else the next remaining one; closing the last document leaves the
session empty. Returns the updated document roster + the now-focused document's HTML.

The close takes effect immediately and is persisted, so a later reconnect or session restore
won't bring the closed document back. Persistence is best-effort — a failure is logged, not
fatal (the close still holds for the active session).



## OpenAPI

````yaml /openapi.json delete /v1/sessions/{session_id}/documents/{document_id}
openapi: 3.1.0
info:
  title: Universal Document AI API
  description: AI-powered document editing with multi-tenant organization support
  version: 2.0.0
servers: []
security: []
paths:
  /v1/sessions/{session_id}/documents/{document_id}:
    delete:
      tags:
        - v1
        - mcp
        - sessions
      summary: Close (remove) a document from a multi-document session.
      description: >-
        Remove document_id from the session's open documents (the tab close
        button). If it's the

        focused document, focus another open document — `next_focus` if it's
        still open (so the client

        can pick the adjacent tab), else the next remaining one; closing the
        last document leaves the

        session empty. Returns the updated document roster + the now-focused
        document's HTML.


        The close takes effect immediately and is persisted, so a later
        reconnect or session restore

        won't bring the closed document back. Persistence is best-effort — a
        failure is logged, not

        fatal (the close still holds for the active session).
      operationId: close_session_document
      parameters:
        - name: session_id
          in: path
          required: true
          schema:
            type: string
            title: Session Id
        - name: document_id
          in: path
          required: true
          schema:
            type: string
            title: Document Id
        - name: next_focus
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Next Focus
        - name: include_html
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              Include each document's full reassembled HTML body. Default false
              (token-light — recommended for AI agents enumerating or switching
              tabs): returns only ids, title, section count, focused flag, and
              page setup, omitting the body which can be hundreds of KB per
              document. The web app passes true to render document content.
            default: false
            title: Include Html
          description: >-
            Include each document's full reassembled HTML body. Default false
            (token-light — recommended for AI agents enumerating or switching
            tabs): returns only ids, title, section count, focused flag, and
            page setup, omitting the body which can be hundreds of KB per
            document. The web app passes true to render document content.
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Authorization
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````