# DocPipe Verify - check an invoice before you post or pay it (`pycasdesign/docpipe-verify`) Actor

Deterministic invoice checks for AI agents: totals reconcile, required fields present, duplicates against your recent invoices, plausible dates, valid currency. Returns PASS, REVIEW or REJECT with canAutoPost / canAutoPay and the reason for every hold.

- **URL**: https://apify.com/pycasdesign/docpipe-verify.md
- **Developed by:** [biju jacob](https://apify.com/pycasdesign) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $10.00 / 1,000 invoice-verifieds

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/running/actors-in-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

## DocPipe Verify

Check an invoice before your agent or automation posts or pays it.

Send the invoice fields you already have, from any extractor. You get back a verdict, two flags your agent can act on, and the reason for every hold.

| Field | Meaning |
|---|---|
| `verdict` | **PASS**: every check that matters ran and passed. **REVIEW**: a warning, or not enough evidence (for example, totals that can't be reconciled). **REJECT**: a check failed, so don't post this data as given. |
| `canAutoPost` | `true` only when the verdict is PASS |
| `canAutoPay` | `true` only when the verdict is PASS **and** the duplicate check actually ran against `priorInvoices` and passed |
| `holdReasons` | Why either flag is false, for example `TOTAL_MISMATCH`, `POSSIBLE_DUPLICATE`, `DUPLICATES_NOT_CHECKED`, `TOTALS_NOT_VERIFIED` |

A warning is never an approval, and a check that couldn't run is never reported as a pass.

The checks are deterministic: plain arithmetic and rules, with no AI deciding. The same request always gives the same answer, and `inputHash` identifies the request. It's computed from the parsed values, so key order, spacing, `561.6` vs `561.60` and Unicode spelling don't change it.

### Checks

| Check | What it does |
|---|---|
| `requiredFields` | Vendor, invoice number, invoice date and total are present |
| `arithmetic` | Subtotal + tax = total (to half a cent), with the expected and found amounts |
| `lineItems` | Line items add up to the subtotal (or the total when there is no subtotal) |
| `dates` | Not in the future; warns when over two years old, or due before issued |
| `purchaseOrder` | PO number present, when you set `poRequired` |
| `duplicate` | Compared with your `priorInvoices` on normalized values ("Northwind Supply Co." = "NORTHWIND SUPPLY, INC"; "INV-0041" = "inv 0041"). Same vendor and number: REJECT. Same vendor, currency and total within 7 days under a different number: REVIEW, with the matched invoice, since it may be a re-issue or a recurring charge. |
| `approvedVendor` | Vendor is on your `approvedVendors` list, when you send one |
| `currency` | A real ISO 4217 code, matching `expectedCurrency` if you set it; warns when currency is missing or the total is negative (credit note) |
| `extractionConfidence` | Fields your extractor scored below `minFieldConfidence` (default 0.8). Confidence is reported per field and never blended into a "safe" score. |

### Input rules

Amounts must be JSON numbers (not strings) with at most 4 decimal places. Dates must be `YYYY-MM-DD`. Unknown field names are rejected, so a typo like `totl` never silently becomes "missing total". Malformed invoices come back as `verdict: "ERROR"` with the field named, and aren't charged.

### Example

Input:

```json
{
  "invoices": [{
    "vendor": "Northwind Supply Co.", "invoiceNumber": "NW-20841", "invoiceDate": "2026-09-30",
    "currency": "USD", "subtotal": 520.00, "tax": 41.60, "total": 601.60
  }],
  "options": {
    "priorInvoices": [{ "vendor": "Northwind Supply Co.", "invoiceNumber": "NW-20799", "total": 388.10, "invoiceDate": "2026-09-02", "currency": "USD" }]
  }
}
```

Dataset item:

```json
{
  "index": 0,
  "invoiceNumber": "NW-20841",
  "verdict": "REJECT",
  "canAutoPost": false,
  "canAutoPay": false,
  "holdReasons": ["TOTAL_MISMATCH"],
  "checks": { "requiredFields": "PASS", "arithmetic": "FAIL", "lineItems": "NOT_CHECKED", "dates": "PASS",
              "purchaseOrder": "NOT_CHECKED", "duplicate": "PASS", "approvedVendor": "NOT_CHECKED",
              "currency": "PASS", "extractionConfidence": "NOT_CHECKED" },
  "issues": [{ "code": "TOTAL_MISMATCH", "severity": "ERROR", "field": "total",
               "message": "Subtotal 520.00 + tax 41.60 = 561.60, but stated total is 601.60 (difference 40.00)",
               "reason": null, "expected": 561.60, "found": 601.60, "matchedInvoice": null }],
  "missingFields": [],
  "validatedFields": { "vendor": true, "invoiceNumber": true, "invoiceDate": true, "subtotal": false, "tax": false, "total": false },
  "fieldConfidence": {},
  "rulesetVersion": "2026-10.2",
  "inputHash": "sha256:..."
}
```

### Pricing

You're charged once for each invoice that gets a verdict. Malformed invoices aren't charged. When your run's spending limit is reached, the run stops; it never goes over. If the platform restarts a run, invoices already charged are delivered from saved results and aren't charged again.

### Your data

Invoice fields are sent over HTTPS to the DocPipe API (Pycas Design Innovations, hosted on AWS) to be checked, and are not stored there. Invoice contents are never logged. Results are saved only in your own Apify storage. Send only the fields the checks need: no bank details are required.

# Actor input Schema

## `invoices` (type: `array`):

Invoice fields you already extracted, as JSON numbers and YYYY-MM-DD dates, one object per invoice (up to 500): vendor, invoiceNumber, invoiceDate (YYYY-MM-DD), dueDate, poNumber, currency (ISO 4217), subtotal, tax, total, lines \[{description, quantity, unitPrice, amount}], and optional confidence {field: 0..1}. You are charged once per invoice checked.

## `options` (type: `object`):

Optional context, applied to every invoice: priorInvoices (array of {vendor, invoiceNumber, total, invoiceDate, currency}) - needed for canAutoPay; approvedVendors (array of names); poRequired (boolean); minFieldConfidence (0..1, default 0.8); expectedCurrency (e.g. USD); asOf (YYYY-MM-DD, fixes 'today' for date checks).

## Actor input object example

```json
{
  "invoices": [
    {
      "vendor": "Northwind Supply Co.",
      "invoiceNumber": "NW-20841",
      "invoiceDate": "2026-09-30",
      "currency": "USD",
      "subtotal": 520,
      "tax": 41.6,
      "total": 601.6,
      "lines": [
        {
          "description": "Shop towels",
          "amount": 185
        },
        {
          "description": "Nitrile gloves",
          "amount": 295
        },
        {
          "description": "Delivery",
          "amount": 40
        }
      ]
    }
  ],
  "options": {
    "poRequired": false,
    "priorInvoices": []
  }
}
```

# Actor output Schema

## `verdicts` (type: `string`):

Verification results, one item per invoice in input order.

# 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 = {
    "invoices": [
        {
            "vendor": "Northwind Supply Co.",
            "invoiceNumber": "NW-20841",
            "invoiceDate": "2026-09-30",
            "currency": "USD",
            "subtotal": 520,
            "tax": 41.6,
            "total": 601.6,
            "lines": [
                {
                    "description": "Shop towels",
                    "amount": 185
                },
                {
                    "description": "Nitrile gloves",
                    "amount": 295
                },
                {
                    "description": "Delivery",
                    "amount": 40
                }
            ]
        }
    ],
    "options": {
        "poRequired": false,
        "priorInvoices": []
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("pycasdesign/docpipe-verify").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 = {
    "invoices": [{
            "vendor": "Northwind Supply Co.",
            "invoiceNumber": "NW-20841",
            "invoiceDate": "2026-09-30",
            "currency": "USD",
            "subtotal": 520,
            "tax": 41.6,
            "total": 601.6,
            "lines": [
                {
                    "description": "Shop towels",
                    "amount": 185,
                },
                {
                    "description": "Nitrile gloves",
                    "amount": 295,
                },
                {
                    "description": "Delivery",
                    "amount": 40,
                },
            ],
        }],
    "options": {
        "poRequired": False,
        "priorInvoices": [],
    },
}

# Run the Actor and wait for it to finish
run = client.actor("pycasdesign/docpipe-verify").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 '{
  "invoices": [
    {
      "vendor": "Northwind Supply Co.",
      "invoiceNumber": "NW-20841",
      "invoiceDate": "2026-09-30",
      "currency": "USD",
      "subtotal": 520,
      "tax": 41.6,
      "total": 601.6,
      "lines": [
        {
          "description": "Shop towels",
          "amount": 185
        },
        {
          "description": "Nitrile gloves",
          "amount": 295
        },
        {
          "description": "Delivery",
          "amount": 40
        }
      ]
    }
  ],
  "options": {
    "poRequired": false,
    "priorInvoices": []
  }
}' |
apify call pycasdesign/docpipe-verify --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pycasdesign/docpipe-verify"
        }
    }
}
```

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/MRJmXfgZjbLWEshLg/builds/ExFFn2RgXGakH1Trl/openapi.json
