# 3PL Fulfillment Invoice Audit — Rate & Quantity Checks (`natstandridge/3pl-fulfillment-invoice-audit`) Actor

Check structured 3PL warehouse invoice lines against your signed unit rates and optional activity export. Get traceable overcharge candidates and review flags.

- **URL**: https://apify.com/natstandridge/3pl-fulfillment-invoice-audit.md
- **Developed by:** [Nathaniel Standridge](https://apify.com/natstandridge) (community)
- **Categories:** E-commerce, Business
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$30.00 / 1,000 delivered 3pl invoice-line checks

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

## 3PL Fulfillment Invoice Audit — Rate & Quantity Checks

**Find warehouse fee lines worth disputing before approving a monthly 3PL bill.** Give the Actor a structured invoice export and the unit rates in your signed contract. It recalculates each supported line with decimal arithmetic, shows the exact rate-card row used, and separates potential overcharges from lines that need a person to review them.

This product is for ecommerce operations and finance teams paying a third-party warehouse for receiving, picks, packing, storage or returns under fixed unit prices. Run it each billing cycle. It reads only the CSV text you supply; it does not log into a 3PL, fetch carrier labels, read contracts from PDFs, file disputes or make payments.

### Try it with the complete sample

The prefilled sample uses two invoice lines. Replace it with your own exports in the Input form or run the JSON in [`examples/input.json`](examples/input.json):

```json
{
  "invoiceCsv": "line_id,service_code,period_start,period_end,quantity,amount\nINV-001,RECEIVING,2026-10-01,2026-11-01,250,350.00\nINV-002,PICK,2026-10-01,2026-11-01,80,96.00",
  "rateCardCsv": "service_code,effective_from,effective_to,unit_rate,tier_after_units,overage_unit_rate\nRECEIVING,2026-01-01,2027-01-01,1.40,180,1.05\nPICK,2026-01-01,2027-01-01,1.10,,"
}
```

The receiving rule prices the first 180 units at $1.40 and the next 70 at $1.05: $325.50 versus $350.00 billed, a $24.50 candidate. The pick line prices 80 units at $1.10: $88.00 versus $96.00 billed, an $8.00 candidate. The **$32.50 total is illustrative sample arithmetic, not customer savings or a recovered credit.**

### Prepare your exports

The invoice CSV needs these exact header names:

| Column | Meaning |
| --- | --- |
| `line_id` | Stable, unique invoice line identifier. |
| `service_code` | Your normalization for the billed service, such as `PICK` or `PALLET_DAY`. It must match the rate card exactly. |
| `period_start`, `period_end` | ISO dates. The start is included; the end is excluded. |
| `quantity` | Nonnegative billed unit count, at most four decimal places. |
| `amount` | Nonnegative USD billed amount, at most two decimal places. |

The rate card needs `service_code,effective_from,effective_to,unit_rate`. The optional columns `tier_after_units,overage_unit_rate` describe one volume tier: units up to the threshold use `unit_rate`; later units use `overage_unit_rate`. One rate rule must cover the whole invoice period. The dates identify the rule's validity period, with `effective_to` excluded.

If you have an independent order or warehouse activity export, supply `activityCsv` with `activity_id,service_code,occurred_on,quantity`. Each `activity_id` must uniquely identify one billable event; repeated IDs are marked for review. The Actor sums the listed units inside each invoice period and prices **that** quantity. When the invoice has overlapping periods for the same service, add a `line_id` column to activity and map each event to its invoice line. Without that mapping, those lines are marked `review` because activity could be counted twice. Activity rows with other service codes, dates or linked line IDs are ignored. A service with no matching activity is marked `review`, not assumed to have zero billable units. Extra CSV columns are ignored and never copied into output.

You can omit `activityCsv` for a **rate-only** check: the Actor applies your rate card to each invoice line's own stated quantity, including overlapping periods. That cannot detect inflated quantities. For an independent quantity check, make sure the activity export covers the entire invoice period and uses the same service units as the contract. Neither source is independently verified by this Actor.

Only structured CSV is supported. Convert a PDF or spreadsheet to these columns before running. Use a separate service code for fees with a different contract basis. Do not put recipient names, street addresses, email addresses or other unnecessary customer data in the input.

### Output and interpretation

Each invoice line yields one dataset record with an `observationId` derived from its CSV row number and the original `lineId` retained for reference. The row ID remains unique even if an invoice repeats a line ID. `potential_overcharge` means the billed amount exceeds the recomputed amount by more than your `toleranceCents`. `under_contract_amount` means it is lower. `quantity_discrepancy` means the independent activity quantity differs from the billed quantity, even though the dollar amount is within tolerance. `within_tolerance` means the dollar amount and any independent quantity are within tolerance. `review` means the Actor cannot compute a defensible expected amount. When activity is supplied, `quantityDifference` is billed quantity minus activity quantity.

| Review code | Reason |
| --- | --- |
| `NO_CONTRACT_RATE` | No applicable service rate. |
| `RATE_PERIOD_SPLIT` | A rate overlaps but does not cover the whole billing period. |
| `AMBIGUOUS_RATE` | More than one complete rule covers the line. |
| `OVERLAPPING_SERVICE_PERIOD` | Activity was supplied without line IDs, and invoice lines for the same service have overlapping periods; activity could be counted twice. |
| `DUPLICATE_LINE_ID` | The supplied invoice repeats a line identifier. |
| `NO_ACTIVITY_EVIDENCE` | An activity export was supplied but has no records for this service and period. |
| `DUPLICATE_ACTIVITY_ID` | Matching activity events repeat an identifier; quantity could be double counted. |
| `ZERO_BILLED_QUANTITY` | A zero unit line cannot use a normal unit rate. |

The `OUTPUT` record includes coverage counts, billed amount for delivered lines, and the sum of supported positive differences for delivered lines. It marks a run partial if the result or charge limit stops delivery. The sum is **potential overcharge**, not a claim, validated savings, a refund, or profit. The Actor cannot determine whether a fee is authorized by other clauses, minimums, credits, taxes, dimensional rules or informal adjustments. Compare any proposed dispute with the signed agreement, activity source and full invoice.

### Price and limits

The intended PAY_PER_EVENT price is **$0.03 per delivered invoice-line check ($3 per 100 lines; $30 per 1,000)**. The default `maxResults` is **100**, so a 100-line invoice can be delivered in full when the customer sets the Apify run charge limit to **$3** for line checks. For a larger invoice, raise **both** `maxResults` and the run charge limit to cover the intended number of lines at $0.03 each. A line counts whether it matches, differs or needs review. Invalid input and an empty invoice produce no billable line checks. An incomplete run clearly reports its delivered count and stop reason in `OUTPUT`; it never presents an unexamined row as verified. A small synthetic Apify start charge may apply under the platform's current rules; allow for that charge if the run cap includes it. Confirm the Store pricing panel for the released Actor price.

| Limit | Value |
| --- | --- |
| Invoice lines | 1,000 per run |
| Rate rules | 200 |
| Activity rows | 10,000 |
| CSV text | 1 MB per field, 2 MB combined |
| Currency | USD only; positive charges only |
| Pricing | Flat unit rate or one simple volume tier per service period |
| Tolerance | 0–100 cents |

Input and output live in your Apify run storage under its retention and access settings. This Actor does not send them to another endpoint. For regulated or confidential exports, remove all fields the audit does not require before submitting them.

### Why this exists

There is a recurring, budgeted job here: [auditmy3pl](https://www.auditmy3pl.com/) advertises a Starter plan from $49/month for invoice and contract audits, and [SpendVerify](https://www.spendverify.com/) advertises $99/month plus a share of recovered amounts. Both offer a free first audit. These are advertised prices that may change; they do not establish sales for this Actor. This Actor offers a narrower, low-cost, machine-readable check for teams that can export clean service lines and rate cards. It does not replace a human-led audit or document ingestion service.

### Development

Run `uv run --frozen python -B -m unittest discover -s tests` for arithmetic, malformed-input and ambiguity fixtures. `tools/validate_cloud.py` checks retained cloud exports after a private qualification run. Local tests establish the deterministic audit logic; cloud execution cost, native charges and Store demand remain separate evidence gates.

# Actor input Schema

## `invoiceCsv` (type: `string`):

Up to 1,000 lines. Required columns: line_id,service_code,period_start,period_end,quantity,amount. Dates use YYYY-MM-DD; period_end is exclusive. USD nonnegative charges only. Remove customer names and addresses before pasting.

## `rateCardCsv` (type: `string`):

Up to 200 rules. Required columns: service_code,effective_from,effective_to,unit_rate. Optional tier_after_units and overage_unit_rate model one volume tier. Effective_to is exclusive.

## `activityCsv` (type: `string`):

If supplied, required columns are activity_id,service_code,occurred_on,quantity. Optional line_id maps each activity event to an invoice line when service periods overlap. Activity IDs detect duplicate source events. Do not include customer or recipient data. An absent activity CSV limits the audit to contract rates applied to billed quantities.

## `toleranceCents` (type: `integer`):

Dollar differences no larger than this tolerance are treated as within tolerance.

## `maxResults` (type: `integer`):

Default 100 lines ($3 in line charges at $0.03 each). Stop output after this many lines; the summary marks incomplete delivery. For larger invoices, raise this limit and the Apify run charge limit. Maximum 1,000.

## Actor input object example

```json
{
  "invoiceCsv": "line_id,service_code,period_start,period_end,quantity,amount\nINV-001,RECEIVING,2026-10-01,2026-11-01,250,350.00\nINV-002,PICK,2026-10-01,2026-11-01,80,96.00",
  "rateCardCsv": "service_code,effective_from,effective_to,unit_rate,tier_after_units,overage_unit_rate\nRECEIVING,2026-01-01,2027-01-01,1.40,180,1.05\nPICK,2026-01-01,2027-01-01,1.10,,",
  "toleranceCents": 1,
  "maxResults": 100
}
```

# Actor output Schema

## `checks` (type: `string`):

No description

## `summary` (type: `string`):

No description

# 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 = {
    "invoiceCsv": `line_id,service_code,period_start,period_end,quantity,amount
INV-001,RECEIVING,2026-10-01,2026-11-01,250,350.00
INV-002,PICK,2026-10-01,2026-11-01,80,96.00`,
    "rateCardCsv": `service_code,effective_from,effective_to,unit_rate,tier_after_units,overage_unit_rate
RECEIVING,2026-01-01,2027-01-01,1.40,180,1.05
PICK,2026-01-01,2027-01-01,1.10,,`
};

// Run the Actor and wait for it to finish
const run = await client.actor("natstandridge/3pl-fulfillment-invoice-audit").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 = {
    "invoiceCsv": """line_id,service_code,period_start,period_end,quantity,amount
INV-001,RECEIVING,2026-10-01,2026-11-01,250,350.00
INV-002,PICK,2026-10-01,2026-11-01,80,96.00""",
    "rateCardCsv": """service_code,effective_from,effective_to,unit_rate,tier_after_units,overage_unit_rate
RECEIVING,2026-01-01,2027-01-01,1.40,180,1.05
PICK,2026-01-01,2027-01-01,1.10,,""",
}

# Run the Actor and wait for it to finish
run = client.actor("natstandridge/3pl-fulfillment-invoice-audit").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 '{
  "invoiceCsv": "line_id,service_code,period_start,period_end,quantity,amount\\nINV-001,RECEIVING,2026-10-01,2026-11-01,250,350.00\\nINV-002,PICK,2026-10-01,2026-11-01,80,96.00",
  "rateCardCsv": "service_code,effective_from,effective_to,unit_rate,tier_after_units,overage_unit_rate\\nRECEIVING,2026-01-01,2027-01-01,1.40,180,1.05\\nPICK,2026-01-01,2027-01-01,1.10,,"
}' |
apify call natstandridge/3pl-fulfillment-invoice-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,natstandridge/3pl-fulfillment-invoice-audit"
        }
    }
}
```

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/iiq765EfwXyV8bdHL/builds/flfFNM1iq6I2VQ411/openapi.json
