# Invoice & Receipt OCR API - Math-Verified Bookkeeping & MCP (`offthetoolsco/verified-invoice-receipt-ocr`) Actor

Invoice & Receipt OCR API and MCP Server: Extract line items to JSON with Math-Verified Bookkeeping OCR. Audited by deterministic Python Decimal math checksums.

- **URL**: https://apify.com/offthetoolsco/verified-invoice-receipt-ocr.md
- **Developed by:** [offthetoolsco](https://apify.com/offthetoolsco) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $30.00 / 1,000 verified documents

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## Invoice, Receipt & Bank Statement OCR API — Math-Verified Bookkeeping OCR & MCP Server

Stop letting raw Vision LLMs silently hallucinate bookkeeping totals. **Verified Invoice & Receipt OCR** is a production-ready **Bookkeeping OCR API** and zero-install **MCP Server** engineered to extract **invoices, receipts, and multi-page bank statements** with deterministic mathematical certainty. Built for accountants, developers, and AI agents, it pairs multimodal Vision LLMs with a Python `Decimal` arithmetic verification engine that guarantees every line item and running bank balance reconciles before hitting Xero, QuickBooks, or MYOB.

***

### ⚡ Instant 1-Click Trial (Zero Setup)

Experience zero-friction verification in seconds:

1. Navigate to the **Input** tab on this Apify Store page.
2. For **Invoices & Receipts**, leave `preset` as `invoice` and `documentUrls` prefilled with our live **Australian GST tax invoice**:
   `https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg`
3. For **Multi-Page Bank Statements + Xero CSV**, set `preset` to `bank_statement` and test with our live 2-page business statement PDF:
   `https://ocr-api.offthetoolsco.com.au/sample-bank-statement.pdf`
4. Click **Save & Run** (or **Start**) and inspect the verified JSON and `xero_csv` output in the **Dataset** tab.

***

### 🧠 Why Math-Verified Bookkeeping OCR Beats Raw Vision LLMs

Raw Vision LLM prompts are impressive at recognizing messy layouts, but they have a fatal flaw for accounting: **they hallucinate arithmetic**.

- **Digit Ambiguity & Smudges:** A fold in a receipt or a low-resolution PDF scan easily turns `$18.25` into `$18.75`. A raw LLM outputs the wrong digit without blinking.
- **Multi-Page Statement Drift:** Skipping a single line across pages 1–10 of a bank statement throws off every subsequent balance unless checked with an exact running-balance walk.
- **Silent Ledger Corruption:** When unverified JSON is piped directly into Xero, QuickBooks, MYOB, or NetSuite, reconciliation errors compound and require costly manual audits.

#### How Our Deterministic Math Engine Works

1. **High-Resolution Vision Extraction:** Single images or multi-page PDFs are parsed into strict JSON schemas.
2. **Deterministic `Decimal` Auditing:**
   - **Invoices & Receipts (`preset="invoice"`):** Verifies `qty * unit_price == line_total`, `sum(line_total) == subtotal`, and `subtotal + tax == total`.
   - **Bank Statements (`preset="bank_statement"`):** Runs a `running_balance_walk` across all pages—verifying `opening_balance`, each transaction's `credit`/`debit` delta against `running_balance`, and `closing_balance`, automatically skipping zero-delta `"BALANCE CARRIED FORWARD"` / `"BALANCE BROUGHT FORWARD"` rows and supporting `reverse_order=True` for newest-first statements.
3. **Targeted Self-Healing Retries:** If any row or total fails, the engine feeds the exact 1-based row index and dollar discrepancy back to the Vision LLM for a targeted re-read.
4. **Xero-Ready CSV Export (`xero_csv`):** Verified bank statements automatically emit clean chronological `*Date,*Amount,Payee,Description,Reference` CSV ready for direct Xero bank statement import—with zero `$0.00` carry-forward clutter.
5. **Audit Protection:** If digits remain irreconcilable after retries, `verification_passed` is `false` with exact `audit_errors` so corrupt numbers never enter your ledger.

***

### 🤖 Zero-Install Streamable HTTP & Stdio MCP Server

Connect this Actor directly to **Cursor**, **Claude Desktop**, **Antigravity**, **Windsurf**, or **Claude Code**:

- **`extract_invoice`**: Extract structured line items and totals from invoices/receipts (or custom schemas).
- **`reconcile_bank_statement`**: Reconcile multi-page bank statement PDFs/images with `running_balance_walk` (`reverse_order` supported) and return `xero_csv` plus exact `audit_errors` if any row mismatches.

#### Streamable HTTP Endpoint

```text
https://mcp.apify.com/?tools=fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr
```

#### 1-Click CLI Setup

```bash
## Add to Cursor
apify mcp install cursor --tools fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr

## Add to Claude Code
apify mcp install claude-code --tools fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr

## Add to VS Code
apify mcp install vscode --tools fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr
```

#### Manual Configuration (`claude_desktop_config.json` / `cursor.json`)

```json
{
  "mcpServers": {
    "verified-ocr": {
      "url": "https://mcp.apify.com/?tools=fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

#### Local Stdio MCP (via `uvx` / `pipx`)

Prefer a local stdio MCP server? Run directly with `uvx`:

```json
{
  "mcpServers": {
    "verified-ocr": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/offthetoolsco/verified-invoice-receipt-ocr", "verified-ocr"],
      "env": {
        "OCR_API_KEY": "YOUR_OCR_API_KEY"
      }
    }
  }
}
```

Or run from your terminal:

```bash
uvx --from git+https://github.com/offthetoolsco/verified-invoice-receipt-ocr verified-ocr
```

***

### 💰 Transparent Pay-Per-Event Pricing

No recurring subscription fees. No seat minimums. No monthly credit expirations.

- **$0.03 per verified document** (Pay-Per-Event via Apify platform).
- **$0.00005 Actor start fee** (nominal compute charge).
- **Zero Charge for Verification Retries:** Multi-pass self-healing arithmetic audits are included in the single document fee.
- Pay only for successful extractions written to your dataset.

***

### 📥 Input Parameters

| Parameter | Type | Required | Description |
|:---|:---|:---:|:---|
| `documentUrls` | `array` of `string` | Optional\* | Direct URLs to invoices, receipts, or multi-page PDFs. Prefilled with `sample-invoice.jpg`. |
| `preset` | `string` | Optional | `"invoice"` (default) or `"bank_statement"` (multi-page reconciliation + Xero CSV). |
| `reverseOrder` | `boolean` | Optional | Set `true` for newest-first (reverse chronological) bank statements (default `false`). |
| `fileBase64` | `string` | Optional\* | Base64-encoded document or data URI (ideal for local files in AI Agent workflows). |
| `fileName` | `string` | Optional | File name when providing `fileBase64` (e.g. `statement.pdf`). Defaults to `invoice.pdf`. |
| `jsonSchema` | `string` | Optional | Custom JSON Schema string. Omit to use the selected `preset` schema. |
| `mathRules` | `string` | Optional | Custom arithmetic rules array. Omit to use the selected `preset` math checks. |

*\* Provide either `documentUrls` or `fileBase64`.*

***

### 📤 Verified Output Schema

#### Invoice / Receipt Output

```json
{
  "source": "https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg",
  "job_id": "job_8f2b3e41a9c0",
  "status": "completed",
  "verification_passed": true,
  "pages_processed": 1,
  "attempts": 1,
  "latency_ms": 1420,
  "data": {
    "vendor_name": "Apex Electrical Contracting Pty Ltd",
    "tax_id": "ABN 84 123 456 789",
    "invoice_number": "INV-2026-0842",
    "invoice_date": "2026-11-20",
    "currency": "AUD",
    "items": [
      {
        "description": "Commercial Switchboard Upgrade & Safety Switch Installation",
        "qty": 1.0,
        "unit_price": 850.00,
        "line_total": 850.00
      }
    ],
    "subtotal": 850.00,
    "tax": 85.00,
    "total": 935.00
  },
  "audit_errors": []
}
```

#### Multi-Page Bank Statement Output (`preset="bank_statement"`)

```json
{
  "source": "https://ocr-api.offthetoolsco.com.au/sample-bank-statement.pdf",
  "job_id": "fb598638-8037-4161-82b4-3a5cf090b9a8",
  "status": "completed",
  "verification_passed": true,
  "pages_processed": 2,
  "attempts": 1,
  "data": {
    "institution": "SOUTHERN CROSS BUSINESS BANK",
    "account_holder": "OFF THE TOOLS CO PTY LTD",
    "currency": "AUD",
    "opening_balance": 12450.00,
    "closing_balance": 14546.70,
    "transactions": [...]
  },
  "xero_csv": "*Date,*Amount,Payee,Description,Reference\n2026-10-02,1840.50,,Shopify Payout - Settlement 4812,SHP-4812\n...",
  "audit_errors": []
}
```

***

### 🔒 Enterprise Privacy & Zero Data Retention

- **Ephemeral Processing:** Uploaded images and PDFs are loaded into memory or transient ephemeral storage solely for the duration of the extraction request.
- **Immediate Disk Purge:** All temporary files are permanently wiped immediately upon completion of the verification pass.
- **Zero Training:** Your confidential invoices, bank statements, and financial data are never used to train machine learning models.

***

### 🚀 Getting Started

1. Click **Try for free** or **Save & Run** above with the prefilled sample (or switch `preset` to `bank_statement` with `https://ocr-api.offthetoolsco.com.au/sample-bank-statement.pdf`).
2. Integrate with Python, Node.js, cURL, or MCP using the Apify API client or `uvx`.
3. For support or custom math rules, contact [Off The Tools Co.](https://offthetoolsco.com.au).

# Actor input Schema

## `documentUrls` (type: `array`):

One or more direct URLs to invoices, receipts, or multi-page bank statement PDFs. Prefilled with a sample Australian GST tax invoice for instant 1-click trial.

## `preset` (type: `string`):

Built-in schema & Decimal audit preset. Use 'invoice' (default) for invoices/receipts, or 'bank_statement' for multi-page bank statement reconciliation + Xero CSV export (try https://ocr-api.offthetoolsco.com.au/sample-bank-statement.pdf).

## `reverseOrder` (type: `boolean`):

Enable when bank statement rows are ordered newest-first (reverse chronological) so running_balance_walk audits and Xero CSV exports emit oldest-first.

## `fileBase64` (type: `string`):

Optional base64 string (or data URI) of a PDF, JPG, PNG, or WEBP file if not using documentUrls.

## `fileName` (type: `string`):

Example: invoice.pdf, statement.pdf, or receipt.jpg (defaults to invoice.pdf if omitted).

## `jsonSchema` (type: `string`):

Optional JSON Schema string. Leave empty to use the selected preset schema (Invoice or Bank Statement).

## `mathRules` (type: `string`):

Optional JSON array of declarative arithmetic rules. Leave empty to use the selected preset math verification rules.

## Actor input object example

```json
{
  "documentUrls": [
    "https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg"
  ],
  "preset": "invoice",
  "reverseOrder": false,
  "fileName": "invoice.pdf"
}
```

# Actor output Schema

## `verifiedDocuments` (type: `string`):

Structured JSON extractions and Xero CSV exports audited by deterministic Decimal arithmetic checksums.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "documentUrls": [
        "https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("offthetoolsco/verified-invoice-receipt-ocr").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "documentUrls": ["https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("offthetoolsco/verified-invoice-receipt-ocr").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "documentUrls": [
    "https://ocr-api.offthetoolsco.com.au/sample-invoice.jpg"
  ]
}' |
apify call offthetoolsco/verified-invoice-receipt-ocr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,offthetoolsco/verified-invoice-receipt-ocr"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/ffPCNE5t967FjBUpk/builds/BLnN2kQobQO1r8RGx/openapi.json
