> ## 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.

# Get Chunk Lineage Handler

> Get lineage graph for a chunk.

Traverses both ancestors and descendants up to max_depth,
returning enriched nodes and edges.



## OpenAPI

````yaml /openapi.yaml get /v1/chunk-lineages/{chunk_id}
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/chunk-lineages/{chunk_id}:
    get:
      tags:
        - chunk-lineages
      summary: Get Chunk Lineage Handler
      description: |-
        Get lineage graph for a chunk.

        Traverses both ancestors and descendants up to max_depth,
        returning enriched nodes and edges.
      operationId: get_chunk_lineage
      parameters:
        - name: chunk_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Chunk Id
        - name: max_depth
          in: query
          required: false
          schema:
            type: integer
            maximum: 10
            minimum: 1
            default: 3
            title: Max Depth
        - 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
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LineageGraphResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    LineageGraphResponse:
      properties:
        nodes:
          items:
            $ref: '#/components/schemas/LineageNodeResponse'
          type: array
          title: Nodes
          description: Chunk nodes in the graph
        edges:
          items:
            $ref: '#/components/schemas/LineageEdgeResponse'
          type: array
          title: Edges
          description: Lineage edges in the graph
      additionalProperties: false
      type: object
      required:
        - nodes
        - edges
      title: LineageGraphResponse
      description: Complete lineage graph with nodes and edges.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    LineageNodeResponse:
      properties:
        id:
          type: string
          format: uuid
          title: Id
          description: Chunk ID
        content:
          type: string
          title: Content
          description: Chunk text content
        chunk_type:
          $ref: '#/components/schemas/ChunkType'
          description: Type of chunk content
        chunk_metadata:
          $ref: '#/components/schemas/ChunkMetadata-Output'
          description: Chunk metadata
        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
        - content
        - chunk_type
        - chunk_metadata
        - tenant_id
        - created_at
        - updated_at
      title: LineageNodeResponse
      description: A node in the lineage graph (enriched chunk).
    LineageEdgeResponse:
      properties:
        parent_chunk_id:
          type: string
          format: uuid
          title: Parent Chunk Id
          description: Parent chunk ID (source)
        chunk_id:
          type: string
          format: uuid
          title: Chunk Id
          description: Child chunk ID (derived)
      additionalProperties: false
      type: object
      required:
        - parent_chunk_id
        - chunk_id
      title: LineageEdgeResponse
      description: An edge in the lineage graph.
    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
    ChunkType:
      type: string
      enum:
        - TEXT
        - TABLE
        - IMAGE
        - HTML
        - UNKNOWN
      title: ChunkType
      description: Type of chunk content.
    ChunkMetadata-Output:
      properties:
        polygons:
          items:
            $ref: '#/components/schemas/PolygonReference'
          type: array
          title: Polygons
          description: >-
            List of bounding boxes in the source document for the chunk,
            potentially from multiple areas of multiple pages.
        s3_urls:
          items:
            type: string
          type: array
          title: S3 Urls
          description: >-
            Ordered s3:// URIs to visual assets for this chunk. Single-element
            for standard IMAGE/TABLE/HTML chunks, multi-element for multi-page
            single-chunk ingestion.
        summary:
          type: string
          nullable: true
          title: Summary
          description: >-
            LLM-generated summary of the chunk content. Used for TABLE and HTML
            chunks to enrich embedding text.
        extracted_text_s3_uri:
          type: string
          nullable: true
          title: Extracted Text S3 Uri
          description: >-
            S3 URI to extracted PDF text used for LLM grounding during
            enrichment
        secondary_taxonomy:
          $ref: '#/components/schemas/ImageTaxonomy'
          nullable: true
          description: >-
            Sub-classification within a primary chunk type. For IMAGE chunks:
            'flowchart' (Mermaid extraction) or 'picture' (image description).
            None when not applicable. Will expand to cover TABLE sub-types in
            the future.
        sheet_name:
          type: string
          nullable: true
          title: Sheet Name
          description: Worksheet name this chunk was extracted from (XLSX only)
        block_type:
          type: string
          nullable: true
          title: Block Type
          description: XLSXParser block type (e.g. table, calculation_block, chart_anchor)
        source_uri:
          type: string
          nullable: true
          title: Source Uri
          description: Cell range URI reference in the source workbook (XLSX only)
        enriched_html:
          type: string
          nullable: true
          title: Enriched Html
          description: >-
            Rendered HTML for non-table XLSX chunks (tables use render_html as
            content)
        cell_range:
          type: string
          nullable: true
          title: Cell Range
          description: Cell address range, e.g. 'A1:D10' (XLSX only)
        dependency_summary:
          additionalProperties: true
          type: object
          nullable: true
          title: Dependency Summary
          description: >-
            Upstream/downstream/cross-sheet cell references for audit reasoning
            (XLSX only)
        formulas:
          items:
            additionalProperties:
              type: string
            type: object
          type: array
          nullable: true
          title: Formulas
          description: >-
            Formula cells in this chunk as [{address, formula, value}] (XLSX
            only)
        key_cells:
          items:
            additionalProperties: true
            type: object
          type: array
          nullable: true
          title: Key Cells
          description: Notable output/header cells for quick identification (XLSX only)
        named_ranges:
          items:
            additionalProperties: true
            type: object
          type: array
          nullable: true
          title: Named Ranges
          description: Named ranges overlapping this chunk (XLSX only)
      type: object
      title: ChunkMetadata
      description: Metadata for a chunk including source document references.
    PolygonReference:
      properties:
        page:
          type: integer
          title: Page
          description: The page number of the source document where the polygon is located.
        polygon:
          $ref: '#/components/schemas/Polygon'
          description: The bounding box of the polygon.
      type: object
      required:
        - page
        - polygon
      title: PolygonReference
      description: Reference to a polygon on a specific page.
    ImageTaxonomy:
      type: string
      enum:
        - picture
        - flowchart
      title: ImageTaxonomy
      description: Image classification taxonomy with prompt descriptions.
    Polygon:
      properties:
        x:
          type: integer
          title: X
          description: The x-coordinate of the top-left corner of the bounding box.
        'y':
          type: integer
          title: 'Y'
          description: The y-coordinate of the top-left corner of the bounding box.
        width:
          type: integer
          title: Width
          description: The width of the bounding box.
        height:
          type: integer
          title: Height
          description: The height of the bounding box.
      type: object
      required:
        - x
        - 'y'
        - width
        - height
      title: Polygon
      description: Bounding box polygon.

````