Factuarea APIDevelopers

Replace a product by changing its base unit

Replace a product by a NEW one with a different base unit and answer 201 with the new product, whose replaces points at the old one.

  • The stock, the presentations you keep, the variants, the supplier offers, the price-list entries and the pack components are converted and moved to the new product; the old one is deactivated, keeps its whole history and its replaced_by points at the new one, and it can never be reactivated.
  • It is IRREVERSIBLE: there is no inverse operation, so Idempotency-Key is mandatory and retrying with the same key returns the same response without creating a second product.
  • The body is the one of the preview plus the mandatory impact_token of a current preview with the same request.
  • It does not consume plan quota: the old product stops counting and the net usage is zero.
  • When the conversion loses precision or there is no equivalence, base_price must be confirmed (422 base_unit_replacement_price_confirmation_required).
  • Rejections: 422 business_rule_violation with subcode product_already_replaced, base_unit_replacement_conversion_unavailable or base_unit_replacement_blocked_by_packs; 422 parameter_invalid_value with subcode base_unit_replacement_same_unit (the target is already the base unit of the product), base_unit_replacement_equivalence_invalid, base_unit_replacement_price_confirmation_required, base_unit_replacement_preview_stale or base_unit_replacement_decision_invalid.
  • The product.replaced event is published with the new product as its object.
  • A product of another company returns 404 product_not_found.
POST
/products/{product}/base_unit_replacement
AuthorizationBearer <token>

In: header

Path Parameters

product*string

Headers

Idempotency-Key*string

Client-generated opaque key (up to 255 characters; UUID v7 recommended) that makes retries safe: the first response is cached and replayed for repeats without re-executing the mutation. Reusing a key with a different body returns 409 idempotency_key_reused. See the Idempotency guide. Required on this operation: repeating it delivers an effect that cannot be taken back (an email sent, a file generated, a third-party call, a charge), so a request without this header is rejected with 422 idempotency_key_required before any business logic runs.

Length1 <= length <= 255
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