Skip to main content

Preview Account Rule

POST 

/api/product-account-rules/preview

See what a draft rule would do before saving it. Nothing is saved and no background run starts. The draft may be incomplete (no name, no accounts yet).

Required scope: accounting:write

Grant this scope to your token under Settings → Developer → Personal Access Tokens.

Authentication: Requires Bearer token with the accounting:write scope (a read that carries a body).

Request body fields: the same fields as Create Account Rule, all optional, plus:

  • rule_id (integer, optional; id is accepted as an alias) — the saved rule being edited. Its saved version is replaced by the draft in the simulation, and the response adds leaves_this_rule counts. Without it the draft is simulated as a new rule at its insert position (or position).

Response (data):

  • matches — active products meeting the draft's conditions.
  • will_change — distinct active products whose product-level account would change for any account type.
  • by_type — per account type the draft sets: moves_from_default / moves_from_rule (products that would move to the draft's account from the company default / from another rule), already_this_account, blocked_by_override (products keeping their own override), blocked_by_higher_rule (products a rule earlier in the order keeps), leaves_this_rule (edits only: products the saved rule sets today that the draft no longer matches), from_default_account (the company default being left), higher_rules ({id, name, products} for the rules that keep products), and for Sales, COGS and Discount a channel_note (products sold on channels that set their own account, and those channels' names).
  • sample — up to 50 changed product/account-type rows: product_id, sku, name, category, type, from ({code, name, source}), to ({code, name}).
  • applying_in_progress — true while a re-apply run is still working through the catalog (counts reflect the rules, not the unfinished run).

Request​

Responses​

OK

Response Headers
    Content-Type