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.
accounting:writeGrant 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,supplierortype.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 asmanufactured).groups.*.accounts(object, optional) — nominal code id per account type:sales,cogs,inventory,inventory_in_transit,accrued_purchases,discount(each integer ornull). 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 (seeexceptionsin 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, defaultsales) — the account type the preview's before/afteraccount_mapshows:sales,cogs,inventory,inventory_in_transit,accrued_purchasesordiscount. 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 inuse_rule_product_idsto clear the override.suggestions— optional extra rules, never added unless accepted:{key, kind: brand|manufactured, title, description, rule, place_above}.brandproposes a separate rule for a brand that holds at least half of a group and posts elsewhere today;manufacturedproposes 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—beforeandafteraccount maps formap_account_type, grouped by the chosen dimension (same shape as Get Account Map).
Returns 422 when no group has an account.
Request
Responses
- 200
- 401
- 403
- 422
- 429
OK
Response Headers
Unauthenticated — the bearer token is missing, revoked, expired, or malformed. Never retry automatically; fix the credential. See the Errors guide.
Forbidden — the token lacks a required scope, the endpoint is not available to API tokens, or the user behind the token lacks the permission. A human must adjust the token scopes or user permissions; do not retry.
Unprocessable Entity
Response Headers
Rate limited — platform limit is 1,000 requests/min; individual tokens may carry lower limits. Honor the Retry-After header before retrying. See the Rate Limits guide.