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

# Trigger document processing

> Trigger asynchronous processing of an uploaded document.

This endpoint should be called after successfully uploading a file to the presigned URL.
It will:
1. Create a document record in the database with the specified UUID
2. Enqueue a background task to process the document (chunking and embedding)

The document status will be updated from 'pending' -> 'processing' -> 'completed' or 'failed'.

Embedding Services:
* openai (default): High-quality 1536-dimensional embeddings (requires OPENAI_API_KEY)
* sentence_transformer: Free, offline-capable, 384-dimensional embeddings

Access Control:
* Users can only process documents in their organization.



## OpenAPI

````yaml /api-reference/openapi.en.json post /api/v1/knowledge-base/process-document
openapi: 3.1.0
info:
  title: Brosbots API
  description: >
    The public Brosbots REST API. Build and manage voice agents, run outbound

    campaigns, read calls and usage, and manage phone numbers, tools,

    knowledge bases and integrations.


    ## Authentication


    Every request must include your organization's API key in the

    `X-API-Key` header:


    ```

    X-API-Key: bb_live_...

    ```


    You create and revoke keys in the dashboard:

    click your account in the bottom-left corner of the sidebar, then **Brosbots
    API**.


    ## Base URL


    ```

    https://app.brosbots.com/api/v1

    ```


    ## Conventions


    - Request and response bodies are JSON (`Content-Type: application/json`).

    - Timestamps are ISO 8601 with a timezone.

    - Lists are paginated with `page` / `limit` parameters; responses include
      `total_count` / `total_pages`.
    - Errors use standard HTTP status codes with a JSON body:
      `{"detail": "a human-readable reason"}`.
    - `{agent_id}` accepts the agent's public ID (`agent_...`) or its number.


    ## Limits


    There is no fixed per-key request-rate limit today. `429` comes from the

    calling endpoints (`POST /agents/{agent_id}/calls` and

    `POST /triggers/{trigger_id}/calls`) when every outbound channel is busy;
    its `Retry-After` header says how many seconds to wait. Handle `429`

    generally: wait as long as `Retry-After` says, or back off exponentially
    when

    it is absent. A request-rate limit may be introduced.
  version: 1.0.0
servers: []
security:
  - ApiKeyAuth: []
paths:
  /api/v1/knowledge-base/process-document:
    post:
      tags:
        - Knowledge Base
      summary: Trigger document processing
      description: >-
        Trigger asynchronous processing of an uploaded document.


        This endpoint should be called after successfully uploading a file to
        the presigned URL.

        It will:

        1. Create a document record in the database with the specified UUID

        2. Enqueue a background task to process the document (chunking and
        embedding)


        The document status will be updated from 'pending' -> 'processing' ->
        'completed' or 'failed'.


        Embedding Services:

        * openai (default): High-quality 1536-dimensional embeddings (requires
        OPENAI_API_KEY)

        * sentence_transformer: Free, offline-capable, 384-dimensional
        embeddings


        Access Control:

        * Users can only process documents in their organization.
      operationId: post_knowledge_base_process_document
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessDocumentRequestSchema'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DocumentResponseSchema'
        '404':
          description: Not found
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    ProcessDocumentRequestSchema:
      properties:
        document_uuid:
          type: string
          description: Document UUID to process
        s3_key:
          type: string
          description: Storage key of the uploaded file.
        embedding_service:
          type: string
          enum:
            - sentence_transformer
            - openai
          description: >-
            Embedding service to use for processing. Options: 'openai' (default,
            1536-dim, requires API key) or 'sentence_transformer' (free,
            384-dim)
          default: openai
      type: object
      required:
        - document_uuid
        - s3_key
      title: ProcessDocumentRequestSchema
      description: Request schema for triggering document processing.
    DocumentResponseSchema:
      properties:
        id:
          type: integer
        document_uuid:
          type: string
        filename:
          type: string
        file_size_bytes:
          type: integer
        file_hash:
          type: string
        mime_type:
          type: string
        processing_status:
          type: string
        processing_error:
          anyOf:
            - type: string
            - type: 'null'
        total_chunks:
          type: integer
        custom_metadata:
          additionalProperties: true
          type: object
        docling_metadata:
          additionalProperties: true
          type: object
        source_url:
          anyOf:
            - type: string
            - type: 'null'
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        organization_id:
          type: integer
        created_by:
          type: integer
        is_active:
          type: boolean
      type: object
      required:
        - id
        - document_uuid
        - filename
        - file_size_bytes
        - file_hash
        - mime_type
        - processing_status
        - total_chunks
        - custom_metadata
        - docling_metadata
        - created_at
        - updated_at
        - organization_id
        - created_by
        - is_active
      title: DocumentResponseSchema
      description: Response schema for document metadata.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
        msg:
          type: string
        type:
          type: string
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Your organization's API key (account in the bottom-left of the dashboard
        → Brosbots API).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.