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

# Insert Chunk

> Insert a new chunk into a knowledge base file.



## OpenAPI

````yaml POST /orgs/{org_id}/k2/{kb_id}/files/{file_id}/chunks
openapi: 3.1.0
info:
  title: Timbal Platform API
  description: Public API documentation for the Timbal platform
  license:
    name: ''
  version: 2.0.0
servers:
  - url: https://api.timbal.ai
    description: Production
  - url: https://api.dev.timbal.ai
    description: Development
security: []
tags:
  - name: ace
    description: Action Control Engine (ACE) operations
  - name: alarms
    description: Metric series and threshold alarms
  - name: analytics
    description: Org and project analytics
  - name: billing
    description: Subscriptions, usage, and payment-related operations
  - name: channels
    description: Delivery channels alarms notify through
  - name: content
    description: Re-sign stored content URLs
  - name: files
    description: File operations
  - name: iam
    description: IAM — actions, roles, users, and authorization introspection
  - name: k2
    description: Knowledge Bases v2 operations
  - name: orgs
    description: Organization operations
  - name: projects
    description: Project operations
  - name: runs
    description: Execution operations
  - name: templates
    description: Public project template catalog
  - name: users
    description: Authenticated user profile
paths:
  /orgs/{org_id}/k2/{kb_id}/files/{file_id}/chunks:
    post:
      tags:
        - k2
      description: Insert a new chunk into a knowledge base file.
      operationId: insert
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
        - name: kb_id
          in: path
          required: true
          schema:
            type: string
        - name: file_id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InsertK2ChunkRequest'
        required: true
      responses:
        '201':
          description: Chunk inserted
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/K2Chunk'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
        '409':
          description: Conflict
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorMessage'
      security:
        - bearer_auth: []
components:
  schemas:
    InsertK2ChunkRequest:
      type: object
      required:
        - content
      properties:
        after_uid:
          type:
            - string
            - 'null'
          format: uuid
          description: |-
            Place the new chunk immediately after this `chunk_uid`. Mutually
            exclusive with `before_uid`. If neither is set, the chunk is
            appended at the end of the file.
        before_uid:
          type:
            - string
            - 'null'
          format: uuid
          description: |-
            Place the new chunk immediately before this `chunk_uid`. Mutually
            exclusive with `after_uid`.
        content:
          type: string
        embed:
          type:
            - string
            - 'null'
          description: |-
            Text used for vector / full-text indexing. Defaults to `content`
            when omitted; provide an explicit value to keep an
            indexing-optimized variant distinct from the user-visible text.
        page_end:
          type:
            - integer
            - 'null'
          format: int32
        page_start:
          type:
            - integer
            - 'null'
          format: int32
    K2Chunk:
      type: object
      required:
        - uid
        - kb_file_id
        - ordinal
        - content
        - embed
        - blocks
        - index_status
        - revision
        - source
        - created_at
        - updated_at
      properties:
        blocks:
          type: object
          description: |-
            Source-document layout metadata (e.g. bounding boxes, page coords)
            when available. `null` for chunks created or edited by the user.
        content:
          type: string
        created_at:
          type: string
          format: date-time
        embed:
          type: string
        index_error:
          type:
            - string
            - 'null'
        index_status:
          type: string
          description: >-
            Indexing state for search (`pending`, `indexing`, `indexed`, or
            `failed`).
        indexed_at:
          type:
            - string
            - 'null'
          format: date-time
        kb_file_id:
          type: string
        ordinal:
          type: string
          description: Ordering key within the file.
        page_end:
          type:
            - integer
            - 'null'
          format: int32
        page_start:
          type:
            - integer
            - 'null'
          format: int32
        revision:
          type: string
          description: Revision token for optimistic concurrency on update and delete.
        source:
          type: string
          description: 'Origin of the chunk: `parser`, `user_edit`, or `insert`.'
        uid:
          type: string
          format: uuid
          description: Stable per-chunk identity.
        updated_at:
          type: string
          format: date-time
    ErrorMessage:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: Machine-readable error code (e.g. `ALREADY_EXISTS`, `BAD_REQUEST`).
        message:
          type: string
          description: Human-readable description.
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer
      description: >-
        Timbal API key. Obtain your API key from the Timbal platform settings.
        See [Authentication](/api-reference/authentication) for more
        information.

````