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.
accounting:writeGrant 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 (.csvor.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) orany(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
- 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.