# Trigger document processing

> POST /api/v1/knowledge-base/process-document — request parameters and responses from the Menace Voice API schema.

`POST /api/v1/knowledge-base/process-document`

{/* Generated by scripts/sync_docs_api.mjs. Edit the API schema source to change the contract. */}

See [authentication](/api-reference/authentication) for workspace API access. Public embed and artifact endpoints use their documented session or access tokens.

## API contract for documentation tools

Generated from the OpenAPI schema. Do not infer a different parameter type from an example. Authentication headers are alternatives as explained in the authentication guide.

### Parameters

| Name | Location | Type | Required | Description and constraints |
| --- | --- | --- | --- | --- |
| authorization | header | string or null | no |  |
| X-API-Key | header | string or null | no |  |

### Request body: application/json

Required body. Schema: ProcessDocumentRequestSchema (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| document_uuid | string | yes | Document UUID to process |
| s3_key | string | yes | S3 key of the uploaded file |
| retrieval_mode | string | no | Retrieval mode: 'chunked' for vector search or 'full_document' for full text retrieval default: "chunked" |

### Response 200

Successful Response

application/json: DocumentResponseSchema (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| id | integer | yes |  |
| document_uuid | string | yes |  |
| filename | string | yes |  |
| file_size_bytes | integer | yes |  |
| file_hash | string | yes |  |
| mime_type | string | yes |  |
| processing_status | string | yes |  |
| processing_error | string or null | no |  |
| total_chunks | integer | yes |  |
| retrieval_mode | string | no | default: "chunked" |
| custom_metadata | object | yes |  |
| docling_metadata | object | yes |  |
| source_url | string or null | no |  |
| content | string or null | no | Extracted document content for preview when processing is complete |
| created_at | string | yes | format: "date-time" |
| updated_at | string | yes | format: "date-time" |
| organization_id | integer | yes |  |
| created_by | integer | yes |  |
| is_active | boolean | yes |  |

### Response 404

Not found

### Response 422

Validation Error

application/json: HTTPValidationError (object).

| Field | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| detail | array of ValidationError (object) | no |  |

## OpenAPI

````yaml api-reference/openapi.json post /api/v1/knowledge-base/process-document
openapi: 3.1.0
info:
  title: Menace Voice API
  description: API for Menace Voice agents
  version: 1.0.0
servers:
  - url: https://voice.menaceui.com
    description: Production
  - url: http://localhost:8000
    description: Local development
paths:
  /api/v1/knowledge-base/process-document:
    post:
      tags:
        - main
        - 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:

        Uses OpenAI text-embedding-3-small (1536-dimensional embeddings,
        requires API key configured in Model Configurations).


        Access Control:

        * Users can only process documents in their organization.
      operationId: process_document_api_v1_knowledge_base_process_document_post
      parameters:
        - name: authorization
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: Authorization
        - name: X-API-Key
          in: header
          required: false
          schema:
            anyOf:
              - type: string
              - type: "null"
            title: X-Api-Key
      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:
    DocumentResponseSchema:
      properties:
        id:
          type: integer
          title: Id
        document_uuid:
          type: string
          title: Document Uuid
        filename:
          type: string
          title: Filename
        file_size_bytes:
          type: integer
          title: File Size Bytes
        file_hash:
          type: string
          title: File Hash
        mime_type:
          type: string
          title: Mime Type
        processing_status:
          type: string
          title: Processing Status
        processing_error:
          anyOf:
            - type: string
            - type: "null"
          title: Processing Error
        total_chunks:
          type: integer
          title: Total Chunks
        retrieval_mode:
          type: string
          title: Retrieval Mode
          default: chunked
        custom_metadata:
          additionalProperties: true
          type: object
          title: Custom Metadata
        docling_metadata:
          additionalProperties: true
          type: object
          title: Docling Metadata
        source_url:
          anyOf:
            - type: string
            - type: "null"
          title: Source Url
        content:
          anyOf:
            - type: string
            - type: "null"
          title: Content
          description: Extracted document content for preview when processing is complete
        created_at:
          type: string
          format: date-time
          title: Created At
        updated_at:
          type: string
          format: date-time
          title: Updated At
        organization_id:
          type: integer
          title: Organization Id
        created_by:
          type: integer
          title: Created By
        is_active:
          type: boolean
          title: Is Active
      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
          title: Detail
      type: object
      title: HTTPValidationError
    ProcessDocumentRequestSchema:
      properties:
        document_uuid:
          type: string
          title: Document Uuid
          description: Document UUID to process
        s3_key:
          type: string
          title: S3 Key
          description: S3 key of the uploaded file
        retrieval_mode:
          type: string
          title: Retrieval Mode
          description: "Retrieval mode: 'chunked' for vector search or 'full_document' for
            full text retrieval"
          default: chunked
      type: object
      required:
        - document_uuid
        - s3_key
      title: ProcessDocumentRequestSchema
      description: Request schema for triggering document processing.
    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
````
