# Amazon Fulfillment Fee Change Margin Audit (`practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-audit`) Actor

Compare two fee-schedule exports against your SKU costs and dimensions to flag fee and margin changes. Offline, no scraping.

- **URL**: https://apify.com/practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-audit.md
- **Developed by:** [Practical AI Lab](https://apify.com/practical_ai_lab_jp) (community)
- **Categories:** E-commerce, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 sku auditeds

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

## Amazon Fulfillment Fee Change Margin Audit

Reconcile two authorized fulfillment fee-schedule exports against your own SKU costs and dimensions. The Actor flags SKUs whose fulfillment fee or projected contribution margin changed, and it refuses to run when a fee input is missing.

It works only on data you paste in. It does **not** scrape Amazon, call any Amazon API, or make any network request.

### What it does

- Matches SKUs across an earlier fee export, a later fee export and your product list.
- Computes contribution margin per unit before and after: `price - referral fee - fulfillment fee - other cost - unit cost`.
- Flags fee increases/decreases, margin drops, margins below your floor, negative margins, size-tier changes, and mismatches between your dimensions/weight and the fee export (orientation-insensitive).
- Estimates monthly profit impact when you provide `monthlyUnits`, and the price that would restore your minimum margin at the new fee.
- Writes a run `SUMMARY` record (key-value store) with counts, coverage, unmatched fee rows and caveats.

### Fail-closed behavior

- The run is refused (no results, no charges) if `oldFeeSchedule`, `newFeeSchedule` or `products` is empty or malformed.
- A product with no fee in either export gets status `missing_fee_input` and no margin numbers. Conflicting duplicate fee rows, non-numeric fees, invalid product values and duplicate products are also reported with their own status and are never billed.

### Sample input

```json
{
  "oldFeeSchedule": [
    {"sku": "MUG-BLUE-12", "fulfillmentFee": 3.22, "sizeTier": "Standard", "lengthIn": 5, "widthIn": 4, "heightIn": 4, "weightLb": 0.9},
    {"sku": "YOGA-MAT-6", "fulfillmentFee": 5.40, "sizeTier": "Standard", "lengthIn": 24, "widthIn": 6, "heightIn": 6, "weightLb": 2.4}
  ],
  "newFeeSchedule": [
    {"sku": "MUG-BLUE-12", "fulfillmentFee": 3.40, "sizeTier": "Standard", "lengthIn": 5, "widthIn": 4, "heightIn": 4, "weightLb": 0.9},
    {"sku": "YOGA-MAT-6", "fulfillmentFee": 6.25, "sizeTier": "Large", "lengthIn": 26, "widthIn": 7, "heightIn": 7, "weightLb": 2.4}
  ],
  "products": [
    {"sku": "MUG-BLUE-12", "price": 18.99, "unitCost": 4.10, "monthlyUnits": 300, "lengthIn": 5, "widthIn": 4, "heightIn": 4, "weightLb": 0.9},
    {"sku": "YOGA-MAT-6", "price": 24.99, "unitCost": 8.50, "otherCostPerUnit": 0.60, "monthlyUnits": 120, "lengthIn": 24, "widthIn": 6, "heightIn": 6, "weightLb": 2.4}
  ],
  "defaultReferralFeeRatePct": 15,
  "minContributionMarginPct": 15
}
```

### Input fields

| Field | Notes |
| --- | --- |
| `oldFeeSchedule`, `newFeeSchedule` | Required. Rows with `sku`, `fulfillmentFee`; optional `sizeTier`, `lengthIn`, `widthIn`, `heightIn`, `weightLb`. |
| `products` | Required. `sku`, `price`, `unitCost`; optional `referralFeeRatePct`, `otherCostPerUnit`, `monthlyUnits`, dimensions, weight. |
| `defaultReferralFeeRatePct` | Your assumption when a product has no rate (default 15). |
| `feeChangeThresholdPct`, `marginDropThresholdPoints`, `minContributionMarginPct`, `dimensionTolerancePct` | Flag thresholds. |
| `onlyFlagged` | Return only flagged SKUs (unaudited rows are always returned). |
| `maxSkus` | Cap on products per run (default 5000). |

Numbers may be given as numbers or strings such as `"$1,234.50"`. SKU matching ignores case and surrounding spaces.

### Output

One dataset row per product: `sku`, `status`, `severity` (`none`, `low`, `medium`, `high`, `critical`), `flags`, old/new fee, fee change and percent, old/new margin and margin percent, `marginChangePoints`, `monthlyProfitImpact`, `priceForMinMargin`, and `reason` for rows that could not be audited.

### Pricing event

The code emits one `sku-audited` event per successfully audited SKU delivered. Rows with any error status are never charged, and the run stops if the user's maximum charge limit is reached. No payable plan is configured in this repository.

### Limitations and caveats

- Results are only as accurate as the exports and costs you supply; nothing is verified against Amazon.
- Referral fees are an assumed percentage, not looked up. Returns, storage, inbound, advertising and taxes are not modeled.
- Fee matching is per SKU; it does not recompute fee tiers from dimensions, so it cannot tell you what Amazon *should* charge.
- Monthly impact assumes constant volume. With fewer than 30 audited SKUs, averages and totals are anecdotal, not statistically meaningful.
- The Actor does not judge whether a flagged change is an error or a legitimate rate change; it only surfaces it for review.
- Only use fee exports you are authorized to access.

# Actor input Schema

## `oldFeeSchedule` (type: `array`):

Rows from the earlier authorized fee export. Each row needs sku and fulfillmentFee; optional sizeTier, lengthIn, widthIn, heightIn, weightLb.

## `newFeeSchedule` (type: `array`):

Rows from the later authorized fee export, same columns as the earlier export.

## `products` (type: `array`):

Imported products. Required: sku, price, unitCost. Optional: referralFeeRatePct, otherCostPerUnit, monthlyUnits, lengthIn, widthIn, heightIn, weightLb.

## `currency` (type: `string`):

Label shown in the output. No conversion is performed.

## `defaultReferralFeeRatePct` (type: `number`):

Your own assumption, used when a product has no referralFeeRatePct.

## `feeChangeThresholdPct` (type: `number`):

Flag a fee increase or decrease at or above this percentage.

## `marginDropThresholdPoints` (type: `number`):

Flag a drop in contribution margin of at least this many percentage points.

## `minContributionMarginPct` (type: `number`):

Flag SKUs whose new margin falls below this value.

## `dimensionTolerancePct` (type: `number`):

Allowed relative difference between your dimensions/weight and the fee export before flagging.

## `onlyFlagged` (type: `boolean`):

Skip audited SKUs with no flags. Rows that could not be audited are always returned.

## `maxSkus` (type: `integer`):

Upper bound on products processed in one run.

## Actor input object example

```json
{
  "oldFeeSchedule": [
    {
      "sku": "MUG-BLUE-12",
      "fulfillmentFee": 3.22,
      "sizeTier": "Standard",
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "fulfillmentFee": 5.4,
      "sizeTier": "Standard",
      "lengthIn": 24,
      "widthIn": 6,
      "heightIn": 6,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "fulfillmentFee": 6.1,
      "sizeTier": "Large",
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    }
  ],
  "newFeeSchedule": [
    {
      "sku": "MUG-BLUE-12",
      "fulfillmentFee": 3.4,
      "sizeTier": "Standard",
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "fulfillmentFee": 6.25,
      "sizeTier": "Large",
      "lengthIn": 26,
      "widthIn": 7,
      "heightIn": 7,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "fulfillmentFee": 6.1,
      "sizeTier": "Large",
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    }
  ],
  "products": [
    {
      "sku": "MUG-BLUE-12",
      "price": 18.99,
      "unitCost": 4.1,
      "monthlyUnits": 300,
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "price": 24.99,
      "unitCost": 8.5,
      "otherCostPerUnit": 0.6,
      "monthlyUnits": 120,
      "lengthIn": 24,
      "widthIn": 6,
      "heightIn": 6,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "price": 29.99,
      "unitCost": 11,
      "monthlyUnits": 80,
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    },
    {
      "sku": "NO-FEE-SKU",
      "price": 15,
      "unitCost": 5
    }
  ],
  "currency": "USD",
  "defaultReferralFeeRatePct": 15,
  "feeChangeThresholdPct": 2,
  "marginDropThresholdPoints": 1,
  "minContributionMarginPct": 15,
  "dimensionTolerancePct": 5,
  "onlyFlagged": false,
  "maxSkus": 5000
}
```

# Actor output Schema

## `results` (type: `string`):

Download rows from the latest run in JSON/CSV.

# 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 = {
    "oldFeeSchedule": [
        {
            "sku": "MUG-BLUE-12",
            "fulfillmentFee": 3.22,
            "sizeTier": "Standard",
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9
        },
        {
            "sku": "YOGA-MAT-6",
            "fulfillmentFee": 5.4,
            "sizeTier": "Standard",
            "lengthIn": 24,
            "widthIn": 6,
            "heightIn": 6,
            "weightLb": 2.4
        },
        {
            "sku": "LAMP-DESK-1",
            "fulfillmentFee": 6.1,
            "sizeTier": "Large",
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1
        }
    ],
    "newFeeSchedule": [
        {
            "sku": "MUG-BLUE-12",
            "fulfillmentFee": 3.4,
            "sizeTier": "Standard",
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9
        },
        {
            "sku": "YOGA-MAT-6",
            "fulfillmentFee": 6.25,
            "sizeTier": "Large",
            "lengthIn": 26,
            "widthIn": 7,
            "heightIn": 7,
            "weightLb": 2.4
        },
        {
            "sku": "LAMP-DESK-1",
            "fulfillmentFee": 6.1,
            "sizeTier": "Large",
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1
        }
    ],
    "products": [
        {
            "sku": "MUG-BLUE-12",
            "price": 18.99,
            "unitCost": 4.1,
            "monthlyUnits": 300,
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9
        },
        {
            "sku": "YOGA-MAT-6",
            "price": 24.99,
            "unitCost": 8.5,
            "otherCostPerUnit": 0.6,
            "monthlyUnits": 120,
            "lengthIn": 24,
            "widthIn": 6,
            "heightIn": 6,
            "weightLb": 2.4
        },
        {
            "sku": "LAMP-DESK-1",
            "price": 29.99,
            "unitCost": 11,
            "monthlyUnits": 80,
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1
        },
        {
            "sku": "NO-FEE-SKU",
            "price": 15,
            "unitCost": 5
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-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 = {
    "oldFeeSchedule": [
        {
            "sku": "MUG-BLUE-12",
            "fulfillmentFee": 3.22,
            "sizeTier": "Standard",
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9,
        },
        {
            "sku": "YOGA-MAT-6",
            "fulfillmentFee": 5.4,
            "sizeTier": "Standard",
            "lengthIn": 24,
            "widthIn": 6,
            "heightIn": 6,
            "weightLb": 2.4,
        },
        {
            "sku": "LAMP-DESK-1",
            "fulfillmentFee": 6.1,
            "sizeTier": "Large",
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1,
        },
    ],
    "newFeeSchedule": [
        {
            "sku": "MUG-BLUE-12",
            "fulfillmentFee": 3.4,
            "sizeTier": "Standard",
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9,
        },
        {
            "sku": "YOGA-MAT-6",
            "fulfillmentFee": 6.25,
            "sizeTier": "Large",
            "lengthIn": 26,
            "widthIn": 7,
            "heightIn": 7,
            "weightLb": 2.4,
        },
        {
            "sku": "LAMP-DESK-1",
            "fulfillmentFee": 6.1,
            "sizeTier": "Large",
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1,
        },
    ],
    "products": [
        {
            "sku": "MUG-BLUE-12",
            "price": 18.99,
            "unitCost": 4.1,
            "monthlyUnits": 300,
            "lengthIn": 5,
            "widthIn": 4,
            "heightIn": 4,
            "weightLb": 0.9,
        },
        {
            "sku": "YOGA-MAT-6",
            "price": 24.99,
            "unitCost": 8.5,
            "otherCostPerUnit": 0.6,
            "monthlyUnits": 120,
            "lengthIn": 24,
            "widthIn": 6,
            "heightIn": 6,
            "weightLb": 2.4,
        },
        {
            "sku": "LAMP-DESK-1",
            "price": 29.99,
            "unitCost": 11,
            "monthlyUnits": 80,
            "lengthIn": 18,
            "widthIn": 10,
            "heightIn": 8,
            "weightLb": 3.1,
        },
        {
            "sku": "NO-FEE-SKU",
            "price": 15,
            "unitCost": 5,
        },
    ],
}

# Run the Actor and wait for it to finish
run = client.actor("practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-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 '{
  "oldFeeSchedule": [
    {
      "sku": "MUG-BLUE-12",
      "fulfillmentFee": 3.22,
      "sizeTier": "Standard",
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "fulfillmentFee": 5.4,
      "sizeTier": "Standard",
      "lengthIn": 24,
      "widthIn": 6,
      "heightIn": 6,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "fulfillmentFee": 6.1,
      "sizeTier": "Large",
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    }
  ],
  "newFeeSchedule": [
    {
      "sku": "MUG-BLUE-12",
      "fulfillmentFee": 3.4,
      "sizeTier": "Standard",
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "fulfillmentFee": 6.25,
      "sizeTier": "Large",
      "lengthIn": 26,
      "widthIn": 7,
      "heightIn": 7,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "fulfillmentFee": 6.1,
      "sizeTier": "Large",
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    }
  ],
  "products": [
    {
      "sku": "MUG-BLUE-12",
      "price": 18.99,
      "unitCost": 4.1,
      "monthlyUnits": 300,
      "lengthIn": 5,
      "widthIn": 4,
      "heightIn": 4,
      "weightLb": 0.9
    },
    {
      "sku": "YOGA-MAT-6",
      "price": 24.99,
      "unitCost": 8.5,
      "otherCostPerUnit": 0.6,
      "monthlyUnits": 120,
      "lengthIn": 24,
      "widthIn": 6,
      "heightIn": 6,
      "weightLb": 2.4
    },
    {
      "sku": "LAMP-DESK-1",
      "price": 29.99,
      "unitCost": 11,
      "monthlyUnits": 80,
      "lengthIn": 18,
      "widthIn": 10,
      "heightIn": 8,
      "weightLb": 3.1
    },
    {
      "sku": "NO-FEE-SKU",
      "price": 15,
      "unitCost": 5
    }
  ]
}' |
apify call practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-audit --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,practical_ai_lab_jp/pal-amazon-fulfillment-fee-change-impact-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/4W8QakqQcOP3OfUQF/builds/SQjqlf22XYvSUSee7/openapi.json
