Create a cost rule
Create a cost rule. Accepts the same snake_case body as the admin Cost Rules API. Requires the tenant Cost Rules feature flag.
On create, name and document_types (or singular document_type) are
required; vendor_id is required unless output_kind is EXTRA_COST.
When output_kind is EXTRA_COST, cost_basis and cost_basis_amount
become required.
Authorizations
Authenticate using a bearer token. To create a token, navigate to /settings/api-tokens and click Create API Token.
Body
Rule name. Required on create. Must be unique per vendor among non-deleted rules.
255Supplier / factory ID. Required on create unless output_kind is EXTRA_COST
(where the supplier is an optional document condition). Optional on update.
1000Document types the rule applies to. Required on create (or provide singular document_type).
1PURCHASE_ORDER, WORK_ORDER, SHIPMENT Singular alternative to document_types (back-compat).
PURCHASE_ORDER, WORK_ORDER, SHIPMENT Defaults to NON_GRADUATED.
NON_GRADUATED, GRADUATED Defaults to LINE.
LINE, SCOPE_GROUP Defaults to 100.
1 <= x <= 1000Defaults to ACTIVE on create.
ACTIVE, INACTIVE, DRAFT Must be on or after effective_from.
x >= 0x >= 0Defaults to UNIT_COST.
UNIT_COST, EXTRA_COST 255UNIT_BASED_ALLOCATION, VOLUME_BASED_ALLOCATION, WEIGHT_BASED_ALLOCATION, VALUE_BASED_ALLOCATION Required when output_kind is EXTRA_COST.
PERCENTAGE, FIXED Required when output_kind is EXTRA_COST.
x >= 030Product / category / tag / supplier-SKU scopes. Replaces existing scopes when provided.
Document-level applicability gates. Replaces existing conditions when provided.
Quantity tiers with their effects. Replaces existing tiers when provided.
Response
Cost rule created.
A cost rule — vendor-scoped tiered pricing or extra-cost rule applied to
purchase orders, work orders, and shipments. Nested scopes, conditions,
and tiers (with effects) are only present when the relation is loaded
(always on GET /cost-rules/{id}).