Factuarea APIDevelopers

Preview a base unit replacement

Compute, without writing anything, what happens when a product is replaced by a new one with a different base unit, and mint the impact_token that confirms THAT exact change.

  • The base unit of a product with history (stock, movements, presentations, supplier offers or variants with stock) cannot be edited in place: its base_unit_change.mode is replacement and the way to change it is to replace the product.
  • It is a READ — asking twice over the same catalog returns the same token — but it requires products:write, because the only thing its answer does is authorise an irreversible write.
  • Send target_base_unit (one of the nine measure units; a packaging unit such as XPK or XBX can only be a presentation), equivalence (how many units of the CURRENT base equal ONE unit of the NEW base, e.g. 0.001 when moving from kg to g because 1 g = 0.001 kg; required between a count unit and a measure unit, in either direction; calculated by itself inside the same measure family; there is none between two different measure families), an optional base_price to confirm, and presentations with a keep or retire decision per presentation of the old product (the ones you omit get the proposed decision).
  • The answer lists every element of the plan in items, each with its before, its after, its group (review, converted or carried) and its flags (precision_loss, no_equivalence, fraction); items[].ref is the public id of the affected element, and null for the product itself and for price-list entries and pack components, which have no public id.
  • pending_documents lists the unissued sales documents that will keep pointing at the old product.
  • The token is a fingerprint of the plan, not a credential: if the catalog, the price lists or the packs change before you confirm, the confirmation is rejected with 422 base_unit_replacement_preview_stale and you ask for a fresh preview.
  • A product of another company returns 404 product_not_found.
POST
/products/{product}/base_unit_replacement/preview
AuthorizationBearer <token>

In: header

Path Parameters

product*string

Headers

Factuarea-Version?string

Pin the API version (YYYY-MM-DD, Stripe-style date versioning) for this request; omit to use the key's pinned version, or the latest if none. Unsupported version → 400 unsupported_api_version; malformed → 400 parameter_invalid_format. The effective version is echoed in the Factuarea-Version response header. See the Versioning guide.

Formatdate
X-Active-Profile?string

Operate on behalf of a child company (gestoría master key): pass its public id (UUID v7) and the request runs against that child's data without changing the key's scope, tier or environment (omit to use the key's own company). Invalid UUID → 400 parameter_invalid_uuid; unknown or non-owned id → 404 profile_not_found. See the Acting on behalf guide.

Formatuuid

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json