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

# Upload Document

> Uploads a new document to a knowledge base. The document content is
chunked and synced to the vector store for RAG retrieval.
Requires `knowledge:upload` permission.




## OpenAPI

````yaml POST /api/knowledge-bases/{id}/documents
openapi: 3.1.0
info:
  title: Naturalead Knowledge Bases API
  version: 1.0.0
  description: >
    API for managing knowledge bases, documents, sitemap crawl jobs, and webhook

    sources in the Naturalead platform. All endpoints require API key
    authentication

    and are scoped to the caller's account.
servers:
  - url: '{baseUrl}'
    description: API server
    variables:
      baseUrl:
        default: http://localhost:3001
security:
  - BearerAuth: []
tags:
  - name: Knowledge Bases
    description: Knowledge base CRUD operations
  - name: Documents
    description: Document management within a knowledge base
  - name: Sitemap & Crawl Jobs
    description: Sitemap scanning and web crawl job management
  - name: Webhook Sources
    description: Webhook source management for auto-updating content
paths:
  /api/knowledge-bases/{id}/documents:
    post:
      tags:
        - Documents
      summary: Upload document
      description: |
        Uploads a new document to a knowledge base. The document content is
        chunked and synced to the vector store for RAG retrieval.
        Requires `knowledge:upload` permission.
      operationId: uploadDocument
      parameters:
        - $ref: '#/components/parameters/KnowledgeBaseId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                  description: Document title
                sourceType:
                  type: string
                  description: Type of source content
                  default: text
                content:
                  type: string
                  description: Document content
                sourceUrl:
                  type: string
                  description: Optional URL where the content was sourced from
              required:
                - title
                - content
      responses:
        '201':
          description: Created document
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Document'
        '400':
          $ref: '#/components/responses/BadRequest'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    KnowledgeBaseId:
      name: id
      in: path
      required: true
      description: Knowledge base ID
      schema:
        type: string
  schemas:
    Document:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier
        knowledgeBaseId:
          type: string
          description: Parent knowledge base ID
        accountId:
          type: string
          description: Owning account ID
        title:
          type: string
          description: Document title
        sourceType:
          type: string
          description: Type of source content
        content:
          type: string
          description: Document content
        sourceUrl:
          type: string
          description: URL where the content was sourced from
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
      required:
        - _id
        - knowledgeBaseId
        - accountId
        - title
        - sourceType
        - content
        - createdAt
        - updatedAt
  responses:
    BadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
    NotFound:
      description: Resource not found
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
            required:
              - error
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Bearer token using an API key (format nl_live_* or nl_test_*)

````