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

# Create Section Handler

> Create a new section.

The section is created as a child of the specified parent (must be
DOCUMENT_VERSION or SECTION). If prev_sibling_path_id is provided,
the section is inserted after that sibling; otherwise it is appended
to the end of the sibling list.



## OpenAPI

````yaml /openapi.yaml post /v1/sections
openapi: 3.1.0
info:
  title: Knowledge Stack API
  description: Knowledge Stack backend API for authentication and knowledge management
  version: 0.1.0
servers:
  - url: http://localhost:8000
    description: Knowledge Stack API local dev server
security: []
tags:
  - name: auth
    description: Authentication and identity management
  - name: users
    description: User accounts
  - name: tenants
    description: Tenant management
  - name: invites
    description: Tenant invitations
  - name: folders
    description: Folder management
  - name: documents
    description: Document management
  - name: document-versions
    description: Document version management
  - name: sections
    description: Document sections
  - name: chunks
    description: Chunk CRUD and semantic search
  - name: chunk-lineages
    description: Chunk lineage tracking
  - name: tags
    description: Tag management
  - name: path-parts
    description: Path part traversal and tagging
  - name: Threads
    description: Thread conversations
  - name: Thread Messages
    description: Thread message management
  - name: user-permissions
    description: User path permissions
  - name: workflows
    description: Ingestion workflows
paths:
  /v1/sections:
    post:
      tags:
        - sections
      summary: Create Section Handler
      description: |-
        Create a new section.

        The section is created as a child of the specified parent (must be
        DOCUMENT_VERSION or SECTION). If prev_sibling_path_id is provided,
        the section is inserted after that sibling; otherwise it is appended
        to the end of the sibling list.
      operationId: create_section
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            type: string
            nullable: true
            title: Authorization
        - name: ks_uat
          in: cookie
          required: false
          schema:
            type: string
            nullable: true
            title: Ks Uat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateSectionRequest'
      responses:
        '201':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SectionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    CreateSectionRequest:
      properties:
        name:
          type: string
          maxLength: 255
          minLength: 1
          title: Name
          description: Section name (can contain any characters)
        parent_path_id:
          type: string
          format: uuid
          title: Parent Path Id
          description: Parent PathPart ID (must be DOCUMENT_VERSION or SECTION)
        page_number:
          type: integer
          exclusiveMinimum: 0
          nullable: true
          title: Page Number
          description: Page number in source document (must be > 0)
        prev_sibling_path_id:
          type: string
          format: uuid
          nullable: true
          title: Prev Sibling Path Id
          description: PathPart ID to insert after (null = append to tail)
      additionalProperties: false
      type: object
      required:
        - name
        - parent_path_id
      title: CreateSectionRequest
      description: Request to create a new section.
    SectionResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Section ID
        path_part_id:
          type: string
          format: uuid
          title: Path Part Id
          description: PathPart ID
        name:
          type: string
          title: Name
          description: Section name
        page_number:
          type: integer
          nullable: true
          title: Page Number
          description: Page number in source document
        parent_path_id:
          type: string
          format: uuid
          title: Parent Path Id
          description: Parent PathPart ID
        prev_sibling_path_id:
          type: string
          format: uuid
          nullable: true
          title: Prev Sibling Path Id
          description: Previous sibling PathPart ID
        next_sibling_path_id:
          type: string
          format: uuid
          nullable: true
          title: Next Sibling Path Id
          description: Next sibling PathPart ID
        materialized_path:
          type: string
          title: Materialized Path
          description: Full materialized path from root
        system_managed:
          type: boolean
          title: System Managed
          description: Whether this section is system-managed
        system_metadata:
          $ref: '#/components/schemas/SectionSystemMetadata'
          description: System-managed metadata (statistics, etc.)
        tenant_id:
          type: string
          format: uuid
          title: Tenant Id
          description: Tenant ID
        created_at:
          type: string
          format: date-time
          title: Created At
          description: Creation timestamp
        updated_at:
          type: string
          format: date-time
          title: Updated At
          description: Last update timestamp
      additionalProperties: false
      type: object
      required:
        - id
        - path_part_id
        - name
        - parent_path_id
        - materialized_path
        - system_managed
        - tenant_id
        - created_at
        - updated_at
      title: SectionResponse
      description: Section response model.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SectionSystemMetadata:
      properties:
        information_statistics:
          $ref: '#/components/schemas/InformationStatistics'
          nullable: true
      type: object
      title: SectionSystemMetadata
      description: Schema for section.system_metadata JSONB field.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    InformationStatistics:
      properties:
        num_chunks_by_type:
          additionalProperties:
            type: integer
          type: object
          title: Num Chunks By Type
          description: 'Count of chunks by type (e.g. {"TEXT": 42, "TABLE": 3})'
        total_tokens:
          type: integer
          title: Total Tokens
          description: Sum of all chunk content tokens in subtree
          default: 0
        num_direct_children:
          type: integer
          title: Num Direct Children
          description: Count of immediate children (sections + chunks)
          default: 0
        children_depth:
          type: integer
          title: Children Depth
          description: Max depth to deepest leaf (0 = no children)
          default: 0
      type: object
      title: InformationStatistics
      description: Aggregate statistics for a section subtree or document version.

````