---
title: "Upload AP Document for AI Processing"
method: POST
path: "/v1/platform/businesses/{business_id}/ap-documents/upload"
tags: ["Accounts Payable"]
---

# Upload AP Document for AI Processing

`POST /v1/platform/businesses/{business_id}/ap-documents/upload`

## Request

- Base URL: `https://docs.thredfi.com` (the document declares no server; this is the origin it was published from)
- URL: `https://docs.thredfi.com/v1/platform/businesses/{business_id}/ap-documents/upload`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP basic
  - HTTP bearer
  - HTTP bearer

Upload an accounts payable document (vendor invoice, credit note, or receipt) for automated processing.

        **Processing Flow:**
        1. File is uploaded to S3 storage
        2. Background LangGraph workflow is queued
        3. API returns immediately (202 Accepted)
        4. Background processing:
           - Downloads file and calculates content hash
           - Quick duplicate check (exact file match)
           - Extracts data using Reducto AI
           - Classifies document type (invoice/credit_note/receipt)
           - Validates document is for this company
           - Routes to type-specific workflow:
             * **Invoice**: Creates/matches vendor, checks duplicates, creates Bill
             * **Credit Note**: Creates VendorCreditNote
             * **Receipt**: Matches to Bill, updates payment status
        5. Processed document appears in GET /bills/ or relevant endpoint

        **File Requirements:**
        - Format: PDF or images (PNG, JPEG, GIF, BMP, TIFF, HEIC)
        - Size: Maximum 50MB for PDF, 10-20MB for images
        - Content: Vendor invoice, credit note, or receipt
        - Content-Type validation: File content is verified to match declared type

        **Document Classification:**
        - AI determines if document is invoice, credit note, or receipt
        - Invoice: Bill created, vendor matched/created
        - Credit Note: VendorCreditNote created
        - Receipt: Matched to existing Bill if possible

        **Vendor Matching (for invoices):**
        - AI semantic matching (handles "Amazon Inc" vs "Amazon.com")
        - VAT number matching (very strong signal)
        - Creates new vendor if no confident match found

        **Duplicate Detection:**
        - File hash check (exact file duplicate)
        - AI semantic duplicate check (same invoice number, date, amount)
        - High confidence duplicates (≥90%) flagged for review
        - Medium confidence (70-89%) flagged for review

        **Company Validation:**
        - Invoices/Credit Notes: Strict validation (must match company name/VAT)
        - Receipts: Lenient validation (assumes for company unless explicitly different)
        - Documents not for this company are flagged for review

        **Review Flags:**
        Documents may be flagged for manual review if:
        - Duplicate detected (file or semantic)
        - Not for this company
        - Low extraction confidence
        - Uncertain document type classification
        - Line items don't match total

        **Access Control:**
        - Requires partner authentication
        - Business must belong to authenticated partner

## Path parameters

- `business_id` string, uuid, required

## Request body

- APDocumentUploadRequestRequest: Request serializer for AP document upload endpoint
  - `file` string, binary, required: PDF or image file to upload (max 50MB)

## Response `202`

- APDocumentUploadResponse: Response serializer for AP document upload endpoint
  - `document_id` string, uuid, required: Unique identifier for the uploaded document
  - `task_id` string, required: Celery task ID for tracking processing
  - `status` string, required: Current status (always 'processing' initially)
  - `message` string, required: Instructions for checking result

## Other responses

- `400`: Validation errors in request data
- `401`: Authentication required - missing or invalid API key
- `403`: Permission denied - insufficient privileges
- `404`: Resource not found
- `409`: Conflict - resource already exists or invalid state transition
- `422`: Unprocessable entity - business logic validation failed
- `500`: Internal server error

---

[API](https://skmtc.dev/thredfi/apis/thredfi-accounting-platform-api.md) - [All operations](https://skmtc.dev/thredfi/apis/thredfi-accounting-platform-api/llms.txt) - [OpenAPI document](https://skmtc.dev/thredfi/apis/thredfi-accounting-platform-api/revisions/0c1918254db3?raw)
