Pack sizes, MOQ, order increments, overbuy cap and price breakpoints: what to actually order
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
| Field | Type | Required | Description |
|---|---|---|---|
requested | integer; 1..1000000000 | yes | Units needed. |
options | array<object>; max 50 items | yes | |
overbuyCapPercent | string; length 0..30 | no | Reject 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.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: 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. |
options | array<object> | no | |
best | string | no | Id of the cheapest valid option by total (lowest overbuy, then first, on ties). |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always 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
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent