Pricing
Set rules once and every slice returns a price.
| Endpoint | Notes |
|---|---|
GET /v1/pricing | { "data": rules }, or { "data": null } before any are saved |
PUT /v1/pricing | Replaces the rules. Slices that succeed afterwards carry a price while enabled is true. |
DELETE /v1/pricing | Removes the rules |
{
"enabled": true,
"currency": "USD",
"minimum": "5.00",
"lines": [
{
"name": "Filament", "basis": "gram", "amount": "0.025",
"variations": [{ "kind": "filament", "slicer": "bambu-studio", "preset": "Shop PLA Black", "amount": "0.04" }]
},
{ "name": "Printer time", "basis": "hour", "amount": "1.50" },
{ "name": "Labour", "basis": "order", "amount": "3.00" },
{ "name": "Margin", "basis": "percent", "amount": "20" }
]
}Lines
Up to 30 lines, each with a unique name. basis is one of:
| Basis | Quantity |
|---|---|
gram | Grams of filament |
hour | Hours of print time |
order | Once per slice |
percent | A share of the sum of the other lines |
Per-gram and per-hour amounts take up to 6 decimals, per-order amounts as many as the currency has, percentages 2.
A variation sets a different amount when the slice uses that printer (machine) or filament. Name a built-in preset with preset, or one of yours with preset (its current name) or preset_id. A name that matches nothing is refused.
Calculation
Each line other than percent is quantity times rate, rounded to whole minor units. Percent lines take their share of those sums, also rounded. If the lines add up to less than minimum, minimum_adjustment_minor covers the gap.
{
"currency": "USD",
"total_minor": 500,
"lines": [
{ "name": "Filament", "basis": "gram", "amount": "0.04", "amount_minor": 32 },
{ "name": "Printer time", "basis": "hour", "amount": "1.50", "amount_minor": 50 },
{ "name": "Labour", "basis": "order", "amount": "3.00", "amount_minor": 300 },
{ "name": "Margin", "basis": "percent", "amount": "20", "amount_minor": 76 }
],
"minimum_adjustment_minor": 42
}The lines and minimum_adjustment_minor always add up to total_minor. The price is fixed when the slice succeeds. Later rule changes don't touch it. enabled: false keeps the rules and stops pricing new slices.