# Dispatch Promise Breach Monitor (`afkdigital/dispatch-promise-breach-monitor`) Actor

Audit order dispatch promises against carrier acceptance events in CSV/XLSX files. Detect missed dispatch deadlines with row evidence and warehouse/channel summaries.

- **URL**: https://apify.com/afkdigital/dispatch-promise-breach-monitor.md
- **Developed by:** [AFK Digital](https://apify.com/afkdigital) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$1.00 / 1,000 unique order revieweds

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

## Dispatch Promise Breach Monitor

Find orders that missed their promised **dispatch** time using your own order, dispatch promise and carrier event files. No shop login, carrier credentials, scraping or third-party account integration is needed.

The monitor compares carrier **acceptance**, not label creation and not final delivery. It does not predict delivery time, verify physical custody independently, or contact customers or carriers.

### Quick start

Run with empty input for a free, deterministic five-order synthetic demo. No private data is needed. It finishes in under five minutes.

For customer files, upload three UTF-8 comma-separated CSV files or single-sheet XLSX files into private Apify key-value stores. Supply:

```json
{
  "ordersFile": "YOUR_STORE_ID_0001",
  "dispatchPromisesFile": "YOUR_STORE_ID_0002",
  "carrierEventsFile": "YOUR_STORE_ID_0003",
  "columnMapping": {
    "orders": {"order_id":"order_id"},
    "promises": {"promised_dispatch_at":"promised_dispatch_at"},
    "events": {"event_type":"event_type"},
    "eventTypes": {
      "CARRIER_ACCEPTED":"acceptance",
      "PICKED_UP":"acceptance",
      "LABEL_CREATED":"label",
      "DELIVERED":"other"
    }
  },
  "timezone":"Europe/Istanbul",
  "asOfDateTime":"2026-11-11T18:00:00+03:00",
  "splitShipmentPolicy":"all_packages",
  "maxOrders":10000
}
```

Select private stores using the Console picker or replace placeholders with real 17-character store IDs. Put files under record keys ORDERS.csv, PROMISES.csv and EVENTS.csv respectively. These keys can contain either UTF-8 CSV or XLSX binary content (the format is detected from bytes). All three records can be in the same store. The schema grants read access only to selected stores under limited Actor permissions. API clients can also pass inline CSV strings; the Console form uses store selectors. Arbitrary URLs and local filesystem paths are not supported.

### Source columns

Mappings are canonical-name → exact source column. Unmapped names use the canonical header.

| File | Columns |
|---|---|
| orders | order_id (required), status (required), shipment_ids, warehouse, channel, placed_at |
| promises | order_id, promised_dispatch_at |
| events | order_id, shipment_id, event_type, event_at |

Every nonempty row needs order_id. IDs are case-sensitive strings. shipment_ids is a pipe-separated complete expected package manifest, e.g. P1|P2. Missing warehouse/channel is retained as an empty grouping. Additional customer columns are ignored.

Provide the full carrier-event export for the evaluation horizon. The tool treats the uploaded export as authoritative; absence of acceptance is not independently verified. Unknown event codes produce needs_review. An incomplete export can otherwise look like a missed dispatch.

### Explicit carrier event table

Every event code must be explicitly assigned in columnMapping.eventTypes. There are no fuzzy or carrier-dependent defaults.

| Mapping value | Interpretation |
|---|---|
| acceptance | Carrier pickup/physical handover acceptance supported by the source code definition |
| label | Label created or electronic pre-advice; never dispatch acceptance |
| other | Delivery, transit, scans or other events that do not prove initial dispatch acceptance |

Do not assign delivery, label or pre-transit to acceptance. Recognizable names containing label/deliver/pre-transit are rejected when mapped as acceptance. For opaque carrier codes, you are responsible for correct semantics. EVENT_MAPPING records the exact applied table.

### Time, status and split rules

All timestamps must contain both date and time in ISO 8601. Offset timestamps are converted to UTC; naive timestamps use the supplied IANA timezone. Ambiguous autumn-fold times and nonexistent spring-gap times require explicit offsets and are never guessed. Output timestamps use UTC. Durations are elapsed **seconds**, including DST transitions. Acceptance at exactly the promised time is on_time. At the exact deadline, an order without acceptance is still pending; it becomes overdue strictly after the deadline. Events after asOfDateTime are ignored.

first_package measures the earliest accepted package. all_packages requires every package in the orders manifest and measures the last package's first acceptance. first_carrier_acceptance_at always shows the earliest acceptance; dispatch_completed_at shows the timestamp used for the chosen policy. Unexpected accepted packages and missing manifests under all_packages go to needs_review.

Default active statuses: active, open, fulfilled, shipped. cancelled/canceled, on_hold/hold and preorder/pre_order are excluded independently. You can map exact lower-case source statuses through columnMapping.orderStatuses to active, cancelled, on_hold or preorder. Excluded orders are not billed. Preorders remain excluded until your source marks them active; no release date is invented.

Missing status, malformed acceptance timestamps, unknown events, conflicting order rows or conflicting promises produce needs_review. Exact duplicate canonical order rows collapse to one unique order with all source row references. Different textual promises are treated conservatively as conflicting even if they could represent the same instant. Rows in promises/events with no corresponding order are counted in SUMMARY, not billed.

A promise is never inferred by default. If explicitly supplied, promiseRule: {minutesAfterOrder: 240} fills a missing promise from orders.placed_at plus elapsed minutes. It does not implement warehouse business days, cutoffs or holidays. An invalid/conflicting source promise is not overwritten by this rule.

### Results

One JSON Dataset record per unique order. Download JSON or flattened Dataset CSV through Apify. DISPATCH.csv preserves arrays/objects as JSON cells and neutralizes spreadsheet formula-leading values. SUMMARY contains status counts and warehouse/channel summaries. Evidence contains only source file row references (header row is 1), never the complete source row.

Main fields: order_id, shipment_ids, promised_dispatch_at, first_carrier_acceptance_at, dispatch_status, delay_duration, warehouse, channel, evidence_rows. Additional fields: dispatch_completed_at, promise_basis, review_reasons, billable.

Statuses: on_time, late_dispatched, overdue_unshipped, overdue_partial, pending, needs_review, excluded_cancelled, excluded_on_hold, excluded_preorder. Overdue duration is measured until asOfDateTime; dispatched delay is measured until policy completion. A positive dispatch delay does not establish late delivery.

### Limits and privacy

Each file: maximum 10 MiB, 200,000 data rows and 100 columns. XLSX: exactly one worksheet, at most 50 MiB expanded ZIP content and 1,000 archive entries; formulas are rejected. Run: at most 50,000 unique orders, default 10,000. Files that exceed limits fail safely rather than returning a silently truncated audit. The runtime target is 512 MiB with a 240-second timeout.

No personal order values, raw rows, file URLs or tokens are written to application logs. Outputs retain only business order/shipment identifiers and warehouse/channel fields needed for the audit. Avoid putting emails or customer names in these columns. Uploaded files, run input, Dataset and key-value store outputs remain in your Apify account under your account's access and retention rules; the Actor does not delete them or promise a retention period. Keep stores private, restrict sharing, and delete files/runs/outputs when no longer required. Inline CSV is stored in run INPUT, so private file references are preferable.

### Pricing

Price: **USD 1.00 per 1,000 successfully reviewed unique orders** (USD 0.001 per order). Only determinate active orders with a valid promise and sufficient data are eligible, including pending and overdue findings. needs_review and excluded orders are free. The empty-input demo is free. Packages, source rows, carrier events, summaries, output downloads and label events do not add custom charges. No startup or synthetic Dataset charge is intended. Re-running files is a new audit and can charge again.

Only one custom event: order-reviewed. Pricing uses only this event; no synthetic startup or Dataset fees apply, and platform usage is included. An insufficient charge budget fails before Dataset output.

### Validation and development

Python 3.12, Apify SDK 3.4.1, openpyxl 3.1.5. Dockerfile included.
Run: python -m unittest discover -s tests -v.
Test coverage includes label without acceptance, first/all split packages, cancellation/hold/preorder, missing promise, DST folds/gaps, exact deadline, future events, conflicting duplicates, custom mapping, limits, evidence privacy, CSV formula safety and XLSX.

Built by AFK Digital. Results are operational dispatch findings based on supplied records, not carrier-certified evidence.

# Actor input Schema

## `ordersFile` (type: `string`):

Select the private store containing ORDERS.csv, PROMISES.csv or EVENTS.csv respectively. Files can contain CSV or XLSX bytes. Omit all three for free synthetic demo.

## `dispatchPromisesFile` (type: `string`):

Select the private store containing ORDERS.csv, PROMISES.csv or EVENTS.csv respectively. Files can contain CSV or XLSX bytes. Omit all three for free synthetic demo.

## `carrierEventsFile` (type: `string`):

Select the private store containing ORDERS.csv, PROMISES.csv or EVENTS.csv respectively. Files can contain CSV or XLSX bytes. Omit all three for free synthetic demo.

## `columnMapping` (type: `object`):

orders/promises/events map canonical field to source header. eventTypes maps exact carrier code to acceptance, label or other. Required for customer files; never classify label creation or delivery as acceptance.

## `timezone` (type: `string`):

Applies to timestamps without an offset. Ambiguous/nonexistent local times require explicit offsets.

## `asOfDateTime` (type: `string`):

ISO 8601 timestamp. Customer files default to run time; demo uses its fixed example time.

## `splitShipmentPolicy` (type: `string`):

all_packages requires the complete expected shipment_ids manifest in orders.

## `maxOrders` (type: `integer`):

Fail instead of silently truncating when exceeded.

## `promiseRule` (type: `object`):

Only if explicitly supplied: {minutesAfterOrder: 240}. Adds elapsed minutes to placed_at, does not imply business hours or carrier delivery promises.

## Actor input object example

```json
{
  "timezone": "UTC",
  "splitShipmentPolicy": "first_package",
  "maxOrders": 10000
}
```

# Actor output Schema

## `json` (type: `string`):

No description

## `csv` (type: `string`):

No description

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

No description

## `eventMapping` (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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("afkdigital/dispatch-promise-breach-monitor").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("afkdigital/dispatch-promise-breach-monitor").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 '{}' |
apify call afkdigital/dispatch-promise-breach-monitor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,afkdigital/dispatch-promise-breach-monitor"
        }
    }
}
```

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/cPwmlKkb6RjbRvPiz/builds/oybgbei3CN6IVqIV1/openapi.json
