# Batch Expiry & Delivery Shelf Life Preflight (`winning_moonstone/batch-expiry-delivery-shelf-life-preflight`) Actor

Check inventory lots against a delivery date and customer minimum remaining shelf life. Separate eligible, blocked, expired and unknown lots; quantify supported shortfalls without approving shipments.

- **URL**: https://apify.com/winning_moonstone/batch-expiry-delivery-shelf-life-preflight.md
- **Developed by:** [月 明](https://apify.com/winning_moonstone) (community)
- **Categories:** Business, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$50.00 / 1,000 completed batch shelf-life preflight reports

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

## Batch Expiry & Delivery Shelf Life Preflight

Check whether your supplied inventory lots meet a customer's minimum remaining shelf life on one planned delivery date. The report separates eligible, blocked, expired, short-dated and unknown-expiry stock, then calculates whether the known eligible quantity covers each requirement.

This is useful when a warehouse export shows enough total stock but some batches cannot meet the customer's date requirement. It is a date-and-quantity review, not a product safety assessment or shipment approval.

### Try the example

The example needs 12 units on October 22, 2026, with at least 30 days remaining. Eight units expire November 1 and fail the rule; ten units expire December 1 and meet it. The completed report shows ten known eligible units and a confirmed two-unit shortfall because coverage is explicitly complete and no relevant expiry date is unknown.

The run writes one dataset record and saves the full JSON in `REPORT`. `OUTPUT` contains the run summary. Export through the dataset as JSON, CSV or Excel.

### Input contract

Pass one `caseJson` string with `caseId`, `asOfDate`, `deliveryDate`, `coverageConfirmed`, `requirements` and `lots`. The supplied snapshot date must not be after delivery. Nothing is inferred from the run's clock.

Each requirement has an exact `sku` and `unit`, a positive whole-unit `quantity`, and `minimumRemainingDays` (0–36,500). Each lot has `lotId`, `sku`, `unit`, whole-unit `quantity`, `expiryDate` (YYYY-MM-DD or null), and a boolean `blocked`. Use unreserved quantities and independently verify the data before acting. One requirement per exact SKU/unit; one lot row per exact SKU/unit/lotId. No unit or SKU conversion occurs.

The explicit date rule is **expiryDate >= deliveryDate + minimumRemainingDays**. Equality passes this supplied rule. An expiry before delivery fails. This date convention does not override a product label, contract, storage condition or local rule. A blocked lot is excluded even when its expiry is unknown.

Set `coverageConfirmed` true only if all relevant stock and blocking information are present. With complete coverage, an empty lot list means zero stock. Without complete coverage, or when relevant unblocked positive stock has unknown expiry, `confirmedShortfall` is null. `uncoveredByKnownEligibleQuantity` remains visible and is not called a confirmed shortage. Unknown unblocked stock can make the review incomplete even when known eligible stock already covers demand.

Unused SKU/unit lots remain visible in `unusedLots`; they do not change another SKU's result. The Actor does not allocate stock across separate deliveries or remember reservations across runs.

### Pricing

**$0.05 per completed report**, including reports with findings or incomplete coverage. Malformed inputs and runs with insufficient report-event budget produce no completed report event. A repeated run is a new review. Platform usage can apply separately; check the live price and set an Apify maximum-charge limit.

### Limits, data and safety

At most 500 requirements, 1,000 lots and 1 MB of UTF-8 input. Quantities are integers up to 1,000,000,000,000. Identifiers are exact, case-sensitive strings of 1–100 characters. Duplicate keys, conflicting records, invalid dates, noninteger quantities and unexpected fields fail before billing. Missing expiry is allowed only as explicit null.

No external network calls, AI, OCR, paid API, inventory writes or automated approvals occur. Do not include customer names, addresses, banking details or credentials. Input and output stay in your Apify storage under its access and retention settings. Source-code visibility is restricted; that does not change your responsibility to protect operational data.

### Reference basis and limitations

Microsoft documents customer sellable-day rules and batch expiration controls. Oracle documents minimum remaining shelf life relative to a shipment or arrival date. This Actor implements only the explicit delivery-date rule supplied in its input; it does not emulate an ERP's full policy hierarchy or certify compliance.

- https://learn.microsoft.com/en-us/dynamics365/supply-chain/master-planning/planning-optimization/shelf-life
- https://docs.oracle.com/en/cloud/saas/readiness/scm/26d/order26d/26D-order-mgmt-wn-f50210.htm

Always review the source labels, applicable contract, physical condition, temperature history and other product requirements before deciding whether to ship or use a lot.

# Actor input Schema

## `caseJson` (type: `string`):

Whole-unit quantities. Dates are YYYY-MM-DD. expiryDate may be null when unknown. minimumRemainingDays is measured from deliveryDate. Complete empty lot scope means no available stock.

## Actor input object example

```json
{
  "caseJson": "{\n  \"caseId\": \"shelf-life-demo-001\",\n  \"asOfDate\": \"2026-10-19\",\n  \"deliveryDate\": \"2026-10-22\",\n  \"coverageConfirmed\": true,\n  \"requirements\": [\n    {\n      \"sku\": \"PART-A\",\n      \"unit\": \"EA\",\n      \"quantity\": 12,\n      \"minimumRemainingDays\": 30\n    }\n  ],\n  \"lots\": [\n    {\n      \"lotId\": \"LOT-NEAR\",\n      \"sku\": \"PART-A\",\n      \"unit\": \"EA\",\n      \"quantity\": 8,\n      \"expiryDate\": \"2026-11-01\",\n      \"blocked\": false\n    },\n    {\n      \"lotId\": \"LOT-LONG\",\n      \"sku\": \"PART-A\",\n      \"unit\": \"EA\",\n      \"quantity\": 10,\n      \"expiryDate\": \"2026-12-01\",\n      \"blocked\": false\n    }\n  ]\n}"
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("winning_moonstone/batch-expiry-delivery-shelf-life-preflight").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("winning_moonstone/batch-expiry-delivery-shelf-life-preflight").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 winning_moonstone/batch-expiry-delivery-shelf-life-preflight --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,winning_moonstone/batch-expiry-delivery-shelf-life-preflight"
        }
    }
}
```

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/yxFwjmEFe1gibAYgo/builds/U7JR8w0s44mWdkKmF/openapi.json
