Credits (1)

About the LedgerBox API

This document outlines the API endpoints for our intelligent document processing application. The API allows users to upload documents, check job statuses, and retrieve processed results.

Interactive SwaggerUI

Click here to try our Swagger documentation

Authentication

All endpoints require authentication using an API key. Include the API key in the request headers.

Click here to get an API Key

x-api-key: your-api-key

Endpoints

1. Upload Files for Processing

Upload files to be processed by a specified OCR model.

  • URL: /api/protected/upload
  • Method: POST
  • Content-Type: multipart/form-data

Parameters

  • Parameter: model
    • Type: "invoice" | "receipt" | "bankstatement" (string)
    • Required: Yes
    • Description: The model to process the files with.

Request Body

  • Field: files
    • Type: array
    • Required: Yes
    • Description: The files to be uploaded (1-10 files).

Response

  • Status Code: 200 OK
  • Content-Type: application/json
{
  "message": "Files uploaded successfully",
  "results": {
    "jobId": "job-12345",
    "jobStatus": "success",
    "documentIds": ["doc-67890", "doc-54321"]
  }
}
{
  "message": "Files uploaded successfully",
  "results": {
    "jobId": "job-12345",
    "jobStatus": "success",
    "documentIds": ["doc-67890", "doc-54321"]
  }
}

Error Responses

  • 400 Bad Request: Invalid model or number of files
  • 401 Unauthorized: Invalid API key

2. Get Job Status

Retrieve the status of a processing job.

  • URL: /api/protected/job
  • Method: GET

Query Parameters

  • Name: jobId
    • Type: string
    • Required: Yes
    • Description: The ID of the job

Response

  • Status Code: 200 OK
  • Content-Type: application/json
{
  "status": "success"
}
{
  "status": "success"
}

The status field can have one of the following values:

  • "pending": The job is still being processed
  • "success": The job has completed successfully
  • "error": An error occurred during job processing

Error Responses

  • 400 Bad Request: Missing job ID
  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Job not found

3. Export Job Results

Retrieve the processed results of a completed job.

  • URL: /api/protected/export
  • Method: GET

Query Parameters

  • Name: jobId
    • Type: string
    • Required: Yes
    • Description: The ID of the job

Response

  • Status Code: 200 OK
  • Content-Type: application/json
{
  "status": "success",
  "jobId": "job-12345",
  "content": [
    {
      "id": "doc-67890",
      "status": "success",
      "content": { ... } // Varies based on document type
    },
    // ... additional documents
  ]
}
{
  "status": "success",
  "jobId": "job-12345",
  "content": [
    {
      "id": "doc-67890",
      "status": "success",
      "content": { ... } // Varies based on document type
    },
    // ... additional documents
  ]
}

The status field in the response and for each document can be "success", "pending", or "error".

The content field will contain different schemas depending on the document type (Invoice, BankStatement, or Receipt). It will only be present for documents with a "success" status.

Error Responses

  • 400 Bad Request: Missing job ID
  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Job not found

The content field will contain different schemas depending on the document type (Invoice, BankStatement, or Receipt).

Error Responses

  • 400 Bad Request: Missing job ID
  • 401 Unauthorized: Invalid API key
  • 404 Not Found: Job not found

Document Schemas

Invoice

interface Invoice {
  CustomerName?: string
  CustomerId?: string
  PurchaseOrder?: string
  InvoiceId?: string
  InvoiceDate?: string // format: date
  DueDate?: string // format: date
  VendorName?: string
  VendorTaxId?: string
  VendorAddress?: string
  VendorAddressRecipient?: string
  CustomerAddress?: string
  CustomerTaxId?: string
  CustomerAddressRecipient?: string
  BillingAddress?: string
  BillingAddressRecipient?: string
  ShippingAddress?: string
  ShippingAddressRecipient?: string
  PaymentTerm?: string
  SubTotal?: number
  TotalTax?: number
  InvoiceTotal?: number
  AmountDue?: number
  ServiceAddress?: string
  ServiceAddressRecipient?: string
  RemittanceAddress?: string
  RemittanceAddressRecipient?: string
  ServiceStartDate?: string
  ServiceEndDate?: string
  PreviousUnpaidBalance?: number
  CurrencyCode?: string
  KVKNumber?: string
  PaymentDetails?: string[]
  TotalDiscount?: number
  TaxItems?: string[]
  LineItems?: LineItem[]
  AdditionalItems?: AdditionalField[]
}
 
interface LineItem {
  Items?: string
  Amount?: number
  Description?: string
  Quantity?: number
  UnitPrice?: number
  ProductCode?: string
  Unit?: string
  Date?: string
  Tax?: number
  TaxRate?: number
}
 
interface AdditionalField {
  FieldName?: string
  FieldValue?: string
}
interface Invoice {
  CustomerName?: string
  CustomerId?: string
  PurchaseOrder?: string
  InvoiceId?: string
  InvoiceDate?: string // format: date
  DueDate?: string // format: date
  VendorName?: string
  VendorTaxId?: string
  VendorAddress?: string
  VendorAddressRecipient?: string
  CustomerAddress?: string
  CustomerTaxId?: string
  CustomerAddressRecipient?: string
  BillingAddress?: string
  BillingAddressRecipient?: string
  ShippingAddress?: string
  ShippingAddressRecipient?: string
  PaymentTerm?: string
  SubTotal?: number
  TotalTax?: number
  InvoiceTotal?: number
  AmountDue?: number
  ServiceAddress?: string
  ServiceAddressRecipient?: string
  RemittanceAddress?: string
  RemittanceAddressRecipient?: string
  ServiceStartDate?: string
  ServiceEndDate?: string
  PreviousUnpaidBalance?: number
  CurrencyCode?: string
  KVKNumber?: string
  PaymentDetails?: string[]
  TotalDiscount?: number
  TaxItems?: string[]
  LineItems?: LineItem[]
  AdditionalItems?: AdditionalField[]
}
 
interface LineItem {
  Items?: string
  Amount?: number
  Description?: string
  Quantity?: number
  UnitPrice?: number
  ProductCode?: string
  Unit?: string
  Date?: string
  Tax?: number
  TaxRate?: number
}
 
interface AdditionalField {
  FieldName?: string
  FieldValue?: string
}

Bank Statement

interface BankStatement {
  CustomerName?: string
  AccountNumber?: string
  BankName?: string
  BankAddress?: string
  PeriodStartDate?: string
  PeriodEndDate?: string
  LineItems?: BankLineItem[]
}
 
interface BankLineItem {
  Date?: string
  Description?: string
  Amount?: number
}
interface BankStatement {
  CustomerName?: string
  AccountNumber?: string
  BankName?: string
  BankAddress?: string
  PeriodStartDate?: string
  PeriodEndDate?: string
  LineItems?: BankLineItem[]
}
 
interface BankLineItem {
  Date?: string
  Description?: string
  Amount?: number
}

Receipt

interface Receipt {
  MerchantName?: string
  MerchantPhoneNumber?: string
  MerchantAddress?: string
  Total?: number
  TransactionDate?: string
  TransactionTime?: string
  Subtotal?: number
  TotalTax?: number
  Tip?: number
  Items?: Item[]
  TaxDetails?: TaxDetail[]
  AdditionalItems?: AdditionalField[]
}
 
interface Item {
  TotalPrice?: number
  Description?: string
  Quantity?: number
  Price?: number
  ProductCode?: string
  QuantityUnit?: string
}
 
interface TaxDetail {
  Amount?: number
}
interface Receipt {
  MerchantName?: string
  MerchantPhoneNumber?: string
  MerchantAddress?: string
  Total?: number
  TransactionDate?: string
  TransactionTime?: string
  Subtotal?: number
  TotalTax?: number
  Tip?: number
  Items?: Item[]
  TaxDetails?: TaxDetail[]
  AdditionalItems?: AdditionalField[]
}
 
interface Item {
  TotalPrice?: number
  Description?: string
  Quantity?: number
  Price?: number
  ProductCode?: string
  QuantityUnit?: string
}
 
interface TaxDetail {
  Amount?: number
}

This API documentation provides a comprehensive overview of the available endpoints, their parameters, expected responses, and the data schemas for different document types processed by the OCR system.