# Catalog Margin Guard (`settled_marzipan/catalog-margin-guard`) Actor

Flag catalog prices that lose money or miss your target margin after item cost, shipping and seller fees, and see the lowest price that meets the target. Reads only the numbers you supply.

- **URL**: https://apify.com/settled_marzipan/catalog-margin-guard.md
- **Developed by:** [Andrew Shim](https://apify.com/settled_marzipan) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$100.00 / 1,000 delivered 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

## Catalog Margin Guard

Check every price in a catalog against what the item really costs you. For each SKU it says whether you lose money, fall short of your target margin, or meet it, and it gives the lowest price that would meet the target. It reads only the numbers you supply and changes nothing anywhere.

### Who it is for

Sellers and catalog managers who want a quick check before publishing a price update, or after supplier costs, shipping or marketplace fees change.

### What you give it

| Field | Meaning |
|---|---|
| `feeBasisPoints` | The seller fee as a share of the sale price. 1,200 means 12 percent. |
| `targetMarginBasisPoints` | The margin you want to keep. 2,000 means 20 percent. |
| `items` | 1 to 1,000 rows. Each needs `sku`, `salePriceCents` and `unitCostCents`. Optional: `shippingCents`, `fixedFeeCents`, `otherCostCents`, and a per row `feeBasisPoints` or `targetMarginBasisPoints`. |
| `currency` | `USD`. Amounts are whole cents. |
| `demo` | Tick this, or start the tool with no catalog rows, to run a free built in example with made up rows. Everything else you entered is ignored. |

```json
{
  "feeBasisPoints": 1200,
  "targetMarginBasisPoints": 2000,
  "items": [{ "sku": "CASE-01", "salePriceCents": 2200, "unitCostCents": 1450, "shippingCents": 400, "fixedFeeCents": 30 }]
}
```

### What you get back

One JSON report, saved as the run's `OUTPUT` record: a summary with counts, and one result per SKU.

```json
{
  "summary": { "currency": "USD", "items": 1, "counts": { "LOSS": 0, "BELOW_TARGET": 1, "MEETS_TARGET": 0, "INVALID": 0 } },
  "rows": [{ "rowNumber": 1, "sku": "CASE-01", "status": "BELOW_TARGET", "salePriceCents": 2200,
    "estimatedVariableFeeUsd": 2.64, "estimatedContributionUsd": 0.56, "estimatedMarginBasisPoints": 255,
    "targetMarginBasisPoints": 2000, "minimumPriceCents": 2765 }]
}
```

The same results are also written to the run's dataset, one row per SKU plus a summary row, so you can view them as a table or export them to CSV or Excel. Dataset rows are not charged.

Statuses: `LOSS` (you lose money on each sale), `BELOW_TARGET`, `MEETS_TARGET`, and `INVALID` with the reason (for example a duplicated SKU or a missing price).

### How it calculates

- Contribution = sale price minus the percentage fee, minus unit cost, shipping, fixed fee and other cost.
- `minimumPriceCents` is the lowest whole cent price that meets your target under the same costs and fee.
- When the fee plus the target reach 100 percent or more, no price can meet the target, and `minimumPriceCents` is `null`.
- All arithmetic is exact in whole cents and basis points. Nothing is rounded before the comparison.

### Pricing

Pay per event, one charge per delivered report. You are not charged for a demo run, for a run with no catalog rows, for a run the tool refuses, or for a run where every row was invalid.

### Limits to know

- It models one percentage fee on the sale price plus fixed amounts per item. Taxes, fee tiers, refunds and payment processor rounding are included only if you put them in the cost fields.
- It does not read live prices or marketplace fee tables, and it never changes a listing.
- US dollars only.

### FAQ

**Is 2,000 really 20 percent?** Yes. Basis points are hundredths of a percent, so 100 is 1 percent.

**Why is the minimum price empty?** Your fee and target together leave nothing to cover the cost, so no price works. Lower the target or the fee.

**Can rows have different fees?** Yes. Add `feeBasisPoints` to a row and it replaces the default for that row.

# Actor input Schema

## `demo` (type: `boolean`):

Runs a built in example with made up rows and ignores everything else entered here. Demo runs are free, and so is a run with no catalog rows. Leave it off to check your own catalog.

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

This pilot uses USD cents.

## `feeBasisPoints` (type: `integer`):

1,200 means 12 percent of sale price.

## `targetMarginBasisPoints` (type: `integer`):

2,000 means 20 percent of sale price.

## `items` (type: `array`):

1 to 1,000 items. Each row takes sku, salePriceCents and unitCostCents plus optional shippingCents, fixedFeeCents, otherCostCents and basis point overrides. Example row: {"sku": "CASE-01", "salePriceCents": 2200, "unitCostCents": 1450, "shippingCents": 400, "fixedFeeCents": 30}. Leave this empty to get a free example.

## Actor input object example

```json
{
  "demo": false,
  "currency": "USD",
  "feeBasisPoints": 1200,
  "targetMarginBasisPoints": 2000
}
```

# Actor output Schema

## `report` (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 = {
    "feeBasisPoints": 1200,
    "targetMarginBasisPoints": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("settled_marzipan/catalog-margin-guard").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 = {
    "feeBasisPoints": 1200,
    "targetMarginBasisPoints": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("settled_marzipan/catalog-margin-guard").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 '{
  "feeBasisPoints": 1200,
  "targetMarginBasisPoints": 2000
}' |
apify call settled_marzipan/catalog-margin-guard --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,settled_marzipan/catalog-margin-guard"
        }
    }
}
```

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/Tgc2Ly1Eez6FFc11v/builds/CFYa9fRD8zXBfzAd7/openapi.json
