Pack sizes, MOQ, order increments, overbuy cap and price breakpoints: what to actually order

$0.005 USDC per call · Business, finance and compliance · POST /api/v1/pack-size · Id pack-size

Finds the cheapest valid order quantity for a requested number of units across up to 50 supplier options, for an agent buying parts or consumables sold in packs. Each option has a pack size (units per pack or notation such as "6x100", "case of 12", "12/case", "case of 6 inners"), an optional minimum order quantity, an order increment and price breakpoints; the order is rounded up to a multiple of both the pack and the increment and at least the MOQ, and a higher breakpoint is considered when raising the quantity to it costs no more. A notation that does not fix the count ("6x100g": 6 pieces or 600 g; "case of 6 inners" with no units per inner) returns unknown with every reading. An overbuy cap in percent rejects options that exceed it. Prices are in whatever currency the caller uses. Not a stock or lead-time check.

What you get

"6x100" and "case of 12 inners" are where agents order 12x too much. Exact arithmetic on packs, MOQ and breakpoints, ambiguity flagged.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/pack-size. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/pack-size \
  -H 'content-type: application/json' \
  -d '{"requested":250,"overbuyCapPercent":"25","options":[{"id":"A","packNotation":"case of 12","unitPrice":"1.50","breakpoints":[{"minQty":300,"unitPrice":"1.20"}]},{"id":"B","packNotation":"6x100","moq":600,"unitPrice":"1.00"},{"id":"C","packNotation":"case of 6 inners","unitPrice":"1.10"}]}'

Input

FieldTypeRequiredDescription
requestedinteger; 1..1000000000yesUnits needed.
optionsarray<object>; max 50 itemsyes
overbuyCapPercentstring; length 0..30noReject orders exceeding the request by more than this percent.

Example request body

{
  "requested": 250,
  "overbuyCapPercent": "25",
  "options": [
    {
      "id": "A",
      "packNotation": "case of 12",
      "unitPrice": "1.50",
      "breakpoints": [
        {
          "minQty": 300,
          "unitPrice": "1.20"
        }
      ]
    },
    {
      "id": "B",
      "packNotation": "6x100",
      "moq": 600,
      "unitPrice": "1.00"
    },
    {
      "id": "C",
      "packNotation": "case of 6 inners",
      "unitPrice": "1.10"
    }
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
optionsarray<object>no
beststringnoId of the cheapest valid option by total (lowest overbuy, then first, on ties).
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the money-math-kit package.

Machine-readable