Skip to main content

Import Account Rules

POST 

/api/product-account-rules/import

Create and update account rules from a CSV file — all or nothing. Rows are matched to existing rules by name (case-insensitive): a matching row updates that rule, any other row creates one. Rules not in the file are left alone.

Required scope: accounting:write

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

Without confirm=1 the call is a preview: the file is validated and the planned changes are returned, but nothing is saved. With confirm=1 and no errors, every row is saved in one transaction and the re-apply run starts.

Authentication: Requires Bearer token with the accounting:write scope. Content-Type: multipart/form-data.

Form fields:

  • file (file, required) — CSV (.csv or .txt), max 5 MB.
  • confirm (1 / 0, optional, default 0) — save the rules.
  • confirm_type_mismatch (1 / 0, optional, default 0) — accept accounts whose type does not fit their column (otherwise reported as row errors).

CSV columns (in order): name, position, is_active, channel_accounts_take_priority, category, include_subcategories, category_scope, brand, default_supplier, product_type, tag, sku_prefix, sales_account, cogs_account, inventory_account, in_transit_account, accrued_purchases_account, discount_account.

  • category, brand, default_supplier, product_type, tag, sku_prefix — names (or product type values), several separated by |.
  • is_active, channel_accounts_take_priority, include_subcategories — 1 or 0.
  • category_scope — primary (match the product's primary category; the default when blank) or any (match any of its categories).
  • Account columns — the nominal code number (e.g. 4010) or "number name" (e.g. 4010 Sales - Binding Machines); blank leaves that account type unset.

Response (data): created / updated (rows that create / update a rule), rules ({name, action: create|update, conditions_summary} per row), errors ({row, message} — row is the CSV line number, header = 1), will_change (active products whose product-level account would change; null when the file has errors), saved (true once written). tracked_job_id is set when a confirmed import saved rules.

A file with any error returns 422 with the same body and saves nothing.

Request​

Responses​

OK

Response Headers
    Content-Type