Units, Quantities, and Bulk Sales¶
BCP uses a shared quantity representation wherever a schema contains an
integer quantity, a quantity_unit, or the shared measure type. It is what
makes it possible to sell in bulk — fruit by the kilogram, fabric by the
metre, fuel by the litre — without putting floating-point numbers on the wire.
Everything on this page is optional: an item without quantity_unit is sold
per unit (each), exactly as before.
Quantity as Steps¶
A quantity is an integer count of steps. A unit descriptor consists of:
unit— a required, stable machine identifier;scale— an optional nonnegative integer, at most 15; its effective value is the provided value, or0when omitted;display_text— a required printable label for the unit.
One step is 10^-scale of unit. The measure type adds a required integer
value, which is also a count of steps. A descriptor's machine identity is
the (unit, effective scale) pair; display_text is not part of it.
The default sale basis is each, with identity (C62, 0). C62 is the
UN/CEFACT Recommendation 20 (Rec20) code for "one/each". The Business MAY
omit quantity_unit from an authoritative representation to encode this
default. Anyone including a descriptor with unit: "C62" MUST use an
effective scale of 0.
Reading a quantity requires no arithmetic and no unit knowledge: shift the
decimal point scale places and append display_text. 1250 with
{ "scale": 3, "display_text": "kg" } renders as 1.250 kg. Because scale
is per-item data (rather than a static table, like a currency exponent), every
authoritative response carries its own descriptor on every non-each line.
Integers, Range, and Arithmetic¶
Every BCP integer field — monetary amounts, step counts, measure values — is
a JSON integer capped at ±(2^53 − 1) (±9,007,199,254,740,991), the range
within which every JSON implementation agrees exactly on integers (RFC 8259
§6) and within which JCS canonicalization (RFC 8785), required for
AP2 mandate signing, is defined. The same cap gives scale
its maximum of 15: at scale 16, one whole unit (10^16 steps) would be
unrepresentable. An out-of-range value is schema-invalid and is rejected like
any other invalid payload.
- Arithmetic over these values MUST be exact. Products such as
price × quantitycan exceed 64 bits: use wider or arbitrary-precision integers, or overflow checks. An implementation that cannot produce an exact, in-range result MUST surface an error rather than emit, display, or act on an approximate value. - When BCP data crosses into external systems, implementations SHOULD
convert once at ingestion into an exact decimal type (SQL
NUMERIC, JavaBigDecimal, PythonDecimal) or carry the (value, scale) pair unchanged, and SHOULD NOT apply scale in binary floating point. - The protocol defines no rounding tolerance and no epsilon comparison. A fulfilled quantity that legitimately differs from the ordered one — 1.190 kg picked against 1.250 kg ordered — is a commercial fact reconciled through adjustments that move money together with quantity.
Unit Vocabulary¶
The Business SHOULD use the exact Rec20 code unless none accurately
identifies the unit; in that case it MAY use its own identifier, and
MUST use it consistently for the same unit. The Platform MUST treat an
unrecognized unit as opaque. Non-exhaustive table:
| Code | Unit |
|---|---|
C62 |
one (each) |
KGM |
kilogram |
GRM |
gram |
LBR |
pound |
MLT |
millilitre |
LTR |
litre |
MTR |
metre |
INH |
inch |
YRD |
yard |
FTK |
square foot |
MTK |
square metre |
HUR |
hour |
MIN |
minute |
Rec20 includes X-prefixed package codes derived from Rec21. BCP excludes them
from quantity_unit: package form is part of the variant's identity (a "box of
12" is a variant), counted as each. The Business MUST NOT use a Rec21
X… code as quantity_unit.
Display text. Anyone sending a descriptor MUST include
display_text. The Platform MUST use it when it does not recognize unit;
for a recognized Rec20 code, it MAY use its own localized label (for
example, "kg"). Neither party MUST use display_text to compare identities
or convert quantities.
Ordering Increment¶
The sale basis (quantity_unit) MAY declare increment: a positive
integer, in steps, whose effective value is the provided value or 1. It
declares the granularity the Business sells in — for example, an item sold by
the kg with scale 3 and increment 50 is sold in multiples of 0.050 kg.
scale bounds what any quantity can express; increment shapes what the
Platform asks for. The increment is advisory merchandising policy:
Platform-authored quantities SHOULD be integer multiples of the increment;
Business-authored quantities (checkout revisions, fulfillment events,
adjustments) are bounded only by scale. increment is not part of the
machine identity and MUST NOT participate in mismatch comparison. The
Business MAY accept, revise, or reject (with a recoverable outcome) an
off-increment request and MUST NOT silently reinterpret it.
Sale Basis in Cart and Checkout¶
- Discovery. The sale basis is item data: the Platform SHOULD
discover the
quantity_unit(withscaleandincrement) from the catalog before transacting. - Request. If the request omits
line_items[].item.quantity_unit, the Platform asserts nothing; the Business interpretsquantityin the item's authoritative basis and returns it in the response. If the Platform includes the descriptor, it is asserting the basis; the Business MUST compare the machine identities. - Mismatch. Silent conversion is forbidden in both directions. The Business
converts visibly (line revised to the authoritative basis, rounded once
to
scale, with aquantity_unit_convertedwarning inmessages[]) or rejects with a recoverablequantity_unit_mismatcherror. - Echo. The Business MAY omit
quantity_uniton aneachline; on every non-eachline, it MUST include it in cart, checkout, and order responses. - Price.
item.priceis the price per one whole unit ofquantity_unit.unit(per kg, per metre). The line amount isprice × quantity × 10^-scale, rounded once to centavos according to the Business's rules.
Taxes Refer to the Whole Line¶
With the Brazilian tax extension, taxes[], base, and amount
refer to the whole line, whatever the quantity_unit — not to the price per
kilogram nor to a step. For a bulk item, the calculation base is that of the
line's total amount.
Example: Bulk Produce¶
Prata bananas sold by the kilogram at R$ 8.99/kg, in multiples of 50 g. The
buyer takes 1.250 kg (1,250 steps of 0.001 kg): 899 × 1250 × 10^-3 = 1123.75,
rounded by the Business to R$ 11.24.
Sale basis declared by the item:
Corresponding checkout line:
[
{
"id": "li_banana",
"item": {
"id": "var_banana_prata",
"title": "Prata bananas",
"price": 899,
"quantity_unit": { "unit": "KGM", "scale": 3, "increment": 50, "display_text": "kg" }
},
"quantity": 1250,
"totals": [
{ "type": "subtotal", "amount": 1124 },
{ "type": "total", "amount": 1124 }
]
}
]
Price per Unit of Measure¶
unit_price is the price per standard unit of measure — the "price per litre"
or "price per kilogram" displayed next to a package price. It is distinct from
quantity_unit: quantity_unit defines the sale basis; unit_price.measure
describes the package content and unit_price.reference the comparison
denominator.
unit_price.currencyMUST equal the price currency; there is no currency conversion.measure.unitandreference.unitMUST be identical; cross-unit conversion is not allowed. The scales may differ.- The Business computes
(price / (measure.value × 10^-measure.scale)) × (reference.value × 10^-reference.scale)and rounds once to centavos. The returned amount is authoritative: the Platform MUST NOT recompute it. - In cart and checkout, the Business MUST include
unit_priceon every line whose pricing basis differs from the sale basis (for example, priced per kg but sold per unit). When the two coincide,item.pricedenominates the charge andunit_priceMAY be omitted.
A 500 mL bottle of olive oil at R$ 39.90, displayed as a price per litre. Both
measures use the same unit (LTR) with different scales:
{
"amount": 7980,
"currency": "BRL",
"measure": { "unit": "LTR", "scale": 3, "value": 500, "display_text": "L" },
"reference": { "unit": "LTR", "value": 1, "display_text": "L" }
}
Availability¶
Catalog variants can report availability: whether the item can be obtained
(available) and an open-vocabulary qualifying status (in_stock,
backorder, preorder, out_of_stock, discontinued). It is a provisional
discovery signal; checkout revalidates.
Schemas¶
Unit¶
See Unit in the Schema Reference for the canonical field definition.
Measure¶
See Measure in the Schema Reference for the canonical field definition.
Sale Basis (quantity_unit)¶
See Quantity Unit in the Schema Reference for the canonical field definition.
Unit Price (unit_price)¶
| Name | Type | Required | Description |
|---|---|---|---|
| amount | Amount | Yes | Unit price in ISO 4217 minor units. After satisfying the same-unit invariant, the Business MUST compute the comparator as (price.amount / (measure.value × 10^-measure.scale)) × (reference.value × 10^-reference.scale) and round it once to ISO 4217 minor units according to its pricing rules. The returned unit_price.amount is authoritative; the Platform MUST NOT recompute or substitute its own result. |
| currency | string | Yes | ISO 4217 currency code. |
| measure | any | Yes | Product quantity in packaging/content (for example, a 750 mL bottle), distinct from quantity_unit, which defines the sale basis. Its integer value MUST be at least 1. |
| reference | any | Yes | Denominator for unit price display (for example, per 100 mL or per 1 kg). Its integer value MUST be at least 1. |
Availability¶
| Name | Type | Required | Description |
|---|---|---|---|
| available | boolean | No | Whether this can be obtained. See status for fulfillment details. |
| status | string | No | Qualifies available with fulfillment state. Well-known values: in_stock, backorder, preorder, out_of_stock, discontinued. |