Skip to main content

Preview Guided Setup

POST 

/api/product-account-rules/setup/preview

Steps 2–4 of the guided setup: turn the chosen accounts per group into rule drafts and project the result. Nothing is saved.

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:

  • dimension (string, required) — how revenue is split: category, brand, supplier or type.
  • groups (array, required, may be empty, max 500) — one entry per group from Get Guided Setup Dimensions.
    • groups.*.id (integer or string, required) — the group id (category / brand / supplier id, or a product type value such as manufactured).
    • groups.*.accounts (object, optional) — nominal code id per account type: sales, cogs, inventory, inventory_in_transit, accrued_purchases, discount (each integer or null). Groups with no account are skipped; groups with identical accounts are merged into one rule.
  • suggestions (array of strings, optional) — keys of suggestions from the preview to accept (e.g. brand:8:3, manufactured).
  • use_rule_product_ids (array of integers, optional) — products whose own account override disagrees with the new rules and should be cleared so they follow the rules (see exceptions in the preview).
  • channel_accounts_take_priority (boolean, optional) — set on every generated rule.
  • confirm_type_mismatch (boolean, optional) — accept accounts whose type does not fit their slot.
  • map_account_type (string|null, optional, default sales) — the account type the preview's before/after account_map shows: sales, cogs, inventory, inventory_in_transit, accrued_purchases or discount. Ignored by apply.

Response (data):

  • totals — products_with_rule_accounts, on_company_default, keep_override (products keeping a disagreeing override), will_change (products whose account changes for any type).
  • where_sales_post — after the change, Sales accounts in use: {account: {id, code, name}, count, source}, largest first.
  • rules — the drafts in the order they will be created (above every existing rule): {name, conditions_summary, conditions, accounts, product_count, from_suggestion}.
  • exceptions — up to 500 products whose own override disagrees with a new rule: {product_id, sku, name, group_name, account_types, override_account, rule_account}. Put their ids in use_rule_product_ids to clear the override.
  • suggestions — optional extra rules, never added unless accepted: {key, kind: brand|manufactured, title, description, rule, place_above}. brand proposes a separate rule for a brand that holds at least half of a group and posts elsewhere today; manufactured proposes a COGS-only rule for manufactured products.
  • channels — sales channels with their own Sales account that sell products the new rules reach: {id, name, sales_account, product_count} (sold in the last 365 days).
  • account_map — before and after account maps for map_account_type, grouped by the chosen dimension (same shape as Get Account Map).

Returns 422 when no group has an account.

Request​

Responses​

OK

Response Headers
    Content-Type