Skip to main content

Update Account Rule

PUT 

/api/product-account-rules/:rule

Replace an account rule's name, conditions, accounts and flags. Send the complete rule — fields left out of conditions and accounts are cleared.

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 and the manage-accounting-settings permission.

Request body fields:

  • name (string, max 120) — unique among non-archived rules. Required.
  • is_active (boolean, optional, default true) — inactive rules are kept in the order but never match.
  • channel_accounts_take_priority (boolean, optional, default false) — when true, a sales channel or sub-channel that sets its own Sales, COGS or Discount account wins over this rule for orders on that channel. Has no effect on the other account types.
  • conditions (object) required — every non-empty group must match (AND); values inside one group are alternatives (OR). At least one group must be set.
    • conditions.category_ids (array of integers) — product category ids.
    • conditions.include_subcategories (boolean, default true) — also match products in sub-categories of the listed categories.
    • conditions.category_scope (string, primary | any, default primary) — primary matches on the product's primary category only; any matches any category the product is in.
    • conditions.brand_ids (array of integers) — brand ids.
    • conditions.supplier_ids (array of integers) — matched against the product's default supplier.
    • conditions.product_types (array of strings) — one or more of: standard, bundle, kit, matrix, blemished, manufactured.
    • conditions.tag_ids (array of integers) — product tag ids.
    • conditions.sku_prefixes (array of strings, max 5 entries, each max 40 characters) — case-insensitive "SKU starts with".
  • accounts (object) required — the nominal code id to use per account type; send null (or omit the key) to leave that type to lower layers. At least one account must be set. Archived nominal codes are rejected.
    • accounts.sales (integer|null) — Sales (revenue) account.
    • accounts.cogs (integer|null) — Cost of goods sold account.
    • accounts.inventory (integer|null) — Inventory asset account.
    • accounts.inventory_in_transit (integer|null) — Inventory in transit account.
    • accounts.accrued_purchases (integer|null) — Accrued purchases (liability) account.
    • accounts.discount (integer|null) — Discount account.
  • position (integer ≥ 1, optional) — place the rule at this position (1 = evaluated first). When omitted on create, the rule is inserted above the first rule with fewer condition groups (more specific rules first), otherwise at the end.
  • confirm_type_mismatch (boolean, optional) — set true to accept an account whose type does not fit its slot (for example an expense account as the Sales account). Without it such a request returns 422 with code: type_mismatch.
  • expected_updated_at (datetime, optional; updated_at is accepted as an alias) — optimistic lock. Send the updated_at you last read; if the rule changed since, the update is refused with 409 code: rule_conflict and nothing is saved. Omit it to overwrite unconditionally.
  • position moves a non-archived rule; the other rules shift to make room.

Every change to the rule set queues a background run that re-applies the rules to the whole catalog. Its id is returned as tracked_job_id; poll GET /api/tracked-job-logs/{trackedJobLog} to follow it. A newer change supersedes a run that is still queued or running.

Request​

Responses​

OK

Response Headers
    Content-Type