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.
accounting:writeGrant 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, defaulttrue) — inactive rules are kept in the order but never match.channel_accounts_take_priority(boolean, optional, defaultfalse) — whentrue, 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, defaulttrue) — also match products in sub-categories of the listed categories.conditions.category_scope(string,primary|any, defaultprimary) —primarymatches on the product's primary category only;anymatches 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; sendnull(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) — settrueto 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 withcode: type_mismatch.expected_updated_at(datetime, optional;updated_atis accepted as an alias) — optimistic lock. Send theupdated_atyou last read; if the rule changed since, the update is refused with 409code: rule_conflictand nothing is saved. Omit it to overwrite unconditionally.positionmoves 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
- 200
- 401
- 403
- 404
- 409
- 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.
Not Found
Response Headers
Conflict
Response Headers
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.